Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support php-cs-fixer #66

Merged
merged 15 commits into from
Jun 10, 2017
Merged

Support php-cs-fixer #66

merged 15 commits into from
Jun 10, 2017

Conversation

zdenekdrahos
Copy link
Member

@zdenekdrahos zdenekdrahos commented May 8, 2017

Closes #60

  • configure dry-run and rules in .phpqa.yml
  • html report - demo
  • add as suggested tool
  • bin/suggested-tools.sh install doesn't work in default "clone", the tool needs Symfony3 components
# install php-cs-fixer after git clone
composer require friendsofphp/php-cs-fixer symfony/filesystem symfony/config symfony/process symfony/finder symfony/console symfony/event-dispatcher phploc/phploc

@zdenekdrahos
Copy link
Member Author

@keradus, @mastercoding: could you try this version? thanks

composer update edgedesign/phpqa:dev-php-cs-fixer

README.md Outdated
@@ -51,6 +51,7 @@ Experimental tool is executed only if the tool is specified in `--tools`.

Tool | PHP | Supported since | Description | Status |
---- | --- | --------------- | ----------- | ------ |
[php-cs-fixer](http://cs.sensiolabs.org/) | `>= 5.6` | `1.12` | Automatically detect and fix PHP coding standards issues | stable |
Copy link

Choose a reason for hiding this comment

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

FYI: if you want support for lower PHP, go with PHP CS Fixer v2.2+

@@ -199,6 +201,8 @@ Tool | Settings | Default Value | Your value
[phpcs.standard](https://pear.php.net/manual/en/package.php.php-codesniffer.usage.php#package.php.php-codesniffer.usage.coding-standard) | Coding standard | PSR2 | Name of existing standard (`PEAR`, `PHPCS`, `PSR1`, `PSR2`, `Squiz`, `Zend`), or path to your coding standard
[phpcs.ignoreWarnings](https://github.com/EdgedesignCZ/phpqa/issues/53) | If number of allowed errors is compared with warnings+errors, or just errors from `checkstyle.xml` | `false` | Boolean 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

<xsl:template match="/">
<html>
<head>
<title>php-cs-fixer report</title>
Copy link

Choose a reason for hiding this comment

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

PHP CS Fixer report
(tool name is PHP CS Fixer, not php-cs-fixer)

@@ -384,13 +392,37 @@ function ($relativeDir) {
);
}

private function phpcsfixer()
Copy link

Choose a reason for hiding this comment

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

if you like, you could execute the code (FixCommand) instead of running it as separated CLI process

@mastercoding
Copy link

mastercoding commented May 8, 2017

Hi @zdenekdrahos! Great to see that you tackled this so soon. I would propose two configurable options in addition to what you've got:

  • using-cache (yes/no)
  • config

The cache is because the results with cache enabled are not always the same. I would default to not using cache.

The configuration file i've got for php-cs-fixer is complex (https://gist.github.com/mastercoding/49db81e63b5b849779ecb79bd1e896e0). It would almost be impossible to put that in your tool.

What do you think?

@keradus
Copy link

keradus commented May 9, 2017

yeah, let point config file instead of mapping the properties

@zdenekdrahos
Copy link
Member Author

zdenekdrahos commented May 21, 2017

Thanks for great comments.

@keradus, @mastercoding: Cache can be disabled in config file. Is it necessary to define cache in .phpqa.yml?

@zdenekdrahos
Copy link
Member Author

@keradus, @mastercoding: is current version ok? Or is there something you'd like to change?

.gitignore Outdated
@@ -2,3 +2,4 @@
/vendor/
/build/
phpstan-phpqa.neon
.php_cs.cache
Copy link

Choose a reason for hiding this comment

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

I would add .php_cs (not .php_cs.dist) as well

$analyzedDirs = $this->options->getAnalyzedDirs();
$analyzedDir = reset($analyzedDirs);
if (count($analyzedDirs) > 1) {
$this->say("<error>php-cs-fixer analyzes only first directory {$analyzedDir}</error>");
Copy link

Choose a reason for hiding this comment

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

huh? you could provide multiple paths (dirs or files) in single CLI run

  [PhpCsFixer\ConfigurationException\InvalidConfigurationException]  
  For multiple paths config parameter is required.                   

PHP-CS-Fixer/PHP-CS-Fixer#2390
@zdenekdrahos zdenekdrahos merged commit 3227212 into master Jun 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Support PHP CS Fixer
3 participants