-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Generic/DisallowTabIndent: multi line comments + error message/code fix #1607
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
Generic/DisallowTabIndent: multi line comments + error message/code fix #1607
Conversation
As a side-note (not covered by this PR), I believe that the "nonIndentTab" part (i.e. tabs found for mid-line alignment or in comment texts) should not be covered by this sniff, as:
For WPCS, I actually created a separate sniff to address "no tabs for mid-line alignment", while tabs are enforced for indentation (via the |
a649790
to
0936533
Compare
Rebased for merge conflicts & updated to allow for the changes made related to #1702 |
The "TabsUsed" error message and code were only set before the loop and not reset within the loop. In practice this meant that as soon as the first non-indent error is encountered, the `$error` and `$errorCode` would be overruled and for any indent errors found after that, the wrong message and error code would be thrown.
0936533
to
939b48a
Compare
Rebased for merge conflicts & code style... |
Thanks for pointing me here, and thanks for the PR. |
You're welcome & glad to help. |
Sister-PR to #1599.
Use the correct error message and code
The "TabsUsed" error message and code were only set before the loop and not reset within the loop.
In practice this meant that as soon as the first non-indent error is encountered, the
$error
and$errorCode
would be overruled and for any indent errors found after that, the wrong message and error code would be thrown.Allow the sniff to fix tab indents for multi-line /* */ comments
This is the same as done in #1599 for the DisallowSpaceIndent sniff.
Metrics
I also noticed that the metrics were not in line with how they are being recorded in the other sniff as the improvements which were previously added there in #1404 were not yet applied here, quite apart from the metrics needing some love for the
/* */
comment.So I've fixed that too.
For in-depth details of the effect on the metrics of this fix, please see: https://gist.github.com/jrfnl/9a5824916969dc6cf27a24d750d78319
While the metrics for both sniffs are now better than they were before and more in line with each other, there is still a difference between them.The indentation metrics created by theDisallowSpaceIndentSniff
are probably best to use for the historic metrics overviews as - except for comments - theDisallowTabIndentSniff
will report "mixed" when it encounters tab indents combined with precision spacing, while theDisallowSpaceIndentSniff
can distinguish between the precision spacing and non-precision spacing and will adjust the metrics accordingly.[Edit] By combining the improvements I'd already made with @gsherwood's improvements in bbe55a5 and 2aa0e09, the metrics should now be quite similar for both sniffs, though I haven't ran any checks to verify.