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

CS: start using YoastCS 0.5 #69

Merged
merged 12 commits into from
Jun 7, 2018
Merged

CS: start using YoastCS 0.5 #69

merged 12 commits into from
Jun 7, 2018

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented May 29, 2018

Summary

This PR can be summarized in the following changelog entry:

  • N/A

Relevant technical choices:

This PR moves this repo onto YoastCS 0.5.

Please see the individual commits for details and complete documentation about the changes.

Test instructions

This PR can be tested by following these steps:

  • Run vendor/bin/phpcs without arguments to see that the library code is clean (other than the above mentioned warnings).

jrfnl added 12 commits May 29, 2018 19:52
* Add YoastCS - not fixed to a specific minor as for this repo any "stable" release should be fine.
* Add the Dealerdirect Composer plugin to automatically sort out the PHPCS installed paths.

Moved the `require-dev` section down to be directly after the `require` section for improved human-readability of the file.
…tandard

The file is named `.phpcs.xml.dist` which allows for overruling the file with individual `phpcs.xml` and `.phpcs.xml` files. For that reasons, those files have been added to `.gitignore`.

Also: activate checking against PHPCS once per Travis run.
Historically, this library uses `camelCaps` for variable names instead of the WP convention of using `snake_case`.

There is no need to change this, we just need:
* to allow for it, i.e. exclude the WPCS sniff;
* make sure it's applied consistently, i.e. include a PHPCS sniff to check for this;
* fix up the few exceptions to the rules - done in separate PRs.
Historically, this library uses `camelCaps` for function names instead of the WP convention of using `snake_case`.

There is no need to change this, we just need:
* to allow for it, i.e. exclude the WPCS sniff;
* make sure it's applied consistently, i.e. include a PHPCS sniff to check for this and configure it;
* exclude a few files which are justified exceptions.
Historically, this library uses a different convention for file names.
... and allow for non-prefixed globals in select test situations.
…nit test files

I've chosen to exclude the errors for the `tests` directory in contrast to downgrading them to `warnings` for the complete plugin to prevent new documentation errors being introduced in the non-test code.
YoastCS uses PHP_CodeSniffer 3.x which has a minimum requirement of PHP 5.4.
As the build check running PHPCS is run on PHP 7.2 and devs generally use a reasonably PHP version as well, this shouldn't be a problem.

However, when installing from and/or validating the `composer.json` file during builds, Composer also tests all the scripts defined by the various packages and if this is done on PHP 5.3, the scripts for PHP_CodeSniffer will - predictably - fail.

Removing PHPCS as a dependency for the non-PHPCS builds solves this.
@moorscode moorscode merged commit d4d391d into master Jun 7, 2018
@moorscode moorscode deleted the JRF/CS/add-phpcs branch June 7, 2018 07:31
@jrfnl jrfnl added this to the Next release milestone Nov 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants