Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
!/bin/phpcca.bat
/.phive/
/.phpunit.cache/
/.phpcca.cache/
/tmp/
/tools/
/benchmarks/storage/
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"require": {
"php": "^8.1",
"nikic/php-parser": "^5.1",
"psr/cache": "^3.0",
"symfony/console": "^6.0||^7.0",
"symfony/config": "^6.0||^7.0",
"symfony/yaml": "^6.0||^7.0",
Expand Down
214 changes: 2 additions & 212 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ cognitive:
threshold: 1
scale: 1.0
enabled: true
cache:
enabled: false
directory: './.phpcca.cache'
# Example of custom reporters:
# customReporters:
# cognitive:
Expand Down
11 changes: 10 additions & 1 deletion src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Phauthentic\CognitiveCodeAnalysis\Business\Cognitive\ScoreCalculator;
use Phauthentic\CognitiveCodeAnalysis\Business\MetricsFacade;
use Phauthentic\CognitiveCodeAnalysis\Business\Utility\DirectoryScanner;
use Phauthentic\CognitiveCodeAnalysis\Cache\FileCache;
use Phauthentic\CognitiveCodeAnalysis\Command\ChurnCommand;
use Phauthentic\CognitiveCodeAnalysis\Command\ChurnSpecifications\ChurnValidationSpecificationFactory;
use Phauthentic\CognitiveCodeAnalysis\Command\CognitiveMetricsCommand;
Expand All @@ -42,6 +43,7 @@
use PhpParser\NodeTraverser;
use PhpParser\NodeTraverserInterface;
use PhpParser\ParserFactory;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Console\Application as SymfonyApplication;
use Symfony\Component\Console\Input\ArgvInput;
Expand Down Expand Up @@ -99,6 +101,12 @@ private function registerCoreServices(): void
$this->containerBuilder->register(ConfigService::class, ConfigService::class)
->setPublic(true);

$this->containerBuilder->register(CacheItemPoolInterface::class, FileCache::class)
->setArguments([
'./.phpcca.cache' // Default cache directory, can be overridden by config
])
->setPublic(true);

$this->containerBuilder->register(Baseline::class, Baseline::class)
->setPublic(true);

Expand Down Expand Up @@ -242,7 +250,8 @@ private function bootstrapMetricsCollectors(): void
new Reference(Parser::class),
new Reference(DirectoryScanner::class),
new Reference(ConfigService::class),
new Reference(MessageBusInterface::class)
new Reference(MessageBusInterface::class),
new Reference(CacheItemPoolInterface::class)
])
->setPublic(true);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Business/Cognitive/CognitiveMetricsCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ public function groupBy(string $property): array
$grouped[$key]->add($metric);
}

ksort($grouped);

return $grouped;
}

Expand Down
Loading