Skip to content

Commit b3cd14e

Browse files
committed
phpmetrics - allow adding composer files when composer.json isn't inside analyzed dirs
#123
1 parent 3282eea commit b3cd14e

4 files changed

Lines changed: 9 additions & 1 deletion

File tree

.phpqa.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ phpmetrics:
3434
# v2
3535
git: false
3636
# junit: build/log-junit.xml
37+
# composer: composer.json
3738

3839
phpstan:
3940
level: 0

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ Tool | Settings | Default Value | Your value
228228
[phpmetrics.config](https://github.com/EdgedesignCZ/phpqa/issues/74) | Configuration for phpmetrics v1 | `null` | Path to `.phpmetrics.yml` file
229229
[phpmetrics.git](https://github.com/EdgedesignCZ/phpqa/pull/122) | phpmetrics v2 analyses based on Git History | `null` | Boolean value or path to git binary
230230
[phpmetrics.junit](https://github.com/EdgedesignCZ/phpqa/pull/125) | phpmetrics v2 evaluates metrics according to JUnit logs | `null` | Path to JUnit xml
231+
[phpmetrics.composer](https://github.com/EdgedesignCZ/phpqa/pull/123) | phpmetrics v2 analyzes composer dependencies | `null` | Path to composer.json when the file is not included in `analyzedDirs`
231232
[phpmd](http://phpmd.org/documentation/creating-a-ruleset.html) | Ruleset | [Edgedesign's standard](/app/phpmd.xml) | Path to ruleset
232233
[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 |
233234
[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: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ public function __invoke()
3131
$args['junit'] = $junit;
3232
}
3333

34-
$args[] = $this->options->getAnalyzedDirs(',');
34+
$analyzedDirs = $this->options->getAnalyzedDirs(',');
35+
$composer = $this->config->path('phpmetrics.composer');
36+
if ($composer) {
37+
$analyzedDirs .= ",{$composer}," . str_replace('composer.json', 'composer.lock', $composer);
38+
}
39+
$args[] = $analyzedDirs;
3540
return $args;
3641
}
3742
}

tests/Config/ConfigTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function testLoadDefaultConfig()
3131
assertThat($config->value('psalm.showInfo'), identicalTo(true));
3232
assertThat($config->value('phpmetrics.config'), is(nullValue()));
3333
assertThat($config->value('phpmetrics.junit'), is(nullValue()));
34+
assertThat($config->value('phpmetrics.composer'), is(nullValue()));
3435
assertThat($config->value('phpmetrics.git'), identicalTo(false));
3536
}
3637

0 commit comments

Comments
 (0)