Use phpcs.xml.dist instead of custom-named phpcs.ruleset.xml#19
Merged
Conversation
Also remove redundant --configuration param from call to phpunit
Eliminates need to pass list of files to check and/or '--extensions=php .'
This ensures that the sniff codes are shown in all reports
schlessera
requested changes
Jun 4, 2017
| script: | ||
| - phpcs --standard=phpcs.ruleset.xml $(find . -name '*.php') | ||
| - phpunit --configuration phpunit.xml.dist No newline at end of file | ||
| - phpcs --standard=phpcs.xml.dist $(find . -name '*.php') |
Member
There was a problem hiding this comment.
I think that the --standard=... should be removed in the CI configurations as well.
Otherwise, you might end up creating a customized rule set that is being used for local tests, while the CI still runs with the default tests.
Member
There was a problem hiding this comment.
Oh, my bad, I thought I was looking at the merged diff.
| - | | ||
| if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then | ||
| phpcs --standard=phpcs.ruleset.xml $(find . -name '*.php') | ||
| phpcs --standard=phpcs.xml.dist $(find . -name '*.php') |
Member
There was a problem hiding this comment.
Same as with the GitLab file above.
schlessera
approved these changes
Jun 5, 2017
Contributor
Author
|
FYI: I also blogged about the background for this change in https://make.xwp.co/2017/06/04/reducing-command-line-args-required-for-running-phpcs/ |
danielbachhuber
pushed a commit
that referenced
this pull request
Nov 18, 2022
Use phpcs.xml.dist instead of custom-named phpcs.ruleset.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Incorporating improvements from xwp/wp-dev-lib#243:
The
phpcs.ruleset.xmlwas a custom filename used to disambiguate from the a genericruleset.xmlwhich used to be what PHPCS looked for until squizlabs/PHP_CodeSniffer@ae995b5 switched this tophpcs.xmland then squizlabs/PHP_CodeSniffer@85cbd46 added support forphpcs.xml.distas the next-level fallback, bringing it in alignment in behavior with PHPUnit'sphpunit.xmlandphpunit.xml.dist.When the standard filenames are used, they do not need to be supplied on the command line and will be automatically discovered by PHPCS by traversing the directory tree, just as ESLint and any number of other tools do.
Additionally, in the past PHPCS-lib would often need to get invoked like:
phpcs -s --extensions=php .These arguments are now unnecessary and are supplied by the default ruleset:
-s: Show sniff codes in all reports--extensions=php: Limit reporting to PHP files..: By indicating a default file, PHPCS won't assume to look atSTDIN, allowing you to just invokephpcsinstead ofphpcs ..First realized in #2 (comment)
The
phpcs.ruleset.xmlfilename originally came from xwp/wp-dev-lib@9d1d025PR which used filename in WP-CLI: wp-cli/wp-cli#3472
See also xwp/wp-dev-lib#231
Also see WordPress/WordPress-Coding-Standards#932
PhpStorm should soon support automatically looking for
phpcs.xml(.dist)as it does for ESLint and other tools' configs. See https://youtrack.jetbrains.com/issue/WI-36028