-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Do not suppress warnings in PHP_CodeSniffer reports #3287
Do not suppress warnings in PHP_CodeSniffer reports #3287
Conversation
Hmm, interesting gotcha, but I wouldn't say it's a configuration issue per se. I'd instead prefer different approach: leverage the warnings we are considering strict part of our CS into errors, like this: <rule ref="PSR2.Methods.MethodDeclaration.Underscore">
<type>error</type>
</rule> |
@Majkl578 IMO both approaches are valid and mutually complementary. If by default a warning doesn't fail the build (not sure if that's the case), it still should be possible to refer to the log which would not suppress warnings. E.g., a line length violation is a warning. Maybe it shouldn't force developers to fix it by any means (e.g. by slicing a long string literal) but if it's an expression which can be reformatted into multiple lines, the code style report should encourage doing so by showing warnings. |
It does fail (exit code 1) unless you specify an option: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options#ignoring-warnings-when-generating-the-exit-code |
Hm… maybe we should use this option? Not all warnings can be fixed w/o crippling the code or adding annotations (both is undesired). Or let's just enable the warnings first and see how annoying they turn out to be. Suppression is a no-go in any event. |
This is already done by having the build fail in case of a warning. There's a reason to not promote "MethodDeclaration.Underscore" to an error. Semantically, an error is what you must fix while a warning is what you should fix if it's possible (my own interpretation). If there's an existing protected method with an underscore which you override, there's no way to not introduce this error in code which adds or modifies the line with the overriding method. And it doesn't seem to be going to change according to #3007 (comment) (which I don't completely agree with). |
I don't think it's a good idea. Some warnings are just annoying and if we don't enforce them, what's the point of having/seeing them?
This is also true for our other sniffs that throw errors, i.e.
This is how annoying it would be in ORM: https://gist.github.com/Majkl578/afcd89f4501c56ea5866142be6d0675c I also disagree with #3007 (comment) btw. |
The point is seeing violations and fixing or asking contributors to fix at least those which is possible. And having a better readable codebase in the end result. Look at #3217 (comment), this is how much frustration it causes to explain the need of a change if the code violation is not flagged by CI and figuring out why that is.
How many of them are not fixable? Given our incremental approach, how often will non-fixable violations be introduced or touched? Personally, I find it more annoying to have to scroll horizontally or resize my editor window to accommodate long lines — that's what the requirement is for in the first place.
I don't know what those sniffs are since I haven't even seen their errors in DBAL because of suppression. Maybe if you provide some more examples, they could help me see your point better. |
@Majkl578, ping. Why don’t we enable warnings and then adjust the standard if it turns out some rules don’t bring value? |
5c3bb5f
to
1f7473e
Compare
1f7473e
to
be33515
Compare
4e02108
to
85a9c00
Compare
85a9c00
to
1f51d2a
Compare
The polyfill would cause a PSR1.Files.SideEffects.FoundWithSymbols warning.
1f51d2a
to
4ee9690
Compare
Suppressed warnings confuse contributors since the report doesn't contain all violations which a pull request may contain.
See #3217 (comment) for the reference.