Skip to content

Commit 8c702de

Browse files
committed
remove output dependency
1 parent 2290a54 commit 8c702de

File tree

5 files changed

+6
-9
lines changed

5 files changed

+6
-9
lines changed

src/AnalyzeComments/Analyzer/AnalyzeFileTask.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace SavinMikhail\CommentsDensity\AnalyzeComments\Analyzer;
66

7+
use Psr\Cache\InvalidArgumentException;
78
use SavinMikhail\CommentsDensity\AnalyzeComments\Analyzer\DTO\Output\CommentDTO;
89
use SavinMikhail\CommentsDensity\AnalyzeComments\Comments\CommentFactory;
910
use SavinMikhail\CommentsDensity\AnalyzeComments\Config\DTO\ConfigDTO;
@@ -29,11 +30,11 @@ public function __construct(
2930
private MissingDocBlockAnalyzer $missingDocBlock,
3031
private CommentFactory $commentFactory,
3132
private ConfigDTO $configDTO,
32-
private OutputInterface $output,
3333
) {}
3434

3535
/**
3636
* @return array{'lines': int, 'comments': array<array-key, array<string, int>>}
37+
* @throws InvalidArgumentException
3738
*/
3839
public function run(SplFileInfo $file): array
3940
{
@@ -69,8 +70,6 @@ private function shouldSkipFile(SplFileInfo $file): bool
6970
*/
7071
private function analyzeFile(string $filename): array
7172
{
72-
$this->output->writeln("<info>Analyzing {$filename}</info>");
73-
7473
$code = file_get_contents($filename);
7574
$tokens = token_get_all($code);
7675

src/AnalyzeComments/Analyzer/Analyzer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use SavinMikhail\CommentsDensity\AnalyzeComments\Analyzer\DTO\Output\Report;
1010
use SavinMikhail\CommentsDensity\AnalyzeComments\Comments\CommentFactory;
1111
use SavinMikhail\CommentsDensity\AnalyzeComments\Config\DTO\ConfigDTO;
12+
use SavinMikhail\CommentsDensity\AnalyzeComments\Exception\CommentsDensityException;
1213
use SavinMikhail\CommentsDensity\AnalyzeComments\Metrics\MetricsFacade;
1314
use SavinMikhail\CommentsDensity\AnalyzeComments\MissingDocblock\MissingDocBlockAnalyzer;
1415
use SavinMikhail\CommentsDensity\Baseline\Storage\BaselineStorageInterface;
@@ -26,7 +27,6 @@ public function __construct(
2627
private readonly CommentFactory $commentFactory,
2728
private readonly MissingDocBlockAnalyzer $missingDocBlock,
2829
private readonly MetricsFacade $metrics,
29-
private readonly OutputInterface $output,
3030
private readonly MissingDocBlockAnalyzer $docBlockAnalyzer,
3131
private readonly BaselineStorageInterface $baselineStorage,
3232
private readonly CacheInterface $cache,
@@ -35,6 +35,7 @@ public function __construct(
3535

3636
/**
3737
* @param SplFileInfo[] $files
38+
* @throws CommentsDensityException
3839
*/
3940
public function analyze(iterable $files): Report
4041
{
@@ -49,7 +50,6 @@ public function analyze(iterable $files): Report
4950
$this->missingDocBlock,
5051
$this->commentFactory,
5152
$this->configDTO,
52-
$this->output,
5353
);
5454

5555
$response = $task->run($file);

src/AnalyzeComments/Analyzer/AnalyzerFactory.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
{
2020
public function getAnalyzer(
2121
ConfigDTO $configDto,
22-
OutputInterface $output,
2322
BaselineStorageInterface $baselineStorage,
2423
): Analyzer {
2524
$commentFactory = new CommentFactory($configDto->getAllowedTypes());
@@ -37,7 +36,6 @@ public function getAnalyzer(
3736
$commentFactory,
3837
$missingDocBlock,
3938
$metrics,
40-
$output,
4139
$missingDocBlock,
4240
$baselineStorage,
4341
new FilesystemAdapter(directory: $configDto->cacheDir),

src/AnalyzeComments/Commands/AnalyzeCommentCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5353
}
5454
$formatter = $formatters[$configDto->output->type] ?? $formatters['console'];
5555

56-
$analyzer = $this->analyzerFactory->getAnalyzer($configDto, $output, $this->storage);
56+
$analyzer = $this->analyzerFactory->getAnalyzer($configDto, $this->storage);
5757

5858
$report = $analyzer->analyze($files);
5959

src/Baseline/Commands/BaselineCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4141
$configDto = $this->configLoader->getConfigDto();
4242
$files = $this->getFilesFromDirectories($configDto->directories);
4343

44-
$analyzer = $this->analyzerFactory->getAnalyzer($configDto, $output, $this->storage);
44+
$analyzer = $this->analyzerFactory->getAnalyzer($configDto, $this->storage);
4545
$report = $analyzer->analyze($files);
4646

4747
$this->storage->setComments($report->comments); // todo create some baseline reporter

0 commit comments

Comments
 (0)