Skip to content

Commit

Permalink
remove output dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
savinmikhail committed Jan 3, 2025
1 parent 2290a54 commit 8c702de
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/AnalyzeComments/Analyzer/AnalyzeFileTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace SavinMikhail\CommentsDensity\AnalyzeComments\Analyzer;

use Psr\Cache\InvalidArgumentException;
use SavinMikhail\CommentsDensity\AnalyzeComments\Analyzer\DTO\Output\CommentDTO;
use SavinMikhail\CommentsDensity\AnalyzeComments\Comments\CommentFactory;
use SavinMikhail\CommentsDensity\AnalyzeComments\Config\DTO\ConfigDTO;
Expand All @@ -29,11 +30,11 @@ public function __construct(
private MissingDocBlockAnalyzer $missingDocBlock,
private CommentFactory $commentFactory,
private ConfigDTO $configDTO,
private OutputInterface $output,
) {}

/**
* @return array{'lines': int, 'comments': array<array-key, array<string, int>>}
* @throws InvalidArgumentException
*/
public function run(SplFileInfo $file): array
{
Expand Down Expand Up @@ -69,8 +70,6 @@ private function shouldSkipFile(SplFileInfo $file): bool
*/
private function analyzeFile(string $filename): array
{
$this->output->writeln("<info>Analyzing {$filename}</info>");

$code = file_get_contents($filename);
$tokens = token_get_all($code);

Expand Down
4 changes: 2 additions & 2 deletions src/AnalyzeComments/Analyzer/Analyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use SavinMikhail\CommentsDensity\AnalyzeComments\Analyzer\DTO\Output\Report;
use SavinMikhail\CommentsDensity\AnalyzeComments\Comments\CommentFactory;
use SavinMikhail\CommentsDensity\AnalyzeComments\Config\DTO\ConfigDTO;
use SavinMikhail\CommentsDensity\AnalyzeComments\Exception\CommentsDensityException;
use SavinMikhail\CommentsDensity\AnalyzeComments\Metrics\MetricsFacade;
use SavinMikhail\CommentsDensity\AnalyzeComments\MissingDocblock\MissingDocBlockAnalyzer;
use SavinMikhail\CommentsDensity\Baseline\Storage\BaselineStorageInterface;
Expand All @@ -26,7 +27,6 @@ public function __construct(
private readonly CommentFactory $commentFactory,
private readonly MissingDocBlockAnalyzer $missingDocBlock,
private readonly MetricsFacade $metrics,
private readonly OutputInterface $output,
private readonly MissingDocBlockAnalyzer $docBlockAnalyzer,
private readonly BaselineStorageInterface $baselineStorage,
private readonly CacheInterface $cache,
Expand All @@ -35,6 +35,7 @@ public function __construct(

/**
* @param SplFileInfo[] $files
* @throws CommentsDensityException
*/
public function analyze(iterable $files): Report
{
Expand All @@ -49,7 +50,6 @@ public function analyze(iterable $files): Report
$this->missingDocBlock,
$this->commentFactory,
$this->configDTO,
$this->output,
);

$response = $task->run($file);
Expand Down
2 changes: 0 additions & 2 deletions src/AnalyzeComments/Analyzer/AnalyzerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
{
public function getAnalyzer(
ConfigDTO $configDto,
OutputInterface $output,
BaselineStorageInterface $baselineStorage,
): Analyzer {
$commentFactory = new CommentFactory($configDto->getAllowedTypes());
Expand All @@ -37,7 +36,6 @@ public function getAnalyzer(
$commentFactory,
$missingDocBlock,
$metrics,
$output,
$missingDocBlock,
$baselineStorage,
new FilesystemAdapter(directory: $configDto->cacheDir),
Expand Down
2 changes: 1 addition & 1 deletion src/AnalyzeComments/Commands/AnalyzeCommentCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
$formatter = $formatters[$configDto->output->type] ?? $formatters['console'];

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/Baseline/Commands/BaselineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$configDto = $this->configLoader->getConfigDto();
$files = $this->getFilesFromDirectories($configDto->directories);

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

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

0 comments on commit 8c702de

Please sign in to comment.