Skip to content

Commit

Permalink
Add configuration for checkstyle report #8
Browse files Browse the repository at this point in the history
  • Loading branch information
scheb committed Aug 11, 2020
1 parent 9425472 commit 5bd1e6e
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/tombstone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ logs:
directory: logs
report:
php: report/tombstone-report.php
checkstyle: report/checkstyle.xml
html: report
console: true
4 changes: 4 additions & 0 deletions src/analyzer/Cli/AnalyzeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Scheb\Tombstone\Analyzer\Model\VampireIndex;
use Scheb\Tombstone\Analyzer\Processing\Processor;
use Scheb\Tombstone\Analyzer\Processing\VampireMatcher;
use Scheb\Tombstone\Analyzer\Report\Checkstyle\CheckstyleReportGenerator;
use Scheb\Tombstone\Analyzer\Report\Console\ConsoleReportGenerator;
use Scheb\Tombstone\Analyzer\Report\Html\HtmlReportGenerator;
use Scheb\Tombstone\Analyzer\Report\Html\Renderer\BreadCrumbRenderer;
Expand Down Expand Up @@ -137,6 +138,9 @@ private function doExecute(): void
)
);
}
if (isset($config['report']['checkstyle'])) {
$reportGenerators[] = new CheckstyleReportGenerator($config['report']['checkstyle']);
}
if (isset($config['report']['php'])) {
$reportGenerators[] = new PhpReportGenerator($config['report']['php']);
}
Expand Down
7 changes: 7 additions & 0 deletions src/analyzer/Config/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ public function getConfigTreeBuilder()
->thenInvalid('Must be a writable file path, given: %s')
->end()
->end()
->scalarNode('checkstyle')
->defaultNull()
->validate()
->ifTrue($this->isNotWritableFile())
->thenInvalid('Must be a writable file path, given: %s')
->end()
->end()
->scalarNode('html')
->defaultNull()
->validate()
Expand Down
4 changes: 4 additions & 0 deletions src/analyzer/Config/YamlConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public function readConfiguration(): array
$config['report']['php'] = $this->resolvePath($config['report']['php']);
}

if (isset($config['report']['checkstyle'])) {
$config['report']['checkstyle'] = $this->resolvePath($config['report']['checkstyle']);
}

if (isset($config['report']['html'])) {
$config['report']['html'] = $this->resolvePath($config['report']['html']);
}
Expand Down
1 change: 1 addition & 0 deletions tests/Analyzer/Cli/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ApplicationTest extends TestCase
'_img/cross.png',
'_img/deleted.png',
'_img/vampire.png',
'checkstyle.xml',
'dashboard.html',
'index.html',
'src',
Expand Down
2 changes: 2 additions & 0 deletions tests/Analyzer/Config/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class ConfigurationTest extends TestCase
],
'report' => [
'php' => self::REPORT_DIR.'/report.php',
'checkstyle' => self::REPORT_DIR.'/checkstyle.xml',
'html' => self::REPORT_DIR,
'console' => true,
],
];

Expand Down
1 change: 1 addition & 0 deletions tests/Analyzer/Config/YamlConfigProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function processConfiguration_fullConfig_haveAllValuesSet(): void
],
'report' => [
'php' => self::CONFIG_DIR.'report'.DIRECTORY_SEPARATOR.'tombstone-report.php',
'checkstyle' => self::CONFIG_DIR.'report'.DIRECTORY_SEPARATOR.'checkstyle.xml',
'html' => self::CONFIG_DIR.'report',
'console' => true,
],
Expand Down
1 change: 1 addition & 0 deletions tests/Analyzer/Config/fixtures/full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ logs:
directory: logs
report:
php: report/tombstone-report.php
checkstyle: report/checkstyle.xml
html: report
console: true

0 comments on commit 5bd1e6e

Please sign in to comment.