Skip to content

Commit ec55df8

Browse files
committed
phpmetrics - allow git statistics in .phpqa.yml
Closes #122
1 parent 03587df commit ec55df8

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

.phpqa.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ phpcpd:
2929
minTokens: 70
3030

3131
phpmetrics:
32+
# v1
3233
config: null
34+
# v2
35+
git: false
3336

3437
phpstan:
3538
level: 0

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ Tool | Settings | Default Value | Your value
225225
[php-cs-fixer.allowRiskyRules](http://cs.sensiolabs.org/#usage) | Whether risky rules may run | `false` | Boolean value
226226
[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
227227
[php-cs-fixer.isDryRun](http://cs.sensiolabs.org/#usage) | If code is just analyzed or fixers are applied | `true` | Boolean value
228+
[phpmetrics.config](https://github.com/EdgedesignCZ/phpqa/issues/74) | Configuration for phpmetrics v1 | `null` | Path to `.phpmetrics.yml` file
229+
[phpmetrics.git](https://github.com/EdgedesignCZ/phpqa/issues/74) | phpmetrics v2 supports basic git statistics | `null` | Boolean value or path to git binary
228230
[phpmd](http://phpmd.org/documentation/creating-a-ruleset.html) | Ruleset | [Edgedesign's standard](/app/phpmd.xml) | Path to ruleset
229231
[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 |
230232
[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/) |

src/Tools/Analyzer/PhpMetricsV2.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ public function __invoke()
2020
$args['report-html'] = $this->options->toFile('phpmetrics/');
2121
$args['report-violations'] = $this->options->toFile('phpmetrics.xml');
2222
}
23+
$gitBinary = $this->config->value('phpmetrics.git');
24+
if ($gitBinary) {
25+
$args['git'] = is_file($gitBinary) ? $gitBinary : 'git';
26+
}
2327
$args[] = $this->options->getAnalyzedDirs(',');
2428
return $args;
2529
}

tests/Config/ConfigTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public function testLoadDefaultConfig()
2929
assertThat($config->value('psalm.deadCode'), identicalTo(false));
3030
assertThat($config->value('psalm.threads'), identicalTo(1));
3131
assertThat($config->value('psalm.showInfo'), identicalTo(true));
32+
assertThat($config->value('phpmetrics.config'), is(nullValue()));
33+
assertThat($config->value('phpmetrics.git'), identicalTo(false));
3234
}
3335

3436
public function testBuildAbsolutePath()

0 commit comments

Comments
 (0)