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
Update to Coding Standard command #469
Conversation
Coding Standard command should be executed only for changed PHP files, skipping fixtures folder.
CONTRIBUTING.md
Outdated
@@ -30,7 +30,7 @@ Make sure your code changes comply with the PSR-2 coding standard by | |||
using [PHP Codesniffer](https://github.com/squizlabs/PHP_CodeSniffer) | |||
from within your PHPMD folder: | |||
|
|||
vendor/bin/phpcs -p --extensions=php --standard=PSR2 src > phpcs.txt | |||
vendor/bin/phpcs -p --extensions=php --standard=PSR2 --ignore=src/tests/resources $(git ls-files -om --exclude-standard | grep '\.php$') > phpcs.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Three thoughts:
- grep is not available on Windows, so I prefer to keep the current one. (yes i know
vendor/bin/phpcs
needs to be adjusted on Windows, anyway) - Just because they aren't changed, doesn't mean those files don't contain a cs violation. The project isn't THAT huge, anyway.
- I would prefer, if we could align the commands with those used as Composer scripts as much as possible:
https://github.com/phpmd/phpmd/blob/master/composer.json#L54
So it would become
vendor/binphpcs -p --standard=PSR2 ./src/main/php ./src/test/php > phpcs.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, we can state, that one could use the Composer scripts composer cs-check
and composer cs-fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ravage84 ,
Current problem is, that there are some files, that already violates the styling rules. That was my main goal here. Grep is not a big deal (I forgot about Windows users) - git ls-files
gives an --ignore
flag, that works exactly as | grep -v
(but again - Windows users will have to execute that in two commands). I assume, that I can just decline this PR, mostly because of OS incompatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about you change your PR to add a note for Linux users who are able to use this, containing the optimized cli command?
Updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After those two small changes, I think we can merge 😸
CONTRIBUTING.md
Outdated
@@ -32,6 +32,9 @@ from within your PHPMD folder: | |||
|
|||
vendor/bin/phpcs -p --extensions=php --standard=PSR2 src > phpcs.txt | |||
|
|||
Linux | OS X users may extend this command to exclude files, that are not part of a commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| -> /
CONTRIBUTING.md
Outdated
@@ -32,6 +32,9 @@ from within your PHPMD folder: | |||
|
|||
vendor/bin/phpcs -p --extensions=php --standard=PSR2 src > phpcs.txt | |||
|
|||
Linux | OS X users may extend this command to exclude files, that are not part of a commit: | |||
|
|||
vendor/bin/phpcs -p --extensions=php --standard=PSR2 --ignore=src/tests/resources $(git ls-files -om --exclude-standard | grep '\.php$') > phpcs.txt | |||
Check the ``phpcs.txt`` once it finished. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add another white line before.
Here we go. |
Thanks! 🍺 |
Coding Standard command should be executed only for changed PHP files, skipping fixtures folder.