Skip to content

Squiz/InlineComment: fix fixer conflict when comment found at end of function #1710

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

Merged

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Oct 15, 2017

Came across this error when running fixer conflict checks for the various standards. (See #1645 (comment) )
Fourth fix in a series to fix the issues found.

When an inline comment is found at the end of a function, removing a blank line after it conflicts with the Squiz.WhiteSpace.FunctionClosingBraceSpace sniff which demands a blank line at the end of a function.

To reproduce the issue, run (against master):
phpcbf -p -s --standard=Squiz ./src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.inc -vv

I have chosen to fix this by adding a specific error code for that situation and excluding that error code from the Squiz ruleset.

This way, the backward-compatibility break for other standards using the Squiz.Commenting.InlineComment sniff will be smallest.
Only if a standard explicitly in/excluded the Squiz.Commenting.InlineComment.SpacingAfter errorcode will this have any effect on them.

The unit tests already contain a test covering this. As the errorcode is excluded via the ruleset, the results of the unit tests do not change.

Fixes #1709

@jrfnl jrfnl force-pushed the feature/fix-1709-squiz-inline-comment branch 2 times, most recently from 2351657 to 327f389 Compare November 22, 2017 05:53
@jrfnl
Copy link
Contributor Author

jrfnl commented Nov 22, 2017

Rebased for merge conflicts & updated code style...

…function

When an inline comment is found at the end of a function, removing a blank line after it conflicts with the `Squiz.WhiteSpace.FunctionClosingBraceSpace` sniff which demands a blank line at the end of a function.

I have chosen to fix this by adding a specific error code for that situation and excluding that error code from the `Squiz` ruleset.

This way, the backward-compatibility break for other standards using the `Squiz.Commenting.InlineComment` sniff will be smallest.
Only if a standard explicitly in/excluded the `Squiz.Commenting.InlineComment.SpacingAfter` errorcode will this have any effect on them.

The unit tests already contain a test covering this. As the errorcode is excluded via the ruleset, the results of the unit tests do not change.

Fixes 1709
@jrfnl jrfnl force-pushed the feature/fix-1709-squiz-inline-comment branch from 2292c82 to dcd89b7 Compare December 22, 2017 00:24
@jrfnl
Copy link
Contributor Author

jrfnl commented Dec 22, 2017

Rebased (again) for merge conflicts...

@gsherwood gsherwood merged commit dcd89b7 into squizlabs:master Mar 12, 2018
gsherwood added a commit that referenced this pull request Mar 12, 2018
@gsherwood
Copy link
Member

Your solution seems like a good one to me as well. Thanks for this.

@jrfnl jrfnl deleted the feature/fix-1709-squiz-inline-comment branch March 12, 2018 02:18
@jrfnl
Copy link
Contributor Author

jrfnl commented Mar 12, 2018

You're welcome 😃

FYI: I'm just now doing a new fixer conflict run to see where we're at.

Initial findings:

  • The fixer conflict for 1 particular test file seems to have been fixed along the way.
  • 6 files with new fixer conflicts.... these may well all be related to one sniff, but I haven't dug that deep yet. I wouldn't be surprised if it has to do with the new PHPCS annotations, but need to have a detailed look to be sure.

Current status based on running phpcbf for each standard against all test case files:

  • PSR1: -- does not contain sniffs with fixers.
  • PSR2: 3 test case files result in fixer conflicts
  • PEAR: 9 test case files result in fixer conflicts
  • Squiz: 41 test case files result in fixer conflicts
  • Zend: 3 test case files result in fixer conflicts

(MySource can not be tested as the ruleset includes an <exclude-pattern> for the test directory)

PR #1813 will solve five of these.

See: https://travis-ci.org/jrfnl/PHP_CodeSniffer/builds/352204624

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.

Squiz: fixer conflict for inline comment at end of function
2 participants