Skip to content

Commit

Permalink
disable rules
Browse files Browse the repository at this point in the history
  • Loading branch information
savinmikhail committed Jan 2, 2025
1 parent 963f2fa commit 3214d57
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/Analyzer/AnalyzeFileTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,12 @@ private function analyzeFile(string $filename): array
private function shouldAnalyzeMissingDocBlocks(): bool
{
return
$this->configDTO->only === []
|| in_array($this->missingDocBlock->getName(), $this->configDTO->only, true);
$this->configDTO->getAllowedTypes() === []
|| in_array(
$this->missingDocBlock->getName(),
$this->configDTO->getAllowedTypes(),
true
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Analyzer/AnalyzerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function getAnalyzer(
OutputInterface $output,
BaselineStorageInterface $baselineStorage,
): Analyzer {
$commentFactory = new CommentFactory($configDto->only);
$commentFactory = new CommentFactory($configDto->getAllowedTypes());
$missingDocBlock = new MissingDocBlockAnalyzer($configDto->docblockConfigDTO);
$cds = new CDS($configDto->thresholds, $commentFactory);

Expand Down
14 changes: 13 additions & 1 deletion src/Config/DTO/ConfigDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ public function __construct(
public string $cacheDir = 'var/cache/comments-density',
/** Disable certain types; set to empty array for full statistics */
public array $disable = [],
public array $only = [],
) {}

public function getAllowedTypes(): array
{
$types = [
'docBlock',
'regular',
'todo',
'fixme',
'missingDocBlock',
];

return array_diff($types, $this->disable);
}
}

0 comments on commit 3214d57

Please sign in to comment.