Skip to content

Commit

Permalink
phpmetrics - allow git statistics in .phpqa.yml
Browse files Browse the repository at this point in the history
Closes #122
  • Loading branch information
zdenekdrahos committed Mar 31, 2018
1 parent 03587df commit ec55df8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .phpqa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ phpcpd:
minTokens: 70

phpmetrics:
# v1
config: null
# v2
git: false

phpstan:
level: 0
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ Tool | Settings | Default Value | Your value
[php-cs-fixer.allowRiskyRules](http://cs.sensiolabs.org/#usage) | Whether risky rules may run | `false` | Boolean value
[php-cs-fixer.config](http://cs.sensiolabs.org/#usage) | Load configuration from [file](https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/.php_cs.dist) | `null` | Path to `.phpcs` file
[php-cs-fixer.isDryRun](http://cs.sensiolabs.org/#usage) | If code is just analyzed or fixers are applied | `true` | Boolean value
[phpmetrics.config](https://github.com/EdgedesignCZ/phpqa/issues/74) | Configuration for phpmetrics v1 | `null` | Path to `.phpmetrics.yml` file
[phpmetrics.git](https://github.com/EdgedesignCZ/phpqa/issues/74) | phpmetrics v2 supports basic git statistics | `null` | Boolean value or path to git binary
[phpmd](http://phpmd.org/documentation/creating-a-ruleset.html) | Ruleset | [Edgedesign's standard](/app/phpmd.xml) | Path to ruleset
[phpcpd](https://github.com/sebastianbergmann/phpcpd/blob/de9056615da6c1230f3294384055fa7d722c38fa/src/CLI/Command.php#L136) | Minimum number of lines/tokens for copy-paste detection | 5 lines, 70 tokens |
[phpstan](https://github.com/phpstan/phpstan#configuration) | Level, config file | Level 0, `%currentWorkingDirectory%/phpstan.neon` | Take a look at [phpqa config in tests/.travis](/tests/.travis/) |
Expand Down
4 changes: 4 additions & 0 deletions src/Tools/Analyzer/PhpMetricsV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public function __invoke()
$args['report-html'] = $this->options->toFile('phpmetrics/');
$args['report-violations'] = $this->options->toFile('phpmetrics.xml');
}
$gitBinary = $this->config->value('phpmetrics.git');
if ($gitBinary) {
$args['git'] = is_file($gitBinary) ? $gitBinary : 'git';
}
$args[] = $this->options->getAnalyzedDirs(',');
return $args;
}
Expand Down
2 changes: 2 additions & 0 deletions tests/Config/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public function testLoadDefaultConfig()
assertThat($config->value('psalm.deadCode'), identicalTo(false));
assertThat($config->value('psalm.threads'), identicalTo(1));
assertThat($config->value('psalm.showInfo'), identicalTo(true));
assertThat($config->value('phpmetrics.config'), is(nullValue()));
assertThat($config->value('phpmetrics.git'), identicalTo(false));
}

public function testBuildAbsolutePath()
Expand Down

0 comments on commit ec55df8

Please sign in to comment.