From add917a73ad6c99ebdc607b081c31cf85d9b4119 Mon Sep 17 00:00:00 2001 From: Fabien Villepinte Date: Thu, 12 Jun 2025 10:18:58 +0200 Subject: [PATCH 1/9] Upgrade actions/upload-artifact to v4 --- .github/workflows/continuous-integration.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 992ba72..c991e61 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -114,9 +114,9 @@ jobs: docker run -i --rm -v $PWD:/churn ${{ matrix.vcs }} /churn/vendor/bin/simple-phpunit -c /churn/phpunit.xml.dist /churn/tests/EndToEnd/${vcs^}Test.php --coverage-clover=/churn/coverage-${{ matrix.vcs }}.xml sed -i 's/\/churn\/src/\/home\/runner\/work\/${{ github.event.repository.name }}\/${{ github.event.repository.name }}\/src/g' coverage-${{ matrix.vcs }}.xml - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: - name: coverage + name: coverage-${{ matrix.vcs }} path: ./coverage-${{ matrix.vcs }}.xml coverage: @@ -148,7 +148,8 @@ jobs: - name: "Download other code coverage reports" uses: actions/download-artifact@v3 with: - name: coverage + pattern: coverage-* + merge-multiple: true path: ./coverage - name: "List all coverage reports" @@ -269,7 +270,7 @@ jobs: run: diff -u <(build/bin/churn --format=csv | sort) <(./churn.phar --format=csv | sort) - name: "Save Phar" - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: churn.phar path: ./churn.phar From c185fa660320255a9aa1f36858068e07b53dd464 Mon Sep 17 00:00:00 2001 From: Fabien Villepinte Date: Thu, 12 Jun 2025 10:22:59 +0200 Subject: [PATCH 2/9] ci: Run Infection with PHP 8.2 --- .github/workflows/pull-request.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index a30a263..cbfae84 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -20,10 +20,10 @@ jobs: with: coverage: "pcov" ini-values: "error_reporting=-1, display_errors=On, display_startup_errors=On, zend.assertions=1" - php-version: "8.1" + php-version: "8.2" tools: composer:v2, infection - - uses: "ramsey/composer-install@v2" + - uses: "ramsey/composer-install@v3" with: dependency-versions: "highest" composer-options: "--no-scripts" From 46e81c3206a3f7777c17b9a0c630279951b9f269 Mon Sep 17 00:00:00 2001 From: Fabien Villepinte Date: Thu, 12 Jun 2025 10:36:07 +0200 Subject: [PATCH 3/9] ci: Remove constraint on nikic/php-parser --- phpunit.xml.dist | 1 - vendor-bin/psalm/composer.json | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 85baba3..01e06e4 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -25,6 +25,5 @@ - diff --git a/vendor-bin/psalm/composer.json b/vendor-bin/psalm/composer.json index f6ddacd..ff6a240 100644 --- a/vendor-bin/psalm/composer.json +++ b/vendor-bin/psalm/composer.json @@ -1,9 +1,9 @@ { "require-dev": { "psalm/plugin-mockery": "^0.10.0 || ^1.0", - "psalm/plugin-phpunit": "^0.18.3", + "psalm/plugin-phpunit": ">=0.18.3", "psalm/plugin-symfony": "^2.1 || ^3.0 || ^4.0 || ^5.0", - "vimeo/psalm": "^4.6 || ^5.0" + "vimeo/psalm": "^4.6 || ^5.0 || ^6.0" }, "config": { "allow-plugins": { From cd2bc06947f716da82ab8a58f24c4292a0af4bd5 Mon Sep 17 00:00:00 2001 From: Fabien Villepinte Date: Thu, 12 Jun 2025 10:41:09 +0200 Subject: [PATCH 4/9] refactor: Add missing Override attribute --- src/Assessor/CyclomaticComplexityAssessor.php | 1 + src/Command/AssessComplexityCommand.php | 2 ++ src/Command/Helper/ProgressBarSubscriber.php | 3 +++ src/Command/RunCommand.php | 2 ++ src/Configuration/Validator/BaseValidator.php | 2 ++ src/Configuration/Validator/CachePath.php | 1 + src/Configuration/Validator/CommitsSince.php | 2 ++ src/Configuration/Validator/DirectoriesToScan.php | 1 + src/Configuration/Validator/FileExtensions.php | 1 + src/Configuration/Validator/FilesToIgnore.php | 1 + src/Configuration/Validator/FilesToShow.php | 1 + src/Configuration/Validator/Hooks.php | 1 + src/Configuration/Validator/MaxScoreThreshold.php | 1 + src/Configuration/Validator/MinScoreToShow.php | 1 + src/Configuration/Validator/ParallelJobs.php | 1 + src/Configuration/Validator/Vcs.php | 1 + src/Event/BrokerImpl.php | 2 ++ src/Event/Channel/AfterAnalysisChannel.php | 3 +++ src/Event/Channel/AfterFileAnalysisChannel.php | 3 +++ src/Event/Channel/BeforeAnalysisChannel.php | 3 +++ src/Event/Event/AfterAnalysisEvent.php | 4 ++++ src/Event/Event/AfterFileAnalysisEvent.php | 3 +++ src/Event/Subscriber/AfterAnalysisHookDecorator.php | 1 + src/Event/Subscriber/AfterFileAnalysisHookDecorator.php | 1 + src/Event/Subscriber/BeforeAnalysisHookDecorator.php | 1 + src/Process/CacheProcessFactory.php | 3 +++ src/Process/ChangesCount/FossilChangesCountProcess.php | 1 + src/Process/ChangesCount/GitChangesCountProcess.php | 1 + src/Process/ChangesCount/MercurialChangesCountProcess.php | 1 + src/Process/ChangesCount/NoVcsChangesCountProcess.php | 4 ++++ src/Process/ChangesCount/SubversionChangesCountProcess.php | 1 + src/Process/ChurnProcess.php | 3 +++ src/Process/ConcreteProcessFactory.php | 1 + src/Process/CyclomaticComplexityProcess.php | 1 + src/Process/Handler/ParallelProcessHandler.php | 1 + src/Process/Handler/SequentialProcessHandler.php | 1 + src/Process/PredefinedProcess.php | 5 +++++ src/Result/Render/ConsoleResultsRenderer.php | 1 + src/Result/Render/CsvResultsRenderer.php | 1 + src/Result/Render/JsonResultsRenderer.php | 1 + src/Result/Render/MarkdownResultsRenderer.php | 1 + src/Result/Result.php | 5 +++++ src/Result/ResultAccumulator.php | 5 +++++ tests/EndToEnd/FossilTest.php | 2 ++ tests/EndToEnd/MercurialTest.php | 2 ++ tests/EndToEnd/SubversionTest.php | 2 ++ tests/Integration/Command/AssessComplexityCommandTest.php | 2 ++ tests/Integration/Command/Assets/PrintHook.php | 2 ++ tests/Integration/Command/Assets/TestHook.php | 3 +++ tests/Integration/Command/RunCommandTest.php | 2 ++ tests/Integration/File/FileFinderTest.php | 1 + tests/Integration/ManifestTest.php | 1 + tests/Unit/Configuration/Validator/CachePathTest.php | 5 +++++ tests/Unit/Configuration/Validator/CommitsSinceTest.php | 6 ++++++ .../Unit/Configuration/Validator/DirectoriesToScanTest.php | 5 +++++ tests/Unit/Configuration/Validator/FileExtensionsTest.php | 5 +++++ tests/Unit/Configuration/Validator/FilesToIgnoreTest.php | 5 +++++ tests/Unit/Configuration/Validator/FilesToShowTest.php | 5 +++++ tests/Unit/Configuration/Validator/HooksTest.php | 5 +++++ .../Unit/Configuration/Validator/MaxScoreThresholdTest.php | 5 +++++ tests/Unit/Configuration/Validator/MinScoreToShowTest.php | 5 +++++ tests/Unit/Configuration/Validator/ParallelJobsTest.php | 5 +++++ .../Unit/Configuration/Validator/ValidatorBaseTestCase.php | 1 + tests/Unit/Configuration/Validator/VcsTest.php | 5 +++++ tests/Unit/File/FileFinderTest.php | 1 + tests/Unit/File/FileHelperTest.php | 1 + tests/Unit/File/FileTest.php | 1 + .../Process/ChangesCount/NoVcsChangesCountProcessTest.php | 1 + tests/Unit/Process/ConcreteProcessFactoryTest.php | 1 + tests/Unit/Result/ResultTest.php | 1 + tests/Unit/Result/ResultsRendererFactoryTest.php | 1 + 71 files changed, 161 insertions(+) diff --git a/src/Assessor/CyclomaticComplexityAssessor.php b/src/Assessor/CyclomaticComplexityAssessor.php index fb7e6a7..361e700 100644 --- a/src/Assessor/CyclomaticComplexityAssessor.php +++ b/src/Assessor/CyclomaticComplexityAssessor.php @@ -43,6 +43,7 @@ public function __construct() * * @param string $contents The contents of a PHP file. */ + #[\Override] public function assess(string $contents): int { $score = 0; diff --git a/src/Command/AssessComplexityCommand.php b/src/Command/AssessComplexityCommand.php index fe7a057..1a3c6a0 100644 --- a/src/Command/AssessComplexityCommand.php +++ b/src/Command/AssessComplexityCommand.php @@ -44,6 +44,7 @@ public static function newInstance(): self /** * Configure the command */ + #[\Override] protected function configure(): void { $this->setName('assess-complexity') @@ -57,6 +58,7 @@ protected function configure(): void * @param InputInterface $input Input. * @param OutputInterface $output Output. */ + #[\Override] protected function execute(InputInterface $input, OutputInterface $output): int { $file = (string) $input->getArgument('file'); diff --git a/src/Command/Helper/ProgressBarSubscriber.php b/src/Command/Helper/ProgressBarSubscriber.php index 019dd02..e6d6bf9 100644 --- a/src/Command/Helper/ProgressBarSubscriber.php +++ b/src/Command/Helper/ProgressBarSubscriber.php @@ -34,6 +34,7 @@ public function __construct(OutputInterface $output) /** * @param AfterAnalysisEvent $event The event triggered when the analysis is done. */ + #[\Override] public function onAfterAnalysis(AfterAnalysisEvent $event): void { $this->progressBar->finish(); @@ -42,6 +43,7 @@ public function onAfterAnalysis(AfterAnalysisEvent $event): void /** * @param BeforeAnalysisEvent $event The event triggered when the analysis starts. */ + #[\Override] public function onBeforeAnalysis(BeforeAnalysisEvent $event): void { $this->progressBar->start(); @@ -50,6 +52,7 @@ public function onBeforeAnalysis(BeforeAnalysisEvent $event): void /** * @param AfterFileAnalysisEvent $event The event triggered when the analysis of a file is done. */ + #[\Override] public function onAfterFileAnalysis(AfterFileAnalysisEvent $event): void { $this->progressBar->advance(); diff --git a/src/Command/RunCommand.php b/src/Command/RunCommand.php index 32e9cd0..d6d927e 100644 --- a/src/Command/RunCommand.php +++ b/src/Command/RunCommand.php @@ -84,6 +84,7 @@ public static function newInstance(): self /** * Configure the command */ + #[\Override] protected function configure(): void { $this->setName('run') @@ -104,6 +105,7 @@ protected function configure(): void * @param InputInterface $input Input. * @param OutputInterface $output Output. */ + #[\Override] protected function execute(InputInterface $input, OutputInterface $output): int { if (true === $input->getOption('quiet')) { diff --git a/src/Configuration/Validator/BaseValidator.php b/src/Configuration/Validator/BaseValidator.php index f4ab55d..d444a2d 100644 --- a/src/Configuration/Validator/BaseValidator.php +++ b/src/Configuration/Validator/BaseValidator.php @@ -34,6 +34,7 @@ public function __construct(string $key) /** * Returns the configuration key. */ + #[\Override] public function getKey(): string { return $this->key; @@ -43,6 +44,7 @@ public function getKey(): string * @param EditableConfig $config The configuration object. * @param array $configuration The array containing the configuration values. */ + #[\Override] public function validate(EditableConfig $config, array $configuration): void { if (!\array_key_exists($this->key, $configuration)) { diff --git a/src/Configuration/Validator/CachePath.php b/src/Configuration/Validator/CachePath.php index d2cb14b..3f92796 100644 --- a/src/Configuration/Validator/CachePath.php +++ b/src/Configuration/Validator/CachePath.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { if (null === $value) { diff --git a/src/Configuration/Validator/CommitsSince.php b/src/Configuration/Validator/CommitsSince.php index dac2d6e..4beb509 100644 --- a/src/Configuration/Validator/CommitsSince.php +++ b/src/Configuration/Validator/CommitsSince.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param array $configuration The array containing the configuration values. */ + #[\Override] public function validate(EditableConfig $config, array $configuration): void { if (!$this->hasConfigurationKey($configuration)) { @@ -40,6 +41,7 @@ public function validate(EditableConfig $config, array $configuration): void * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { Assert::string($value, 'Commits since should be a string'); diff --git a/src/Configuration/Validator/DirectoriesToScan.php b/src/Configuration/Validator/DirectoriesToScan.php index 15c29d8..a2601bf 100644 --- a/src/Configuration/Validator/DirectoriesToScan.php +++ b/src/Configuration/Validator/DirectoriesToScan.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { Assert::isArray($value, 'Directories to scan should be an array of strings'); diff --git a/src/Configuration/Validator/FileExtensions.php b/src/Configuration/Validator/FileExtensions.php index 857194b..23b8717 100644 --- a/src/Configuration/Validator/FileExtensions.php +++ b/src/Configuration/Validator/FileExtensions.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { Assert::isArray($value, 'File extensions should be an array of strings'); diff --git a/src/Configuration/Validator/FilesToIgnore.php b/src/Configuration/Validator/FilesToIgnore.php index b924603..ed22777 100644 --- a/src/Configuration/Validator/FilesToIgnore.php +++ b/src/Configuration/Validator/FilesToIgnore.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { Assert::isArray($value, 'Files to ignore should be an array of strings'); diff --git a/src/Configuration/Validator/FilesToShow.php b/src/Configuration/Validator/FilesToShow.php index efcb049..b4f874a 100644 --- a/src/Configuration/Validator/FilesToShow.php +++ b/src/Configuration/Validator/FilesToShow.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { Assert::integer($value, 'Files to show should be an integer'); diff --git a/src/Configuration/Validator/Hooks.php b/src/Configuration/Validator/Hooks.php index 7ed7490..d783a3b 100644 --- a/src/Configuration/Validator/Hooks.php +++ b/src/Configuration/Validator/Hooks.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { Assert::isArray($value, 'Hooks should be an array of strings'); diff --git a/src/Configuration/Validator/MaxScoreThreshold.php b/src/Configuration/Validator/MaxScoreThreshold.php index 90d6623..a08fc62 100644 --- a/src/Configuration/Validator/MaxScoreThreshold.php +++ b/src/Configuration/Validator/MaxScoreThreshold.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { if (null === $value) { diff --git a/src/Configuration/Validator/MinScoreToShow.php b/src/Configuration/Validator/MinScoreToShow.php index 880ee39..5ee13d2 100644 --- a/src/Configuration/Validator/MinScoreToShow.php +++ b/src/Configuration/Validator/MinScoreToShow.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { if (null === $value) { diff --git a/src/Configuration/Validator/ParallelJobs.php b/src/Configuration/Validator/ParallelJobs.php index 72a17c2..8caa41d 100644 --- a/src/Configuration/Validator/ParallelJobs.php +++ b/src/Configuration/Validator/ParallelJobs.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { Assert::integer($value, 'Amount of parallel jobs should be an integer'); diff --git a/src/Configuration/Validator/Vcs.php b/src/Configuration/Validator/Vcs.php index bfece92..1619431 100644 --- a/src/Configuration/Validator/Vcs.php +++ b/src/Configuration/Validator/Vcs.php @@ -24,6 +24,7 @@ public function __construct() * @param EditableConfig $config The configuration object. * @param mixed $value The value to validate. */ + #[\Override] protected function validateValue(EditableConfig $config, $value): void { Assert::string($value, 'VCS should be a string'); diff --git a/src/Event/BrokerImpl.php b/src/Event/BrokerImpl.php index fc71381..84a372e 100644 --- a/src/Event/BrokerImpl.php +++ b/src/Event/BrokerImpl.php @@ -39,6 +39,7 @@ public function __construct() /** * @param object $subscriber A subscriber object. */ + #[\Override] public function subscribe($subscriber): void { foreach ($this->channels as $channel) { @@ -53,6 +54,7 @@ public function subscribe($subscriber): void /** * @param Event $event The triggered event. */ + #[\Override] public function notify(Event $event): void { foreach ($this->subscribers as $eventClass => $subscribers) { diff --git a/src/Event/Channel/AfterAnalysisChannel.php b/src/Event/Channel/AfterAnalysisChannel.php index 175f42d..acc974e 100644 --- a/src/Event/Channel/AfterAnalysisChannel.php +++ b/src/Event/Channel/AfterAnalysisChannel.php @@ -18,6 +18,7 @@ final class AfterAnalysisChannel implements Channel /** * @param object $subscriber A subscriber instance. */ + #[\Override] public function accepts($subscriber): bool { return $subscriber instanceof AfterAnalysis; @@ -26,6 +27,7 @@ public function accepts($subscriber): bool /** * @psalm-return class-string */ + #[\Override] public function getEventClassname(): string { return AfterAnalysisEvent::class; @@ -36,6 +38,7 @@ public function getEventClassname(): string * @psalm-param AfterAnalysis $subscriber * @psalm-return Closure(AfterAnalysisEvent): void */ + #[\Override] public function buildEventHandler($subscriber): Closure { return static function (AfterAnalysisEvent $event) use ($subscriber): void { diff --git a/src/Event/Channel/AfterFileAnalysisChannel.php b/src/Event/Channel/AfterFileAnalysisChannel.php index 3bc3b1b..3b80c64 100644 --- a/src/Event/Channel/AfterFileAnalysisChannel.php +++ b/src/Event/Channel/AfterFileAnalysisChannel.php @@ -18,6 +18,7 @@ final class AfterFileAnalysisChannel implements Channel /** * @param object $subscriber A subscriber instance. */ + #[\Override] public function accepts($subscriber): bool { return $subscriber instanceof AfterFileAnalysis; @@ -26,6 +27,7 @@ public function accepts($subscriber): bool /** * @psalm-return class-string */ + #[\Override] public function getEventClassname(): string { return AfterFileAnalysisEvent::class; @@ -36,6 +38,7 @@ public function getEventClassname(): string * @psalm-param AfterFileAnalysis $subscriber * @psalm-return Closure(AfterFileAnalysisEvent): void */ + #[\Override] public function buildEventHandler($subscriber): Closure { return static function (AfterFileAnalysisEvent $event) use ($subscriber): void { diff --git a/src/Event/Channel/BeforeAnalysisChannel.php b/src/Event/Channel/BeforeAnalysisChannel.php index 3718b3f..4e698f8 100644 --- a/src/Event/Channel/BeforeAnalysisChannel.php +++ b/src/Event/Channel/BeforeAnalysisChannel.php @@ -18,6 +18,7 @@ final class BeforeAnalysisChannel implements Channel /** * @param object $subscriber A subscriber instance. */ + #[\Override] public function accepts($subscriber): bool { return $subscriber instanceof BeforeAnalysis; @@ -26,6 +27,7 @@ public function accepts($subscriber): bool /** * @psalm-return class-string */ + #[\Override] public function getEventClassname(): string { return BeforeAnalysisEvent::class; @@ -36,6 +38,7 @@ public function getEventClassname(): string * @psalm-param BeforeAnalysis $subscriber * @psalm-return Closure(BeforeAnalysisEvent): void */ + #[\Override] public function buildEventHandler($subscriber): Closure { return static function (BeforeAnalysisEvent $event) use ($subscriber): void { diff --git a/src/Event/Event/AfterAnalysisEvent.php b/src/Event/Event/AfterAnalysisEvent.php index 1b6b2c4..33979ac 100644 --- a/src/Event/Event/AfterAnalysisEvent.php +++ b/src/Event/Event/AfterAnalysisEvent.php @@ -27,6 +27,7 @@ public function __construct(ResultReporter $resultReporter) /** * Returns the total number of files analysed. */ + #[\Override] public function getNumberOfFiles(): int { return $this->resultReporter->getNumberOfFiles(); @@ -35,6 +36,7 @@ public function getNumberOfFiles(): int /** * Returns the max number of changes among the analysed files. */ + #[\Override] public function getMaxNumberOfChanges(): int { return $this->resultReporter->getMaxCommits(); @@ -43,6 +45,7 @@ public function getMaxNumberOfChanges(): int /** * Returns the max cyclomatic complexity among the analysed files. */ + #[\Override] public function getMaxCyclomaticComplexity(): int { return $this->resultReporter->getMaxComplexity(); @@ -51,6 +54,7 @@ public function getMaxCyclomaticComplexity(): int /** * Returns the highest score among the analysed files. */ + #[\Override] public function getMaxScore(): ?float { return $this->resultReporter->getMaxScore(); diff --git a/src/Event/Event/AfterFileAnalysisEvent.php b/src/Event/Event/AfterFileAnalysisEvent.php index a92fc7d..7157e22 100644 --- a/src/Event/Event/AfterFileAnalysisEvent.php +++ b/src/Event/Event/AfterFileAnalysisEvent.php @@ -35,6 +35,7 @@ public function getResult(): ResultInterface /** * Returns the absolute path of the file. */ + #[\Override] public function getFilePath(): string { return $this->result->getFile()->getFullPath(); @@ -43,6 +44,7 @@ public function getFilePath(): string /** * Returns the number of times the file has been changed. */ + #[\Override] public function getNumberOfChanges(): int { return $this->result->getCommits(); @@ -51,6 +53,7 @@ public function getNumberOfChanges(): int /** * Returns the cyclomatic complexity of the file. */ + #[\Override] public function getCyclomaticComplexity(): int { return $this->result->getComplexity(); diff --git a/src/Event/Subscriber/AfterAnalysisHookDecorator.php b/src/Event/Subscriber/AfterAnalysisHookDecorator.php index f5b5822..134c7b8 100644 --- a/src/Event/Subscriber/AfterAnalysisHookDecorator.php +++ b/src/Event/Subscriber/AfterAnalysisHookDecorator.php @@ -30,6 +30,7 @@ public function __construct(string $hook) /** * @param AfterAnalysisEvent $event The event triggered when the analysis is done. */ + #[\Override] public function onAfterAnalysis(AfterAnalysisEvent $event): void { $this->hook::afterAnalysis($event); diff --git a/src/Event/Subscriber/AfterFileAnalysisHookDecorator.php b/src/Event/Subscriber/AfterFileAnalysisHookDecorator.php index 83acd71..6f628c1 100644 --- a/src/Event/Subscriber/AfterFileAnalysisHookDecorator.php +++ b/src/Event/Subscriber/AfterFileAnalysisHookDecorator.php @@ -30,6 +30,7 @@ public function __construct(string $hook) /** * @param AfterFileAnalysisEvent $event The event triggered when the analysis of a file is done. */ + #[\Override] public function onAfterFileAnalysis(AfterFileAnalysisEvent $event): void { $this->hook::afterFileAnalysis($event); diff --git a/src/Event/Subscriber/BeforeAnalysisHookDecorator.php b/src/Event/Subscriber/BeforeAnalysisHookDecorator.php index 9a27b93..893697d 100644 --- a/src/Event/Subscriber/BeforeAnalysisHookDecorator.php +++ b/src/Event/Subscriber/BeforeAnalysisHookDecorator.php @@ -30,6 +30,7 @@ public function __construct(string $hook) /** * @param BeforeAnalysisEvent $event The event triggered when the analysis starts. */ + #[\Override] public function onBeforeAnalysis(BeforeAnalysisEvent $event): void { $this->hook::beforeAnalysis($event); diff --git a/src/Process/CacheProcessFactory.php b/src/Process/CacheProcessFactory.php index 58a07f7..ea8683e 100644 --- a/src/Process/CacheProcessFactory.php +++ b/src/Process/CacheProcessFactory.php @@ -57,6 +57,7 @@ public function __construct(string $cachePath, ProcessFactory $processFactory) * @param File $file File that the processes will execute on. * @return iterable The list of processes to execute. */ + #[\Override] public function createProcesses(File $file): iterable { if (!$this->isCached($file)) { @@ -75,6 +76,7 @@ public function createProcesses(File $file): iterable /** * @param AfterAnalysisEvent $event The event triggered when the analysis is done. */ + #[\Override] public function onAfterAnalysis(AfterAnalysisEvent $event): void { $this->writeCache(); @@ -83,6 +85,7 @@ public function onAfterAnalysis(AfterAnalysisEvent $event): void /** * @param AfterFileAnalysisEvent $event The event triggered when the analysis of a file is done. */ + #[\Override] public function onAfterFileAnalysis(AfterFileAnalysisEvent $event): void { $this->addToCache( diff --git a/src/Process/ChangesCount/FossilChangesCountProcess.php b/src/Process/ChangesCount/FossilChangesCountProcess.php index 40ad820..9fd4a86 100644 --- a/src/Process/ChangesCount/FossilChangesCountProcess.php +++ b/src/Process/ChangesCount/FossilChangesCountProcess.php @@ -34,6 +34,7 @@ public function __construct(File $file, string $dateSince) /** * Returns the number of changes for a file. */ + #[\Override] public function countChanges(): int { $count = 0; diff --git a/src/Process/ChangesCount/GitChangesCountProcess.php b/src/Process/ChangesCount/GitChangesCountProcess.php index 098223a..86cef9c 100644 --- a/src/Process/ChangesCount/GitChangesCountProcess.php +++ b/src/Process/ChangesCount/GitChangesCountProcess.php @@ -34,6 +34,7 @@ public function __construct(File $file, string $commitsSince) /** * Returns the number of changes for a file. */ + #[\Override] public function countChanges(): int { return (int) $this->getOutput(); diff --git a/src/Process/ChangesCount/MercurialChangesCountProcess.php b/src/Process/ChangesCount/MercurialChangesCountProcess.php index c7ab289..5ad32da 100644 --- a/src/Process/ChangesCount/MercurialChangesCountProcess.php +++ b/src/Process/ChangesCount/MercurialChangesCountProcess.php @@ -34,6 +34,7 @@ public function __construct(File $file, string $dateSince) /** * Returns the number of changes for a file. */ + #[\Override] public function countChanges(): int { return \substr_count($this->getOutput(), "\n"); diff --git a/src/Process/ChangesCount/NoVcsChangesCountProcess.php b/src/Process/ChangesCount/NoVcsChangesCountProcess.php index fc42a15..802ade4 100644 --- a/src/Process/ChangesCount/NoVcsChangesCountProcess.php +++ b/src/Process/ChangesCount/NoVcsChangesCountProcess.php @@ -32,6 +32,7 @@ public function __construct(File $file) /** * Returns the number of changes for a file. */ + #[\Override] public function countChanges(): int { return 1; @@ -40,6 +41,7 @@ public function countChanges(): int /** * Start the process. */ + #[\Override] public function start(): void { // nothing to do @@ -48,6 +50,7 @@ public function start(): void /** * Determines if the process was successful. */ + #[\Override] public function isSuccessful(): bool { return true; @@ -56,6 +59,7 @@ public function isSuccessful(): bool /** * Gets the file the process is being executed on. */ + #[\Override] public function getFile(): File { return $this->file; diff --git a/src/Process/ChangesCount/SubversionChangesCountProcess.php b/src/Process/ChangesCount/SubversionChangesCountProcess.php index d5dcb97..a76bedd 100644 --- a/src/Process/ChangesCount/SubversionChangesCountProcess.php +++ b/src/Process/ChangesCount/SubversionChangesCountProcess.php @@ -30,6 +30,7 @@ public function __construct(File $file, string $dateRange) /** * Returns the number of changes for a file. */ + #[\Override] public function countChanges(): int { return (int) \floor(\substr_count($this->getOutput(), "\n") / 2); diff --git a/src/Process/ChurnProcess.php b/src/Process/ChurnProcess.php index e947ddf..68fee03 100644 --- a/src/Process/ChurnProcess.php +++ b/src/Process/ChurnProcess.php @@ -42,6 +42,7 @@ public function __construct(File $file, Process $process) /** * Start the process. */ + #[\Override] public function start(): void { $this->process->start(); @@ -52,6 +53,7 @@ public function start(): void * * @throws ProcessFailedException If the process failed. */ + #[\Override] public function isSuccessful(): bool { $exitCode = $this->process->getExitCode(); @@ -66,6 +68,7 @@ public function isSuccessful(): bool /** * Gets the file the process is being executed on. */ + #[\Override] public function getFile(): File { return $this->file; diff --git a/src/Process/ConcreteProcessFactory.php b/src/Process/ConcreteProcessFactory.php index 1e04615..a7f0677 100644 --- a/src/Process/ConcreteProcessFactory.php +++ b/src/Process/ConcreteProcessFactory.php @@ -45,6 +45,7 @@ public function __construct(string $vcs, string $commitsSince) * @param File $file File that the processes will execute on. * @return iterable The list of processes to execute. */ + #[\Override] public function createProcesses(File $file): iterable { $processes = []; diff --git a/src/Process/CyclomaticComplexityProcess.php b/src/Process/CyclomaticComplexityProcess.php index 78c41f6..6e4cae8 100644 --- a/src/Process/CyclomaticComplexityProcess.php +++ b/src/Process/CyclomaticComplexityProcess.php @@ -12,6 +12,7 @@ final class CyclomaticComplexityProcess extends ChurnProcess implements Cyclomat /** * Returns the cyclomatic complexity of a file. */ + #[\Override] public function getCyclomaticComplexity(): int { return (int) $this->getOutput(); diff --git a/src/Process/Handler/ParallelProcessHandler.php b/src/Process/Handler/ParallelProcessHandler.php index 5b67841..231e8f3 100644 --- a/src/Process/Handler/ParallelProcessHandler.php +++ b/src/Process/Handler/ParallelProcessHandler.php @@ -54,6 +54,7 @@ public function __construct(int $numberOfParallelJobs, Broker $broker) * @param ProcessFactory $processFactory Process Factory. * @psalm-param Generator<\Churn\File\File> $filesFinder */ + #[\Override] public function process(Generator $filesFinder, ProcessFactory $processFactory): void { $pool = []; diff --git a/src/Process/Handler/SequentialProcessHandler.php b/src/Process/Handler/SequentialProcessHandler.php index e61274e..4976a24 100644 --- a/src/Process/Handler/SequentialProcessHandler.php +++ b/src/Process/Handler/SequentialProcessHandler.php @@ -36,6 +36,7 @@ public function __construct(Broker $broker) * @param ProcessFactory $processFactory Process Factory. * @psalm-param Generator<\Churn\File\File> $filesFinder */ + #[\Override] public function process(Generator $filesFinder, ProcessFactory $processFactory): void { foreach ($filesFinder as $file) { diff --git a/src/Process/PredefinedProcess.php b/src/Process/PredefinedProcess.php index 515b110..872f2a2 100644 --- a/src/Process/PredefinedProcess.php +++ b/src/Process/PredefinedProcess.php @@ -41,6 +41,7 @@ public function __construct(File $file, int $countChanges, int $cyclomaticComple /** * Start the process. */ + #[\Override] public function start(): void { // nothing to do @@ -49,6 +50,7 @@ public function start(): void /** * Determines if the process was successful. */ + #[\Override] public function isSuccessful(): bool { return true; @@ -57,6 +59,7 @@ public function isSuccessful(): bool /** * Gets the file the process is being executed on. */ + #[\Override] public function getFile(): File { return $this->file; @@ -65,6 +68,7 @@ public function getFile(): File /** * Returns the number of changes for a file. */ + #[\Override] public function countChanges(): int { return $this->countChanges; @@ -73,6 +77,7 @@ public function countChanges(): int /** * Returns the cyclomatic complexity of a file. */ + #[\Override] public function getCyclomaticComplexity(): int { return $this->cyclomaticComplexity; diff --git a/src/Result/Render/ConsoleResultsRenderer.php b/src/Result/Render/ConsoleResultsRenderer.php index 5e6f2dc..af0b04d 100644 --- a/src/Result/Render/ConsoleResultsRenderer.php +++ b/src/Result/Render/ConsoleResultsRenderer.php @@ -18,6 +18,7 @@ final class ConsoleResultsRenderer implements ResultsRendererInterface * @param OutputInterface $output Output Interface. * @param array> $results The results. */ + #[\Override] public function render(OutputInterface $output, array $results): void { $table = new Table($output); diff --git a/src/Result/Render/CsvResultsRenderer.php b/src/Result/Render/CsvResultsRenderer.php index 4629e8c..3163376 100644 --- a/src/Result/Render/CsvResultsRenderer.php +++ b/src/Result/Render/CsvResultsRenderer.php @@ -17,6 +17,7 @@ final class CsvResultsRenderer implements ResultsRendererInterface * @param OutputInterface $output Output Interface. * @param array> $results The results. */ + #[\Override] public function render(OutputInterface $output, array $results): void { $output->writeln($this->getHeader()); diff --git a/src/Result/Render/JsonResultsRenderer.php b/src/Result/Render/JsonResultsRenderer.php index d40c8f3..cb21f34 100644 --- a/src/Result/Render/JsonResultsRenderer.php +++ b/src/Result/Render/JsonResultsRenderer.php @@ -17,6 +17,7 @@ final class JsonResultsRenderer implements ResultsRendererInterface * @param OutputInterface $output Output Interface. * @param array> $results The results. */ + #[\Override] public function render(OutputInterface $output, array $results): void { $data = []; diff --git a/src/Result/Render/MarkdownResultsRenderer.php b/src/Result/Render/MarkdownResultsRenderer.php index a61158a..ee4a982 100644 --- a/src/Result/Render/MarkdownResultsRenderer.php +++ b/src/Result/Render/MarkdownResultsRenderer.php @@ -17,6 +17,7 @@ final class MarkdownResultsRenderer implements ResultsRendererInterface * @param OutputInterface $output Output Interface. * @param array> $results The results. */ + #[\Override] public function render(OutputInterface $output, array $results): void { $output->writeln('| File | Times Changed | Complexity | Score |'); diff --git a/src/Result/Result.php b/src/Result/Result.php index 78abb38..5698a67 100644 --- a/src/Result/Result.php +++ b/src/Result/Result.php @@ -46,6 +46,7 @@ public function __construct(File $file) /** * Return the file. */ + #[\Override] public function getFile(): File { return $this->file; @@ -72,6 +73,7 @@ public function setCommits(int $commits): self /** * Get the number of changes. */ + #[\Override] public function getCommits(): int { return $this->commits; @@ -90,6 +92,7 @@ public function setComplexity(int $complexity): self /** * Get the file complexity. */ + #[\Override] public function getComplexity(): int { return $this->complexity; @@ -98,6 +101,7 @@ public function getComplexity(): int /** * Get the file priority. */ + #[\Override] public function getPriority(): int { return $this->commits * $this->complexity; @@ -110,6 +114,7 @@ public function getPriority(): int * @param integer $maxComplexity The maximum complexity out of any file scanned. * @codingStandardsIgnoreStart */ + #[\Override] public function getScore(int $maxCommits, int $maxComplexity): float { Assert::greaterThan($maxComplexity, 0); diff --git a/src/Result/ResultAccumulator.php b/src/Result/ResultAccumulator.php index af7eca2..d8828de 100644 --- a/src/Result/ResultAccumulator.php +++ b/src/Result/ResultAccumulator.php @@ -54,6 +54,7 @@ public function __construct(int $maxSize, ?float $minScore) /** * @param AfterFileAnalysisEvent $event The event triggered when the analysis of a file is done. */ + #[\Override] public function onAfterFileAnalysis(AfterFileAnalysisEvent $event): void { if (!($event instanceof AfterFileAnalysisEventWithResult)) { @@ -88,6 +89,7 @@ public function add(ResultInterface $result): void /** * Returns the maximum number of changes for a file. */ + #[\Override] public function getMaxCommits(): int { return $this->maxCommits; @@ -96,6 +98,7 @@ public function getMaxCommits(): int /** * Returns the maximum complexity for a file. */ + #[\Override] public function getMaxComplexity(): int { return $this->maxComplexity; @@ -104,6 +107,7 @@ public function getMaxComplexity(): int /** * Returns the number of files processed. */ + #[\Override] public function getNumberOfFiles(): int { return $this->numberOfFiles; @@ -112,6 +116,7 @@ public function getNumberOfFiles(): int /** * Returns the highest score. */ + #[\Override] public function getMaxScore(): ?float { $result = $this->highestScores->toArray()[0] ?? null; diff --git a/tests/EndToEnd/FossilTest.php b/tests/EndToEnd/FossilTest.php index 80c7bf8..54eef6d 100644 --- a/tests/EndToEnd/FossilTest.php +++ b/tests/EndToEnd/FossilTest.php @@ -17,6 +17,7 @@ final class FossilTest extends BaseTestCase private $commandTester; /** @return void */ + #[\Override] protected function setUp() { parent::setUp(); @@ -28,6 +29,7 @@ protected function setUp() } /** @return void */ + #[\Override] protected function tearDown() { parent::tearDown(); diff --git a/tests/EndToEnd/MercurialTest.php b/tests/EndToEnd/MercurialTest.php index 8cfd200..9c871b3 100644 --- a/tests/EndToEnd/MercurialTest.php +++ b/tests/EndToEnd/MercurialTest.php @@ -17,6 +17,7 @@ final class MercurialTest extends BaseTestCase private $commandTester; /** @return void */ + #[\Override] protected function setUp() { parent::setUp(); @@ -28,6 +29,7 @@ protected function setUp() } /** @return void */ + #[\Override] protected function tearDown() { parent::tearDown(); diff --git a/tests/EndToEnd/SubversionTest.php b/tests/EndToEnd/SubversionTest.php index 746b610..490e6b0 100644 --- a/tests/EndToEnd/SubversionTest.php +++ b/tests/EndToEnd/SubversionTest.php @@ -17,6 +17,7 @@ final class SubversionTest extends BaseTestCase private $commandTester; /** @return void */ + #[\Override] protected function setUp() { parent::setUp(); @@ -28,6 +29,7 @@ protected function setUp() } /** @return void */ + #[\Override] protected function tearDown() { parent::tearDown(); diff --git a/tests/Integration/Command/AssessComplexityCommandTest.php b/tests/Integration/Command/AssessComplexityCommandTest.php index 4839341..c33506e 100644 --- a/tests/Integration/Command/AssessComplexityCommandTest.php +++ b/tests/Integration/Command/AssessComplexityCommandTest.php @@ -17,6 +17,7 @@ final class AssessComplexityCommandTest extends BaseTestCase private $commandTester; /** @return void */ + #[\Override] protected function setUp() { parent::setUp(); @@ -28,6 +29,7 @@ protected function setUp() } /** @return void */ + #[\Override] protected function tearDown() { parent::tearDown(); diff --git a/tests/Integration/Command/Assets/PrintHook.php b/tests/Integration/Command/Assets/PrintHook.php index e11048b..e58a550 100644 --- a/tests/Integration/Command/Assets/PrintHook.php +++ b/tests/Integration/Command/Assets/PrintHook.php @@ -15,6 +15,7 @@ class PrintHook implements AfterAnalysisHook, BeforeAnalysisHook /** * @param AfterAnalysis $event The event triggered when the analysis is done. */ + #[\Override] public static function afterAnalysis(AfterAnalysis $event): void { echo "DONE"; @@ -23,6 +24,7 @@ public static function afterAnalysis(AfterAnalysis $event): void /** * @param BeforeAnalysis $event The event triggered when the analysis starts. */ + #[\Override] public static function beforeAnalysis(BeforeAnalysis $event): void { echo "Churn: "; diff --git a/tests/Integration/Command/Assets/TestHook.php b/tests/Integration/Command/Assets/TestHook.php index ba4efaa..033499b 100644 --- a/tests/Integration/Command/Assets/TestHook.php +++ b/tests/Integration/Command/Assets/TestHook.php @@ -31,6 +31,7 @@ public static function reset(): void /** * @param AfterAnalysis $event The event triggered when the analysis is done. */ + #[\Override] public static function afterAnalysis(AfterAnalysis $event): void { self::$nbAfterAnalysisEvent++; @@ -39,6 +40,7 @@ public static function afterAnalysis(AfterAnalysis $event): void /** * @param AfterFileAnalysis $event The event triggered when the analysis of a file is done. */ + #[\Override] public static function afterFileAnalysis(AfterFileAnalysis $event): void { self::$nbAfterFileAnalysisEvent++; @@ -47,6 +49,7 @@ public static function afterFileAnalysis(AfterFileAnalysis $event): void /** * @param BeforeAnalysis $event The event triggered when the analysis starts. */ + #[\Override] public static function beforeAnalysis(BeforeAnalysis $event): void { self::$nbBeforeAnalysisEvent++; diff --git a/tests/Integration/Command/RunCommandTest.php b/tests/Integration/Command/RunCommandTest.php index 1ba0043..3ae94a5 100644 --- a/tests/Integration/Command/RunCommandTest.php +++ b/tests/Integration/Command/RunCommandTest.php @@ -29,6 +29,7 @@ final class RunCommandTest extends BaseTestCase private $tmpFile; /** @return void */ + #[\Override] protected function setUp() { parent::setUp(); @@ -40,6 +41,7 @@ protected function setUp() } /** @return void */ + #[\Override] protected function tearDown() { parent::tearDown(); diff --git a/tests/Integration/File/FileFinderTest.php b/tests/Integration/File/FileFinderTest.php index 069f8c2..413491a 100644 --- a/tests/Integration/File/FileFinderTest.php +++ b/tests/Integration/File/FileFinderTest.php @@ -16,6 +16,7 @@ final class FileFinderTest extends BaseTestCase private $fileFinder; /** @return void */ + #[\Override] public function setUp() { parent::setUp(); diff --git a/tests/Integration/ManifestTest.php b/tests/Integration/ManifestTest.php index 0fb17e5..45a4908 100644 --- a/tests/Integration/ManifestTest.php +++ b/tests/Integration/ManifestTest.php @@ -17,6 +17,7 @@ final class ManifestTest extends BaseTestCase private $manifest; /** @return void */ + #[\Override] public function setUp() { parent::setUp(); diff --git a/tests/Unit/Configuration/Validator/CachePathTest.php b/tests/Unit/Configuration/Validator/CachePathTest.php index b1b94b8..ab729df 100644 --- a/tests/Unit/Configuration/Validator/CachePathTest.php +++ b/tests/Unit/Configuration/Validator/CachePathTest.php @@ -12,6 +12,7 @@ final class CachePathTest extends ValidatorBaseTestCase { /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return new CachePath(); @@ -21,24 +22,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getCachePath(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return null; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'CachePath' => ['/tmp/.churn.cache']; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'CachePath / int' => [123, 'Cache path should be a string']; diff --git a/tests/Unit/Configuration/Validator/CommitsSinceTest.php b/tests/Unit/Configuration/Validator/CommitsSinceTest.php index ee263fe..1afcc0a 100644 --- a/tests/Unit/Configuration/Validator/CommitsSinceTest.php +++ b/tests/Unit/Configuration/Validator/CommitsSinceTest.php @@ -16,6 +16,7 @@ final class CommitsSinceTest extends ValidatorBaseTestCase private $validator; /** @return void */ + #[\Override] public function setUp() { parent::setUp(); @@ -24,6 +25,7 @@ public function setUp() } /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return $this->validator; @@ -33,24 +35,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getCommitsSince(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return '10 years ago'; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'CommitsSince' => ['4 years ago']; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'CommitsSince / int' => [123, 'Commits since should be a string']; diff --git a/tests/Unit/Configuration/Validator/DirectoriesToScanTest.php b/tests/Unit/Configuration/Validator/DirectoriesToScanTest.php index 0f7d40b..e45c7f0 100644 --- a/tests/Unit/Configuration/Validator/DirectoriesToScanTest.php +++ b/tests/Unit/Configuration/Validator/DirectoriesToScanTest.php @@ -11,6 +11,7 @@ final class DirectoriesToScanTest extends ValidatorBaseTestCase { /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return new DirectoriesToScan(); @@ -20,24 +21,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getDirectoriesToScan(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return []; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'DirectoriesToScan' => [['src', 'tests']]; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'DirectoriesToScan / string' => ['foo', 'Directories to scan should be an array of strings']; diff --git a/tests/Unit/Configuration/Validator/FileExtensionsTest.php b/tests/Unit/Configuration/Validator/FileExtensionsTest.php index 5b32c74..3aab3a5 100644 --- a/tests/Unit/Configuration/Validator/FileExtensionsTest.php +++ b/tests/Unit/Configuration/Validator/FileExtensionsTest.php @@ -11,6 +11,7 @@ final class FileExtensionsTest extends ValidatorBaseTestCase { /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return new FileExtensions(); @@ -20,24 +21,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getFileExtensions(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return ['php']; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'FileExtensions' => [['php', 'inc']]; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'FileExtensions / string' => ['foo', 'File extensions should be an array of strings']; diff --git a/tests/Unit/Configuration/Validator/FilesToIgnoreTest.php b/tests/Unit/Configuration/Validator/FilesToIgnoreTest.php index bedb4b2..7af0f08 100644 --- a/tests/Unit/Configuration/Validator/FilesToIgnoreTest.php +++ b/tests/Unit/Configuration/Validator/FilesToIgnoreTest.php @@ -11,6 +11,7 @@ final class FilesToIgnoreTest extends ValidatorBaseTestCase { /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return new FilesToIgnore(); @@ -20,24 +21,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getFilesToIgnore(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return []; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'FilesToIgnore' => [['foo.php', 'bar.php', 'baz.php']]; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'FilesToIgnore / string' => ['foo', 'Files to ignore should be an array of strings']; diff --git a/tests/Unit/Configuration/Validator/FilesToShowTest.php b/tests/Unit/Configuration/Validator/FilesToShowTest.php index 196b7a0..2bc9631 100644 --- a/tests/Unit/Configuration/Validator/FilesToShowTest.php +++ b/tests/Unit/Configuration/Validator/FilesToShowTest.php @@ -11,6 +11,7 @@ final class FilesToShowTest extends ValidatorBaseTestCase { /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return new FilesToShow(); @@ -20,24 +21,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getFilesToShow(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return 10; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'FilesToShow' => [13]; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'FilesToShow / string' => ['foo', 'Files to show should be an integer']; diff --git a/tests/Unit/Configuration/Validator/HooksTest.php b/tests/Unit/Configuration/Validator/HooksTest.php index 0f18374..80e8ba4 100644 --- a/tests/Unit/Configuration/Validator/HooksTest.php +++ b/tests/Unit/Configuration/Validator/HooksTest.php @@ -11,6 +11,7 @@ final class HooksTest extends ValidatorBaseTestCase { /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return new Hooks(); @@ -20,24 +21,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getHooks(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return []; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'Hook' => [['Hook1', 'Hook2']]; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'Hooks / string' => ['foo', 'Hooks should be an array of strings']; diff --git a/tests/Unit/Configuration/Validator/MaxScoreThresholdTest.php b/tests/Unit/Configuration/Validator/MaxScoreThresholdTest.php index 4413969..68f766c 100644 --- a/tests/Unit/Configuration/Validator/MaxScoreThresholdTest.php +++ b/tests/Unit/Configuration/Validator/MaxScoreThresholdTest.php @@ -12,6 +12,7 @@ final class MaxScoreThresholdTest extends ValidatorBaseTestCase { /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return new MaxScoreThreshold(); @@ -21,24 +22,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getMaxScoreThreshold(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return null; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'MaxScoreThreshold' => [9.5]; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'MaxScoreThreshold / string' => ['foo', 'Maximum score threshold should be a number']; diff --git a/tests/Unit/Configuration/Validator/MinScoreToShowTest.php b/tests/Unit/Configuration/Validator/MinScoreToShowTest.php index 90d8fe4..e3dd3f3 100644 --- a/tests/Unit/Configuration/Validator/MinScoreToShowTest.php +++ b/tests/Unit/Configuration/Validator/MinScoreToShowTest.php @@ -12,6 +12,7 @@ final class MinScoreToShowTest extends ValidatorBaseTestCase { /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return new MinScoreToShow(); @@ -21,24 +22,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getMinScoreToShow(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return 0.1; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'MinScoreToShow' => [5.0]; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'MinScoreToShow / string' => ['foo', 'Minimum score to show should be a number']; diff --git a/tests/Unit/Configuration/Validator/ParallelJobsTest.php b/tests/Unit/Configuration/Validator/ParallelJobsTest.php index 8d63ec4..fafe9ec 100644 --- a/tests/Unit/Configuration/Validator/ParallelJobsTest.php +++ b/tests/Unit/Configuration/Validator/ParallelJobsTest.php @@ -11,6 +11,7 @@ final class ParallelJobsTest extends ValidatorBaseTestCase { /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return new ParallelJobs(); @@ -20,24 +21,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getParallelJobs(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return 10; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'ParallelJobs' => [7]; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'ParallelJobs / string' => ['foo', 'Amount of parallel jobs should be an integer']; diff --git a/tests/Unit/Configuration/Validator/ValidatorBaseTestCase.php b/tests/Unit/Configuration/Validator/ValidatorBaseTestCase.php index f07e8bb..fb93309 100644 --- a/tests/Unit/Configuration/Validator/ValidatorBaseTestCase.php +++ b/tests/Unit/Configuration/Validator/ValidatorBaseTestCase.php @@ -44,6 +44,7 @@ abstract public static function provideValidValues(): iterable; abstract public static function provideInvalidValues(): iterable; /** @return void */ + #[\Override] public function setUp() { parent::setUp(); diff --git a/tests/Unit/Configuration/Validator/VcsTest.php b/tests/Unit/Configuration/Validator/VcsTest.php index 198a9c7..157edc7 100644 --- a/tests/Unit/Configuration/Validator/VcsTest.php +++ b/tests/Unit/Configuration/Validator/VcsTest.php @@ -11,6 +11,7 @@ final class VcsTest extends ValidatorBaseTestCase { /** {@inheritDoc} */ + #[\Override] protected function getValidator(): Validator { return new Vcs(); @@ -20,24 +21,28 @@ protected function getValidator(): Validator * @param Config $config The configuration object. * @return mixed */ + #[\Override] protected function getValue(Config $config) { return $config->getVCS(); } /** {@inheritDoc} */ + #[\Override] protected function getDefaultValue() { return 'git'; } /** {@inheritDoc} */ + #[\Override] public static function provideValidValues(): iterable { yield 'Vcs' => ['none']; } /** {@inheritDoc} */ + #[\Override] public static function provideInvalidValues(): iterable { yield 'Vcs / int' => [123, 'VCS should be a string']; diff --git a/tests/Unit/File/FileFinderTest.php b/tests/Unit/File/FileFinderTest.php index a3f9f75..596b543 100644 --- a/tests/Unit/File/FileFinderTest.php +++ b/tests/Unit/File/FileFinderTest.php @@ -17,6 +17,7 @@ final class FileFinderTest extends BaseTestCase protected $fileFinder; /** @return void */ + #[\Override] public function setUp() { parent::setUp(); diff --git a/tests/Unit/File/FileHelperTest.php b/tests/Unit/File/FileHelperTest.php index 09f3c6f..53c782c 100644 --- a/tests/Unit/File/FileHelperTest.php +++ b/tests/Unit/File/FileHelperTest.php @@ -17,6 +17,7 @@ final class FileHelperTest extends BaseTestCase private static $filesToDelete = []; /** @return void */ + #[\Override] protected function tearDown() { parent::tearDown(); diff --git a/tests/Unit/File/FileTest.php b/tests/Unit/File/FileTest.php index d8e2a2b..2a6d863 100644 --- a/tests/Unit/File/FileTest.php +++ b/tests/Unit/File/FileTest.php @@ -15,6 +15,7 @@ final class FileTest extends BaseTestCase private $file; /** @return void */ + #[\Override] public function setUp() { parent::setUp(); diff --git a/tests/Unit/Process/ChangesCount/NoVcsChangesCountProcessTest.php b/tests/Unit/Process/ChangesCount/NoVcsChangesCountProcessTest.php index 29bb535..5256eec 100644 --- a/tests/Unit/Process/ChangesCount/NoVcsChangesCountProcessTest.php +++ b/tests/Unit/Process/ChangesCount/NoVcsChangesCountProcessTest.php @@ -16,6 +16,7 @@ final class NoVcsChangesCountProcessTest extends BaseTestCase private $process; /** @return void */ + #[\Override] protected function setUp() { parent::setUp(); diff --git a/tests/Unit/Process/ConcreteProcessFactoryTest.php b/tests/Unit/Process/ConcreteProcessFactoryTest.php index 3647502..2c224ac 100644 --- a/tests/Unit/Process/ConcreteProcessFactoryTest.php +++ b/tests/Unit/Process/ConcreteProcessFactoryTest.php @@ -21,6 +21,7 @@ final class ConcreteProcessFactoryTest extends BaseTestCase private $processFactory; /** @return void */ + #[\Override] public function setUp() { parent::setUp(); diff --git a/tests/Unit/Result/ResultTest.php b/tests/Unit/Result/ResultTest.php index 6664bcd..1c0d4d4 100644 --- a/tests/Unit/Result/ResultTest.php +++ b/tests/Unit/Result/ResultTest.php @@ -19,6 +19,7 @@ final class ResultTest extends BaseTestCase protected $result; /** @return void */ + #[\Override] public function setUp() { parent::setUp(); diff --git a/tests/Unit/Result/ResultsRendererFactoryTest.php b/tests/Unit/Result/ResultsRendererFactoryTest.php index 11163e2..1af30ac 100644 --- a/tests/Unit/Result/ResultsRendererFactoryTest.php +++ b/tests/Unit/Result/ResultsRendererFactoryTest.php @@ -20,6 +20,7 @@ final class ResultsRendererFactoryTest extends BaseTestCase private $factory; /** @return void */ + #[\Override] public function setUp() { parent::setUp(); From 6d552121bcefe005ea90deffa3878d00a05fa150 Mon Sep 17 00:00:00 2001 From: Fabien Villepinte Date: Thu, 12 Jun 2025 10:48:45 +0200 Subject: [PATCH 5/9] ci: Update Psalm configuration to ignore assets --- psalm.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/psalm.xml b/psalm.xml index 92ca14c..d7227a8 100644 --- a/psalm.xml +++ b/psalm.xml @@ -17,6 +17,7 @@ + From 1747af27e7ea74d9064f4856c1709ec54cb164ef Mon Sep 17 00:00:00 2001 From: Fabien Villepinte Date: Thu, 12 Jun 2025 11:01:06 +0200 Subject: [PATCH 6/9] refactor: Avoid mixing ints and floats --- src/Result/Render/CsvResultsRenderer.php | 2 +- src/Result/Result.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Result/Render/CsvResultsRenderer.php b/src/Result/Render/CsvResultsRenderer.php index 3163376..828c598 100644 --- a/src/Result/Render/CsvResultsRenderer.php +++ b/src/Result/Render/CsvResultsRenderer.php @@ -23,7 +23,7 @@ public function render(OutputInterface $output, array $results): void $output->writeln($this->getHeader()); foreach ($results as $result) { - $output->writeln(\implode(';', ['"' . $result[0] . '"', $result[1], $result[2], $result[3]])); + $output->writeln(\implode(';', ['"' . strval($result[0]) . '"', $result[1], $result[2], $result[3]])); } } diff --git a/src/Result/Result.php b/src/Result/Result.php index 5698a67..826013c 100644 --- a/src/Result/Result.php +++ b/src/Result/Result.php @@ -131,16 +131,16 @@ public function getScore(int $maxCommits, int $maxComplexity): float * Normalize these values over time, we first divide by the maximum * values, to always end up with distances between 0 and 1. */ - $normalizedHorizontalDistance = $horizontalDistance / $maxCommits; - $normalizedVerticalDistance = $verticalDistance / $maxComplexity; + $normalizedHorizontalDistance = floatval($horizontalDistance / $maxCommits); + $normalizedVerticalDistance = floatval($verticalDistance / $maxComplexity); /* * Calculate the distance of this class from the "top right" corner, * using the simple formula A^2 + B^2 = C^2; or: C = sqrt(A^2 + B^2)). */ $distanceFromTopRightCorner = \sqrt( - $normalizedHorizontalDistance ** 2 - + $normalizedVerticalDistance ** 2 + $normalizedHorizontalDistance ** 2.0 + + $normalizedVerticalDistance ** 2.0 ); /* @@ -148,7 +148,7 @@ public function getScore(int $maxCommits, int $maxComplexity): float * so in order to end up with a high score, we invert the value by * subtracting it from 1. */ - return \round(1 - $distanceFromTopRightCorner, 3); + return \round(1.0 - $distanceFromTopRightCorner, 3); // @codingStandardsIgnoreEnd } } From bcd274f179a6eeb025f4d1706aea21a00238e70f Mon Sep 17 00:00:00 2001 From: Fabien Villepinte Date: Thu, 12 Jun 2025 11:02:18 +0200 Subject: [PATCH 7/9] Upgrade actions/download-artifact to v4 --- .github/workflows/continuous-integration.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index c991e61..9c2f683 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -146,7 +146,7 @@ jobs: run: "vendor/bin/simple-phpunit --colors=always --testdox --testsuite churn-tests --coverage-clover=coverage.xml" - name: "Download other code coverage reports" - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: pattern: coverage-* merge-multiple: true @@ -301,7 +301,7 @@ jobs: tools: none - name: Download churn.phar - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: churn.phar @@ -343,7 +343,7 @@ jobs: tools: none - name: Download churn.phar - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: churn.phar From 02bcefe244533008a78f5a360b9cf0a3f729a2b5 Mon Sep 17 00:00:00 2001 From: Fabien Villepinte Date: Thu, 12 Jun 2025 11:05:47 +0200 Subject: [PATCH 8/9] refactor: Functions should be referenced via a fully qualified name --- src/Result/Render/CsvResultsRenderer.php | 2 +- src/Result/Result.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Result/Render/CsvResultsRenderer.php b/src/Result/Render/CsvResultsRenderer.php index 828c598..1f79e6b 100644 --- a/src/Result/Render/CsvResultsRenderer.php +++ b/src/Result/Render/CsvResultsRenderer.php @@ -23,7 +23,7 @@ public function render(OutputInterface $output, array $results): void $output->writeln($this->getHeader()); foreach ($results as $result) { - $output->writeln(\implode(';', ['"' . strval($result[0]) . '"', $result[1], $result[2], $result[3]])); + $output->writeln(\implode(';', ['"' . \strval($result[0]) . '"', $result[1], $result[2], $result[3]])); } } diff --git a/src/Result/Result.php b/src/Result/Result.php index 826013c..5c8912d 100644 --- a/src/Result/Result.php +++ b/src/Result/Result.php @@ -131,8 +131,8 @@ public function getScore(int $maxCommits, int $maxComplexity): float * Normalize these values over time, we first divide by the maximum * values, to always end up with distances between 0 and 1. */ - $normalizedHorizontalDistance = floatval($horizontalDistance / $maxCommits); - $normalizedVerticalDistance = floatval($verticalDistance / $maxComplexity); + $normalizedHorizontalDistance = \floatval($horizontalDistance / $maxCommits); + $normalizedVerticalDistance = \floatval($verticalDistance / $maxComplexity); /* * Calculate the distance of this class from the "top right" corner, From 1c14792940edac90e3a0ef43f0bb86f4427e46dd Mon Sep 17 00:00:00 2001 From: Fabien Villepinte Date: Thu, 12 Jun 2025 11:19:29 +0200 Subject: [PATCH 9/9] chore: Configure new phpcs rule --- phpcs-tests.xml | 5 +++++ phpcs.xml | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/phpcs-tests.xml b/phpcs-tests.xml index 14bef83..0d1ea2d 100644 --- a/phpcs-tests.xml +++ b/phpcs-tests.xml @@ -65,5 +65,10 @@ + + + + + diff --git a/phpcs.xml b/phpcs.xml index cdefdb7..ef7b08f 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -59,6 +59,11 @@ + + + + +