|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace SavinMikhail\CommentsDensity\Commands; |
|
6
|
|
|
|
|
7
|
|
|
use SavinMikhail\CommentsDensity\AnalyzerFactory; |
|
|
|
|
|
|
8
|
|
|
use SavinMikhail\CommentsDensity\BaselineManager; |
|
9
|
|
|
use SavinMikhail\CommentsDensity\Database\SQLiteDatabaseManager; |
|
|
|
|
|
|
10
|
|
|
use SavinMikhail\CommentsDensity\Reporters\ReporterFactory; |
|
|
|
|
|
|
11
|
|
|
use Symfony\Component\Console\Command\Command as SymfonyCommand; |
|
12
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
13
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
14
|
|
|
use function file_exists; |
|
15
|
|
|
use function touch; |
|
16
|
|
|
|
|
17
|
|
|
final class BaselineCommand extends Command |
|
18
|
|
|
{ |
|
19
|
|
|
protected function configure(): void |
|
20
|
|
|
{ |
|
21
|
|
|
$this->setName('generate:baseline') |
|
22
|
|
|
->setDescription('Generate a baseline of comments to ignore them in the future') |
|
23
|
|
|
->setHelp('This command allows you to ignore old tech debt and start this quality check from this point'); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int |
|
28
|
|
|
{ |
|
29
|
|
|
$databaseFile = __DIR__ . '/../../comments_density.sqlite'; |
|
30
|
|
|
if (! file_exists($databaseFile)) { |
|
31
|
|
|
touch($databaseFile); |
|
32
|
|
|
} |
|
33
|
|
|
$dbManager = new SQLiteDatabaseManager($databaseFile); |
|
34
|
|
|
$connection = $dbManager->getConnection(); |
|
35
|
|
|
$baselineManager = new BaselineManager($connection); |
|
36
|
|
|
|
|
37
|
|
|
$configDto = $this->getConfigDto(); |
|
38
|
|
|
|
|
39
|
|
|
$files = $this->getFilesFromDirectories($configDto->directories); |
|
40
|
|
|
$analyzerFactory = new AnalyzerFactory(); |
|
41
|
|
|
|
|
42
|
|
|
$analyzer = $analyzerFactory->getAnalyzer($configDto, $output); |
|
43
|
|
|
$outputDTO = $analyzer->analyze($files); |
|
44
|
|
|
|
|
45
|
|
|
$baselineManager->set($outputDTO); |
|
46
|
|
|
|
|
47
|
|
|
$output->writeln('<info>Baseline generated successfully!</info>'); |
|
48
|
|
|
|
|
49
|
|
|
return SymfonyCommand::SUCCESS; |
|
50
|
|
|
} |
|
51
|
|
|
} |
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