From 57b094aae03a1d3f41ed803490626600f2747070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=20G=C3=B3mez?= Date: Tue, 3 Oct 2023 22:31:16 +0200 Subject: [PATCH 1/9] chore: add reporting of bad code --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 1a16c8a1..d110bc16 100644 --- a/Makefile +++ b/Makefile @@ -13,16 +13,16 @@ test: docker exec codely-php_ddd_skeleton-backoffice_backend-php ./vendor/bin/phpunit --testsuite backoffice static-analysis: - docker exec codely-php_ddd_skeleton-mooc_backend-php ./vendor/bin/psalm + docker exec codely-php_ddd_skeleton-mooc_backend-php ./vendor/bin/psalm --output-format=github lint: docker exec codely-php_ddd_skeleton-mooc_backend-php ./vendor/bin/ecs check test-architecture: - docker exec codely-php_ddd_skeleton-mooc_backend-php php -d memory_limit=4G ./vendor/bin/phpstan analyse + docker exec codely-php_ddd_skeleton-mooc_backend-php php -d memory_limit=4G ./vendor/bin/phpstan analyse --error-format=github mess-detector: - docker exec codely-php_ddd_skeleton-mooc_backend-php ./vendor/bin/phpmd apps,src,tests text phpmd.xml + docker exec codely-php_ddd_skeleton-mooc_backend-php ./vendor/bin/phpmd apps,src,tests github phpmd.xml start: @if [ ! -f .env.local ]; then echo '' > .env.local; fi From ba150634d61c97f837be016cdd4ad29c717067dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=20G=C3=B3mez?= Date: Tue, 3 Oct 2023 22:43:46 +0200 Subject: [PATCH 2/9] break: try psalm reporting --- .../CoursesCounter/Application/Find/CoursesCounterResponse.php | 2 +- src/Mooc/CoursesCounter/Domain/CoursesCounter.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mooc/CoursesCounter/Application/Find/CoursesCounterResponse.php b/src/Mooc/CoursesCounter/Application/Find/CoursesCounterResponse.php index b7ddf561..d85597df 100644 --- a/src/Mooc/CoursesCounter/Application/Find/CoursesCounterResponse.php +++ b/src/Mooc/CoursesCounter/Application/Find/CoursesCounterResponse.php @@ -10,7 +10,7 @@ { public function __construct(private int $total) {} - public function total(): int + public function total() { return $this->total; } diff --git a/src/Mooc/CoursesCounter/Domain/CoursesCounter.php b/src/Mooc/CoursesCounter/Domain/CoursesCounter.php index 0a6ed0d1..97d6d7bf 100644 --- a/src/Mooc/CoursesCounter/Domain/CoursesCounter.php +++ b/src/Mooc/CoursesCounter/Domain/CoursesCounter.php @@ -21,7 +21,7 @@ public function __construct( $this->existingCourses = $existingCourses; } - public static function initialize(CoursesCounterId $id): self + public static function initialize(CoursesCounterId $id) { return new self($id, CoursesCounterTotal::initialize()); } From 9c02f2541239ea46a4dc88f35d8a1b21a5a17945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=20G=C3=B3mez?= Date: Tue, 3 Oct 2023 22:49:32 +0200 Subject: [PATCH 3/9] Revert "break: try psalm reporting" This reverts commit ba150634d61c97f837be016cdd4ad29c717067dc. --- .../CoursesCounter/Application/Find/CoursesCounterResponse.php | 2 +- src/Mooc/CoursesCounter/Domain/CoursesCounter.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mooc/CoursesCounter/Application/Find/CoursesCounterResponse.php b/src/Mooc/CoursesCounter/Application/Find/CoursesCounterResponse.php index d85597df..b7ddf561 100644 --- a/src/Mooc/CoursesCounter/Application/Find/CoursesCounterResponse.php +++ b/src/Mooc/CoursesCounter/Application/Find/CoursesCounterResponse.php @@ -10,7 +10,7 @@ { public function __construct(private int $total) {} - public function total() + public function total(): int { return $this->total; } diff --git a/src/Mooc/CoursesCounter/Domain/CoursesCounter.php b/src/Mooc/CoursesCounter/Domain/CoursesCounter.php index 97d6d7bf..0a6ed0d1 100644 --- a/src/Mooc/CoursesCounter/Domain/CoursesCounter.php +++ b/src/Mooc/CoursesCounter/Domain/CoursesCounter.php @@ -21,7 +21,7 @@ public function __construct( $this->existingCourses = $existingCourses; } - public static function initialize(CoursesCounterId $id) + public static function initialize(CoursesCounterId $id): self { return new self($id, CoursesCounterTotal::initialize()); } From f1e592a2b57f98c80994ac78bd00ebf2c0b6e73a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=20G=C3=B3mez?= Date: Tue, 3 Oct 2023 22:50:22 +0200 Subject: [PATCH 4/9] break: try phpat reporting --- src/Shared/Infrastructure/PhpRandomNumberGenerator.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Shared/Infrastructure/PhpRandomNumberGenerator.php b/src/Shared/Infrastructure/PhpRandomNumberGenerator.php index b01b0463..fa830560 100644 --- a/src/Shared/Infrastructure/PhpRandomNumberGenerator.php +++ b/src/Shared/Infrastructure/PhpRandomNumberGenerator.php @@ -4,12 +4,15 @@ namespace CodelyTv\Shared\Infrastructure; +use CodelyTv\Mooc\Videos\Domain\VideoTitle; use CodelyTv\Shared\Domain\RandomNumberGenerator; final class PhpRandomNumberGenerator implements RandomNumberGenerator { public function generate(): int { + $uuid = new VideoTitle('test'); + return random_int(1, 5); } } From f9bdba37cd385551f8a8060a22ecc6257bbc9d36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=20G=C3=B3mez?= Date: Tue, 3 Oct 2023 22:50:55 +0200 Subject: [PATCH 5/9] Revert "break: try phpat reporting" This reverts commit f1e592a2b57f98c80994ac78bd00ebf2c0b6e73a. --- src/Shared/Infrastructure/PhpRandomNumberGenerator.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Shared/Infrastructure/PhpRandomNumberGenerator.php b/src/Shared/Infrastructure/PhpRandomNumberGenerator.php index fa830560..b01b0463 100644 --- a/src/Shared/Infrastructure/PhpRandomNumberGenerator.php +++ b/src/Shared/Infrastructure/PhpRandomNumberGenerator.php @@ -4,15 +4,12 @@ namespace CodelyTv\Shared\Infrastructure; -use CodelyTv\Mooc\Videos\Domain\VideoTitle; use CodelyTv\Shared\Domain\RandomNumberGenerator; final class PhpRandomNumberGenerator implements RandomNumberGenerator { public function generate(): int { - $uuid = new VideoTitle('test'); - return random_int(1, 5); } } From 3bb10721b77e53b8c70176e6100e569d299e088f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=20G=C3=B3mez?= Date: Tue, 3 Oct 2023 22:52:42 +0200 Subject: [PATCH 6/9] break: try phpmd reporting --- .../Infrastructure/PhpRandomNumberGenerator.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Shared/Infrastructure/PhpRandomNumberGenerator.php b/src/Shared/Infrastructure/PhpRandomNumberGenerator.php index b01b0463..5e2e8857 100644 --- a/src/Shared/Infrastructure/PhpRandomNumberGenerator.php +++ b/src/Shared/Infrastructure/PhpRandomNumberGenerator.php @@ -10,6 +10,20 @@ final class PhpRandomNumberGenerator implements RandomNumberGenerator { public function generate(): int { - return random_int(1, 5); + $random = random_int(1, 5); + + if ($random > 1) { + if ($random > 2) { + if ($random > 3) { + if ($random > 4) { + return 5; + } else { + return 4; + } + } + } + } + + return $random; } } From f8a5c9c4d82d47d3dc3a9a98d85928af0a0f30ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=20G=C3=B3mez?= Date: Tue, 3 Oct 2023 22:58:01 +0200 Subject: [PATCH 7/9] Revert "break: try phpmd reporting" This reverts commit 3bb10721b77e53b8c70176e6100e569d299e088f. --- .../Infrastructure/PhpRandomNumberGenerator.php | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/Shared/Infrastructure/PhpRandomNumberGenerator.php b/src/Shared/Infrastructure/PhpRandomNumberGenerator.php index 5e2e8857..b01b0463 100644 --- a/src/Shared/Infrastructure/PhpRandomNumberGenerator.php +++ b/src/Shared/Infrastructure/PhpRandomNumberGenerator.php @@ -10,20 +10,6 @@ final class PhpRandomNumberGenerator implements RandomNumberGenerator { public function generate(): int { - $random = random_int(1, 5); - - if ($random > 1) { - if ($random > 2) { - if ($random > 3) { - if ($random > 4) { - return 5; - } else { - return 4; - } - } - } - } - - return $random; + return random_int(1, 5); } } From 33b1c28ed217a0095c7019330efc665cea50ece0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=20G=C3=B3mez?= Date: Tue, 3 Oct 2023 23:00:36 +0200 Subject: [PATCH 8/9] chore(psalm): add type coverage --- Dockerfile | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index e5dd7520..5a269cec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM php:8.2-fpm-alpine WORKDIR /app RUN apk --update upgrade \ - && apk add --no-cache autoconf automake make gcc g++ bash icu-dev libzip-dev rabbitmq-c rabbitmq-c-dev linux-headers + && apk add --no-cache autoconf automake make gcc g++ git bash icu-dev libzip-dev rabbitmq-c rabbitmq-c-dev linux-headers RUN pecl install apcu-5.1.22 && pecl install amqp-2.1.0 && pecl install xdebug-3.2.2 diff --git a/Makefile b/Makefile index d110bc16..efec06c2 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ test: docker exec codely-php_ddd_skeleton-backoffice_backend-php ./vendor/bin/phpunit --testsuite backoffice static-analysis: - docker exec codely-php_ddd_skeleton-mooc_backend-php ./vendor/bin/psalm --output-format=github + docker exec codely-php_ddd_skeleton-mooc_backend-php ./vendor/bin/psalm --output-format=github --shepherd lint: docker exec codely-php_ddd_skeleton-mooc_backend-php ./vendor/bin/ecs check From 016b2210d8f217da218e0cd86089d7b171adaa74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=20G=C3=B3mez?= Date: Tue, 3 Oct 2023 23:05:48 +0200 Subject: [PATCH 9/9] chore(psalm): add type coverage --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ade42f64..5cb549a7 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ codely.tv CodelyTV Courses Symfony 6 + Type Coverage CI pipeline status