Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use phpcs.xml.dist instead of custom-named phpcs.ruleset.xml#19

Merged
schlessera merged 4 commits into
wp-cli:masterfrom
xwp:update/phpcs
Jun 5, 2017
Merged

Use phpcs.xml.dist instead of custom-named phpcs.ruleset.xml#19
schlessera merged 4 commits into
wp-cli:masterfrom
xwp:update/phpcs

Conversation

@westonruter

Copy link
Copy Markdown
Contributor

Incorporating improvements from xwp/wp-dev-lib#243:

The phpcs.ruleset.xml was a custom filename used to disambiguate from the a generic ruleset.xml which used to be what PHPCS looked for until squizlabs/PHP_CodeSniffer@ae995b5 switched this to phpcs.xml and then squizlabs/PHP_CodeSniffer@85cbd46 added support for phpcs.xml.dist as the next-level fallback, bringing it in alignment in behavior with PHPUnit's phpunit.xml and phpunit.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 at STDIN, allowing you to just invoke phpcs instead of phpcs ..

First realized in #2 (comment)
The phpcs.ruleset.xml filename originally came from xwp/wp-dev-lib@9d1d025
PR 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

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
Comment thread templates/plugin-gitlab.mustache Outdated
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')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Isn't this what was done in c1fd60d?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh, my bad, I thought I was looking at the merged diff.

Comment thread templates/plugin-travis.mustache Outdated
- |
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
phpcs --standard=phpcs.ruleset.xml $(find . -name '*.php')
phpcs --standard=phpcs.xml.dist $(find . -name '*.php')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same as with the GitLab file above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

See c1fd60d?

@schlessera schlessera added enhancement command:scaffold-child-theme Related to 'scaffold child-theme' command command:scaffold-plugin-tests Related to 'scaffold plugin-tests' command labels Jun 4, 2017
@schlessera schlessera merged commit fd3a648 into wp-cli:master Jun 5, 2017
@westonruter

Copy link
Copy Markdown
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/

@westonruter westonruter deleted the update/phpcs branch June 5, 2017 15:30
@schlessera schlessera added this to the 1.0.5 milestone Jun 5, 2017
danielbachhuber pushed a commit that referenced this pull request Nov 18, 2022
Use phpcs.xml.dist instead of custom-named phpcs.ruleset.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:scaffold-child-theme Related to 'scaffold child-theme' command command:scaffold-plugin-tests Related to 'scaffold plugin-tests' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants