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 PHPCS default rule set #161

Merged
merged 10 commits into from Jul 29, 2018

Conversation

4 participants
@NicktheGeek

NicktheGeek commented Jul 20, 2018

The .phpcs.xml.dist rule file is detected and implemented automatically, reducing complexity for running phpcs.

The updated rules account for new wpcs sniff properties including the ability to check global prefix and i18n implementation with the correct text domain when specified.

The values have been left blank so the sniffs are generic, but the rules are in place to make it easier to get started by scaffold.

This is tangentially related to #109

This is also loosely related to #63 as updating composer scaffolds could work with this change.

@GaryJones may be able to provide additional feedback on this file change.

Nick Croft
change to .phpcs.xml.dist and update rules
The .phpcs.xml.dist rule file is detected and implemented automatically, reducing complexity for running phpcs.

The updated rules account for new wpcs sniff properties including the ability to check global prefix and i18n implementation with the correct text domain when specified.

The values have been left blank so the sniffs are generic, but the rules are in place to make it easier to get started by scaffold.
@schlessera

This comment has been minimized.

Show comment
Hide comment
@schlessera

schlessera Jul 20, 2018

Member

Yes, I would indeed love feedback from @GaryJones and @jrfnl to know whether this would be a good default starting point for new plugins.

Member

schlessera commented Jul 20, 2018

Yes, I would indeed love feedback from @GaryJones and @jrfnl to know whether this would be a good default starting point for new plugins.

@schlessera

This comment has been minimized.

Show comment
Hide comment
@schlessera

schlessera Jul 20, 2018

Member

@NicktheGeek For the blanks, it would be helpful to add comments so that developers immediately know where to turn the dials.

Member

schlessera commented Jul 20, 2018

@NicktheGeek For the blanks, it would be helpful to add comments so that developers immediately know where to turn the dials.

@NicktheGeek

This comment has been minimized.

Show comment
Hide comment
@NicktheGeek

NicktheGeek commented Jul 20, 2018

@schlessera good idea.

@NicktheGeek

This comment has been minimized.

Show comment
Hide comment
@NicktheGeek

NicktheGeek Jul 20, 2018

@schlessera added the comments.

NicktheGeek commented Jul 20, 2018

@schlessera added the comments.

Show outdated Hide outdated templates/.phpcs.xml.dist
Show outdated Hide outdated templates/.phpcs.xml.dist
Show outdated Hide outdated templates/.phpcs.xml.dist
Show outdated Hide outdated templates/.phpcs.xml.dist
Show outdated Hide outdated templates/.phpcs.xml.dist
Show outdated Hide outdated templates/.phpcs.xml.dist
Show outdated Hide outdated templates/.phpcs.xml.dist
Show outdated Hide outdated templates/.phpcs.xml.dist
Show outdated Hide outdated templates/.phpcs.xml.dist
Show outdated Hide outdated templates/.phpcs.xml.dist
@GaryJones

This comment has been minimized.

Show comment
Hide comment
@GaryJones

GaryJones Jul 20, 2018

Contributor

Rushing the review, and @jrfnl can fill in some blanks (or I can another day), but overall +1 for the PR to make it a much nicer starting point to implementing WPCS.

Thanks @NicktheGeek!

Contributor

GaryJones commented Jul 20, 2018

Rushing the review, and @jrfnl can fill in some blanks (or I can another day), but overall +1 for the PR to make it a much nicer starting point to implementing WPCS.

Thanks @NicktheGeek!

@NicktheGeek

This comment has been minimized.

Show comment
Hide comment
@NicktheGeek

NicktheGeek Jul 20, 2018

thanks you @GaryJones after you helped me get this on GFWA I've used it on several projects and I can't tell you the number of times it has found a minor typo in the text domain and saved me so much headache down the road. That one feature is worth the price of admission.

NicktheGeek commented Jul 20, 2018

thanks you @GaryJones after you helped me get this on GFWA I've used it on several projects and I can't tell you the number of times it has found a minor typo in the text domain and saved me so much headache down the road. That one feature is worth the price of admission.

Nick Croft added some commits Jul 20, 2018

Nick Croft
update based on more PR feedback
change the the ruleset name and add a comment explaining parellel processing.
@NicktheGeek

This comment has been minimized.

Show comment
Hide comment
@NicktheGeek

NicktheGeek Jul 20, 2018

@jrfnl Thanks! I've added the changes you recommended.

@schlessera this may need some additional feedback from @jrfnl or @GaryJones but so far I've implemented almost everything suggested. There are a couple of comments regarding WPCS 1.0.0 but IMO we are better if this is implemented now and an issue created to update when 1.0.0 comes out with additional improvements. I'm good either way though pending release timeline for WP CLI 2.0 and WPCS 1.0.0.

NicktheGeek commented Jul 20, 2018

@jrfnl Thanks! I've added the changes you recommended.

@schlessera this may need some additional feedback from @jrfnl or @GaryJones but so far I've implemented almost everything suggested. There are a couple of comments regarding WPCS 1.0.0 but IMO we are better if this is implemented now and an issue created to update when 1.0.0 comes out with additional improvements. I'm good either way though pending release timeline for WP CLI 2.0 and WPCS 1.0.0.

@jrfnl

@schlessera Thanks for the ping. @NicktheGeek I've left some comments inline.

@jrfnl will the current CSV method work with PHPCS 3.3.0+? If so it seams like it might be better to wait before implementing that even by reference.

Yes, the current comma-delimited string format will still work, but it will be removed in PHPCS 4.0.

For more information about this change and the new format - much more readable! -, see the PHPCS 3.3.0 release notes: https://github.com/squizlabs/PHP_CodeSniffer/releases/tag/3.3.0

Show outdated Hide outdated templates/.phpcs.xml.dist
Show outdated Hide outdated templates/.phpcs.xml.dist
Show outdated Hide outdated templates/.phpcs.xml.dist
Show outdated Hide outdated templates/.phpcs.xml.dist
Show outdated Hide outdated templates/.phpcs.xml.dist
Show outdated Hide outdated templates/.phpcs.xml.dist
Show outdated Hide outdated templates/.phpcs.xml.dist
Show outdated Hide outdated templates/.phpcs.xml.dist
@jrfnl

This comment has been minimized.

Show comment
Hide comment
@jrfnl

jrfnl Jul 20, 2018

Contributor

Forgot to respond to this:

There are a couple of comments regarding WPCS 1.0.0 but IMO we are better if this is implemented now and an issue created to update when 1.0.0 comes out with additional improvements.

WPCS 1.0.0 was due to come out last week, but there's still one issue which needs to be fixed. Expect it very soon though.

All the same, for the ruleset as it is, AFAICS, no changes would be needed for WPCS 1.0.0, so you're good.

Contributor

jrfnl commented Jul 20, 2018

Forgot to respond to this:

There are a couple of comments regarding WPCS 1.0.0 but IMO we are better if this is implemented now and an issue created to update when 1.0.0 comes out with additional improvements.

WPCS 1.0.0 was due to come out last week, but there's still one issue which needs to be fixed. Expect it very soon though.

All the same, for the ruleset as it is, AFAICS, no changes would be needed for WPCS 1.0.0, so you're good.

@jrfnl jrfnl referenced this pull request Jul 20, 2018

Open

Add template/composer.json #63

Nick Croft
add comments and update rule ref
also converts spaces to tabs
@GaryJones

This comment has been minimized.

Show comment
Hide comment
@GaryJones

GaryJones Jul 20, 2018

Contributor

The failure looks like some behat tests need updating to reference .phpcs.xml.dist (leading dot) instead of phpcs.xml.dist.

Contributor

GaryJones commented Jul 20, 2018

The failure looks like some behat tests need updating to reference .phpcs.xml.dist (leading dot) instead of phpcs.xml.dist.

@NicktheGeek

This comment has been minimized.

Show comment
Hide comment
@NicktheGeek

NicktheGeek Jul 20, 2018

@GaryJones @jrfnl will it be ok for this to not have the leading .? I think it is required to be automatically used but I want to make sure I'm understanding the reason.

NicktheGeek commented Jul 20, 2018

@GaryJones @jrfnl will it be ok for this to not have the leading .? I think it is required to be automatically used but I want to make sure I'm understanding the reason.

@jrfnl

This comment has been minimized.

Show comment
Hide comment
@jrfnl

jrfnl Jul 20, 2018

Contributor

@GaryJones @jrfnl will it be ok for this to not have the leading .? I think it is required to be automatically used but I want to make sure I'm understanding the reason.

Do you mean for the actual file name phpcs.xml.dist ? (in contrast to my remark about the exclude pattern #161 (comment) )

Yes, no problem.

Allowing a leading . for the filename was introduced in PHPCS 3.1.0 with a file loading order change in 3.1.1.

So for the custom ruleset with a leading dot to work, the minimum PHPCS requirement would have to be set at 3.1.0.

The file loading order (as of PHPCS 3.1.1) is:

  1. .phpcs.xml
  2. phpcs.xml
  3. .phpcs.xml.dist
  4. phpcs.xml.dist

In other words, not having the leading . now allows three different files to overrule the file.

Refs:

Contributor

jrfnl commented Jul 20, 2018

@GaryJones @jrfnl will it be ok for this to not have the leading .? I think it is required to be automatically used but I want to make sure I'm understanding the reason.

Do you mean for the actual file name phpcs.xml.dist ? (in contrast to my remark about the exclude pattern #161 (comment) )

Yes, no problem.

Allowing a leading . for the filename was introduced in PHPCS 3.1.0 with a file loading order change in 3.1.1.

So for the custom ruleset with a leading dot to work, the minimum PHPCS requirement would have to be set at 3.1.0.

The file loading order (as of PHPCS 3.1.1) is:

  1. .phpcs.xml
  2. phpcs.xml
  3. .phpcs.xml.dist
  4. phpcs.xml.dist

In other words, not having the leading . now allows three different files to overrule the file.

Refs:

@GaryJones

This comment has been minimized.

Show comment
Hide comment
@GaryJones

GaryJones Jul 20, 2018

Contributor

will it be ok for this to not have the leading .?

And beyond what @jrfnl just said, whether it's right for PHPCS 3.1[.1] to be the minimum version for scaffolded plugins is a different matter, though for new plugins I don't see much reason why the default shouldn't be 3.3.

Contributor

GaryJones commented Jul 20, 2018

will it be ok for this to not have the leading .?

And beyond what @jrfnl just said, whether it's right for PHPCS 3.1[.1] to be the minimum version for scaffolded plugins is a different matter, though for new plugins I don't see much reason why the default shouldn't be 3.3.

@NicktheGeek

This comment has been minimized.

Show comment
Hide comment
@NicktheGeek

NicktheGeek Jul 20, 2018

I went ahed and updated the tests to solve for the file ext change

NicktheGeek commented Jul 20, 2018

I went ahed and updated the tests to solve for the file ext change

@schlessera schlessera added this to the 1.1.4 milestone Jul 29, 2018

@jrfnl

This comment has been minimized.

Show comment
Hide comment
@jrfnl

jrfnl Jul 29, 2018

Contributor

FYI: in the mean time, both PHPCS 3.3.1 as well as WPCS 1.0.0 have been released.

Contributor

jrfnl commented Jul 29, 2018

FYI: in the mean time, both PHPCS 3.3.1 as well as WPCS 1.0.0 have been released.

@schlessera

This comment has been minimized.

Show comment
Hide comment
@schlessera

schlessera Jul 29, 2018

Member

Thanks to @NicktheGeek for the pull request, and thanks to @GaryJones & @jrfnl for the extensive review!

Member

schlessera commented Jul 29, 2018

Thanks to @NicktheGeek for the pull request, and thanks to @GaryJones & @jrfnl for the extensive review!

@schlessera schlessera merged commit a897a54 into wp-cli:master Jul 29, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@schlessera schlessera changed the title from change to .phpcs.xml.dist and update rules to Update PHPCS default rule set Jul 29, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment