1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SavinMikhail\CommentsDensity\Commands; |
6
|
|
|
|
7
|
|
|
use SavinMikhail\CommentsDensity\AnalyzerFactory; |
|
|
|
|
8
|
|
|
use SavinMikhail\CommentsDensity\Reporters\ReporterFactory; |
|
|
|
|
9
|
|
|
use Symfony\Component\Console\Command\Command as SymfonyCommand; |
10
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
11
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
12
|
|
|
|
13
|
|
|
class AnalyzeCommentCommand extends Command |
14
|
|
|
{ |
15
|
|
|
protected function configure(): void |
16
|
|
|
{ |
17
|
|
|
$this->setName('analyze:comments') |
18
|
|
|
->setDescription('Analyzes the comment density in files within a directory.') |
19
|
|
|
->setHelp('This command allows you to analyze the comments in PHP files within a specified directory.'); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter) |
24
|
|
|
*/ |
25
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int |
26
|
|
|
{ |
27
|
|
|
$configDto = $this->getConfigDto(); |
28
|
|
|
|
29
|
|
|
$files = $this->getFilesFromDirectories($configDto->directories); |
30
|
|
|
$reporter = (new ReporterFactory())->createReporter($output, $configDto); |
31
|
|
|
$analyzerFactory = new AnalyzerFactory(); |
32
|
|
|
|
33
|
|
|
$analyzer = $analyzerFactory->getAnalyzer($configDto, $output); |
34
|
|
|
|
35
|
|
|
$outputDTO = $analyzer->analyze($files); |
36
|
|
|
|
37
|
|
|
$reporter->report($outputDTO); |
38
|
|
|
|
39
|
|
|
if ($outputDTO->exceedThreshold) { |
40
|
|
|
$output->writeln('<error>Comment thresholds were exceeded!</error>'); |
41
|
|
|
return SymfonyCommand::FAILURE; |
42
|
|
|
} |
43
|
|
|
$output->writeln('<info>Comment thresholds are passed!</info>'); |
44
|
|
|
return SymfonyCommand::SUCCESS; |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths