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

Do not suppress warnings in PHP_CodeSniffer reports #3287

Merged
merged 8 commits into from
Jul 25, 2020

Conversation

morozov
Copy link
Member

@morozov morozov commented Sep 12, 2018

Suppressed warnings confuse contributors since the report doesn't contain all violations which a pull request may contain.

Q A
Type improvement
BC Break no

See #3217 (comment) for the reference.

@Majkl578
Copy link
Contributor

Majkl578 commented Sep 12, 2018

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>

@morozov
Copy link
Member Author

morozov commented Sep 12, 2018

@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.

@Majkl578
Copy link
Contributor

@morozov
Copy link
Member Author

morozov commented Sep 12, 2018

It does fail (exit code 1) unless you specify an option

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.

@morozov
Copy link
Member Author

morozov commented Sep 12, 2018

I'd instead prefer different approach: leverage the warnings we are considering strict part of our CS into errors […]

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).

@Majkl578
Copy link
Contributor

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?

Not all warnings can be fixed w/o crippling the code or adding annotations (both is undesired).

This is also true for our other sniffs that throw errors, i.e. declare(), parameter/return types, naming conventions etc.

Or let's just enable the warnings first and see how annoying they turn out to be.

This is how annoying it would be in ORM: https://gist.github.com/Majkl578/afcd89f4501c56ea5866142be6d0675c

I also disagree with #3007 (comment) btw.

@morozov
Copy link
Member Author

morozov commented Sep 14, 2018

Some warnings are just annoying and if we don't enforce them, what's the point of having/seeing them?

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.

This is how annoying it would be in ORM: https://gist.github.com/Majkl578/afcd89f4501c56ea5866142be6d0675c

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.

This is also true for our other sniffs that throw errors, i.e. declare(), parameter/return types, naming conventions etc.

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.

@morozov
Copy link
Member Author

morozov commented Sep 16, 2018

@Majkl578, ping. Why don’t we enable warnings and then adjust the standard if it turns out some rules don’t bring value?

@morozov morozov closed this Oct 8, 2018
@morozov morozov deleted the dont-suppress-phpcs-warnings branch October 8, 2018 01:50
@morozov morozov mentioned this pull request Nov 12, 2018
2 tasks
@morozov morozov restored the dont-suppress-phpcs-warnings branch July 24, 2020 17:11
@morozov morozov reopened this Jul 24, 2020
@morozov morozov changed the base branch from master to 2.10.x July 24, 2020 17:12
@morozov morozov force-pushed the dont-suppress-phpcs-warnings branch from 5c3bb5f to 1f7473e Compare July 24, 2020 17:13
@morozov morozov force-pushed the dont-suppress-phpcs-warnings branch from 1f7473e to be33515 Compare July 24, 2020 19:59
@morozov morozov force-pushed the dont-suppress-phpcs-warnings branch 3 times, most recently from 4e02108 to 85a9c00 Compare July 25, 2020 01:45
@morozov morozov requested review from greg0ire and removed request for Majkl578 July 25, 2020 02:08
@morozov morozov force-pushed the dont-suppress-phpcs-warnings branch from 85a9c00 to 1f51d2a Compare July 25, 2020 14:37
@morozov morozov force-pushed the dont-suppress-phpcs-warnings branch from 1f51d2a to 4ee9690 Compare July 25, 2020 15:33
@morozov morozov merged commit 217b2cf into doctrine:2.10.x Jul 25, 2020
@morozov morozov deleted the dont-suppress-phpcs-warnings branch July 25, 2020 15:47
@morozov morozov added this to the 2.10.3 milestone Jul 25, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants