Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
php-cs-fixer - allow custom .php_cs configuration instead of mapping …
…rules in .phpqa.yml
  • Loading branch information
zdenekdrahos committed May 21, 2017
commit 966dda65a5739af685df6f45792ba0854fd21a4b
2 changes: 2 additions & 0 deletions .phpqa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ php-cs-fixer:
allowRiskyRules: false
# by default the tool is runned in dry-run mode (no fixers are applied)
isDryRun: true
# alternatively you can define path to your .phpcs_file (rules/allowRiskyRules config is ignored)
config: null

phpmd:
standard: app/phpmd.xml
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ Tool | Settings | Default Value | Your value
[phpcs.reports](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Reporting) | Report types | [`full`](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Reporting#printing-full-and-summary-reports) report in [cli mode](#output-modes), [`checkstyle`](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Reporting#printing-a-checkstyle-report) in [file mode](#output-modes) | Predefined [report types](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Reporting) or [custom reports](https://github.com/wikidi/codesniffer#examples)
[php-cs-fixer.rules](http://cs.sensiolabs.org/#usage) | Coding standard rules | `@PSR2` | String value
Copy link

@keradus keradus May 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may require risky support, as some of the rules require that to be enabled

[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
[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 |
Expand Down
11 changes: 9 additions & 2 deletions src/CodeAnalysisTasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,18 @@ private function phpcsfixer()
$args = [
'fix',
$analyzedDir,
'rules' => $this->config->value('php-cs-fixer.rules'),
'verbose' => '',
'format' => $this->options->isSavedToFiles ? 'junit' : 'txt',
'allow-risky' => $this->config->value('php-cs-fixer.allowRiskyRules') ? 'yes' : 'no',
];
$configFile = $this->config->value('php-cs-fixer.config');
if ($configFile) {
$args['config'] = $configFile;
} else {
$args += [
'rules' => $this->config->value('php-cs-fixer.rules'),
'allow-risky' => $this->config->value('php-cs-fixer.allowRiskyRules') ? 'yes' : 'no',
];
}
if ($this->config->value('php-cs-fixer.isDryRun')) {
$args['dry-run'] = '';
}
Expand Down
1 change: 1 addition & 0 deletions tests/Config/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function testLoadDefaultConfig()
assertThat($config->value('php-cs-fixer.rules'), is(nonEmptyString()));
assertThat($config->value('php-cs-fixer.isDryRun'), identicalTo(true));
assertThat($config->value('php-cs-fixer.allowRiskyRules'), identicalTo(false));
assertThat($config->path('php-cs-fixer.config'), is(nullValue()));
assertThat($config->path('phpmd.standard'), is(nonEmptyString()));
assertThat($config->value('phpstan.level'), identicalTo(0));
}
Expand Down