|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace SavinMikhail\CommentsDensity\Commands; |
|
6
|
|
|
|
|
7
|
|
|
use Generator; |
|
8
|
|
|
use SavinMikhail\CommentsDensity\AnalyzerFactory; |
|
|
|
|
|
|
9
|
|
|
use SavinMikhail\CommentsDensity\Reporters\ConsoleReporter; |
|
|
|
|
|
|
10
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
11
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
12
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
13
|
|
|
use SplFileInfo; |
|
14
|
|
|
|
|
15
|
|
|
class AnalyzeFilesCommand extends Command |
|
16
|
|
|
{ |
|
17
|
|
|
protected function configure(): void |
|
18
|
|
|
{ |
|
19
|
|
|
$this->setName('analyze:files') |
|
20
|
|
|
->setDescription('Analyzes the comment density in multiple PHP files.') |
|
21
|
|
|
->addArgument('files', InputArgument::IS_ARRAY, 'The PHP files to analyze') |
|
22
|
|
|
->setHelp('This command allows you to analyze the comments in multiple PHP files.'); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int |
|
26
|
|
|
{ |
|
27
|
|
|
$configDto = $this->getConfigDto(); |
|
28
|
|
|
|
|
29
|
|
|
$filePaths = $input->getArgument('files'); |
|
30
|
|
|
|
|
31
|
|
|
$files = $this->generateFiles($filePaths); |
|
32
|
|
|
|
|
33
|
|
|
$reporter = new ConsoleReporter($output); |
|
34
|
|
|
$analyzerFactory = new AnalyzerFactory(); |
|
35
|
|
|
|
|
36
|
|
|
$analyzer = $this->getAnalyzer($analyzerFactory, $configDto, $output, $reporter); |
|
37
|
|
|
|
|
38
|
|
|
return $this->analyze($analyzer, $files, $output); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
protected function generateFiles(array $filePaths): Generator |
|
42
|
|
|
{ |
|
43
|
|
|
foreach ($filePaths as $filePath) { |
|
44
|
|
|
yield new SplFileInfo($filePath); |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|
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