Skip to content

Commit

Permalink
phpqa - remove tool.allowedErrorsCount (BC)
Browse files Browse the repository at this point in the history
Reverts 6b24e64
  • Loading branch information
zdenekdrahos committed Jul 13, 2019
1 parent c246785 commit b450040
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 49 deletions.
7 changes: 0 additions & 7 deletions .phpqa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ phpqa:
phpcs:
# alternatively you can use an array to define multiple rule sets (https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage#specifying-a-coding-standard)
standard: PSR2
# can be overriden by CLI: phpqa --tools phpcs:1
allowedErrorsCount: null
# number of allowed errors is compared with warnings+errors, or just errors from checkstyle.xml
ignoreWarnings: false
# https://github.com/squizlabs/PHP_CodeSniffer/wiki/Reporting
Expand All @@ -30,7 +28,6 @@ phpcs:
# ./vendor/owner/package/src/MySummaryReport.php: phpcs-summary.html

php-cs-fixer:
allowedErrorsCount: null
# http://cs.sensiolabs.org/#usage
rules: '@PSR2'
allowRiskyRules: false
Expand All @@ -40,15 +37,13 @@ php-cs-fixer:
config: null

phpmd:
allowedErrorsCount: null
# alternatively you can use an array to define multiple rule sets (https://phpmd.org/documentation/index.html#using-multiple-rule-sets)
standard: app/phpmd.xml

pdepend:
# coverageReport: build/coverage-clover.xml

phpcpd:
allowedErrorsCount: null
minLines: 5
minTokens: 70

Expand All @@ -61,13 +56,11 @@ phpmetrics:
# composer: composer.json

phpstan:
allowedErrorsCount: null
level: 0
# https://github.com/phpstan/phpstan#configuration
# standard: tests/.travis/phpstan.neon

phpunit:
allowedErrorsCount: null
# binary: vendor/bin/phpunit
binary: null
# phpunit.xml
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,10 @@ phpqa --report --tools phpcs:0,phpmd:0,phpcpd:0,parallel-lint:0,phpstan:0,phpmet
Number of allowed errors can be also defined in [.phpqa.yml](#advanced-configuration---phpqayml).

```yaml
phpcs:
phpqa:
# can be overriden by CLI: phpqa --tools phpcs:1
allowedErrorsCount: 0
tools:
- phpcs:0
```
**File mode**
Expand Down Expand Up @@ -246,7 +247,6 @@ Tool | Settings | Default Value | Your value
[psalm.deadCode](https://github.com/vimeo/psalm/wiki/Running-Psalm#command-line-options) | Enable or not `--find-dead-code` option of psalm | `false` | Boolean value
[psalm.threads](https://github.com/vimeo/psalm/wiki/Running-Psalm#command-line-options) | Set the number of process to use in parallel (option `--threads` of psalm) (Only if `--execution == parallel` for phpqa) | `1` | Number (>= 1)
[psalm.showInfo](https://github.com/vimeo/psalm/wiki/Running-Psalm#command-line-options) | Display or not information (non-error) messages (option `--show-info=` of psalm) | `true` | Boolean value
`<tool>.allowedErrorsCount` | Number of allowed errors, see [exit code](#exit-code) | `null` | Integer value

`.phpqa.yml` is automatically detected in current working directory, but you can specify
directory via option:
Expand Down
5 changes: 2 additions & 3 deletions src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,13 @@ private function loadTools($inputTools)
}
}

public function buildRunningTools(array $tools, Config $c)
public function buildRunningTools(array $tools)
{
$allowed = array();
foreach ($tools as $tool => $config) {
if (array_key_exists($tool, $this->allowedTools)) {
$preload = [
'allowedErrorsCount' => $this->allowedTools[$tool] !== null
? $this->allowedTools[$tool] : $c->value("{$tool}.allowedErrorsCount"),
'allowedErrorsCount' => $this->allowedTools[$tool],
'xml' => array_key_exists('xml', $config) ? array_map([$this, 'rawFile'], $config['xml']) : []
];
$runningTool = new RunningTool($tool, $preload + $config);
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function (array $config) use ($tool) {
public function getExecutableTools(Options $o)
{
if (!$this->selectedTools) {
$this->selectedTools = $o->buildRunningTools($this->tools, $this->config);
$this->selectedTools = $o->buildRunningTools($this->tools);
}
return array_filter(
$this->selectedTools,
Expand Down
9 changes: 2 additions & 7 deletions tests/.appveyor/.phpqa.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
phpmd:
allowedErrorsCount: 0
phpcpd:
allowedErrorsCount: 0
phpunit:
allowedErrorsCount: 0
phpqa:
tools: phpmetrics,phploc,phpcs:0,php-cs-fixer,phpmd:0,pdepend,phpcpd:0,phpstan,phpunit:0,psalm,security-checker,parallel-lint

phpcs:
allowedErrorsCount: 1
ignoreWarnings: false
reports:
file:
Expand Down
30 changes: 2 additions & 28 deletions tests/OptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,34 +131,8 @@ public function testLoadAllowedErrorsCount()
assertThat($tools['pdepend']->getAllowedErrorsCount(), is(nullValue()));
}

public function testLoadErrorsCountFromConfig()
private function buildRunningTools(Options $o, array $tools)
{
$config = $this->givenConfig(function ($config) {
$config->value('phpcs.allowedErrorsCount')->willReturn(0);
$config->value('pdepend.allowedErrorsCount')->willReturn(2);
});
$options = $this->overrideOptions(array('tools' => 'phpcs:1,pdepend'));
$tools = $this->buildRunningTools($options, array('phpcs' => [], 'pdepend' => []), $config);
assertThat($tools['phpcs']->getAllowedErrorsCount(), is(1));
assertThat($tools['pdepend']->getAllowedErrorsCount(), is(2));
}

private function buildRunningTools(Options $o, array $tools, $config = null)
{
if (!$config) {
$config = $this->givenConfig(function ($config) {
$config->value(\Prophecy\Argument::any())->willReturn(null);
});
}
return $o->buildRunningTools($tools, $config);
}

private function givenConfig($setMethods = null)
{
$config = $this->prophesize('Edge\QA\Config');
if ($setMethods) {
$setMethods($config);
}
return $config->reveal();
return $o->buildRunningTools($tools);
}
}

0 comments on commit b450040

Please # to comment.