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

It should be possible to change a severity level per rule #655

Open
1 task
vprudnikov opened this issue Jun 1, 2023 · 7 comments
Open
1 task

It should be possible to change a severity level per rule #655

vprudnikov opened this issue Jun 1, 2023 · 7 comments

Comments

@vprudnikov
Copy link

vprudnikov commented Jun 1, 2023

Problem

I would like to make some suggestions required for my team by changing the default severity level for them.

Description of the proposed new feature

  • Avoid a common gotcha, or potential problem.

It would be nice to provide a compiler argument that changes the severity for one rule, for example:
-XepOpt:Refaster:StreamRules:StreamMapFirst:ERROR

@Stephan202
Copy link
Member

Thanks @vprudnikov; this is a nice idea. We'll have to assess which flag/config format works best, but technically this looks very doable 👍.

(Before making a decision on the flag support we should perhaps assess to what extent repeated flags can be supported, as that may influence the design space.)

@vprudnikov
Copy link
Author

thanks @Stephan202! I admit that my example is not that good, however, I hope it outlines the idea :)
And I agree that it would be less confusing if I could repeat the same flag as many times as I want.

@jai-ramakrishnan
Copy link

I am trying to disable all checks and selectively turn on Raster rules 1 at a time. So passing -XepDisableAllChecks takes care of the former. Now I need to enable say all NullRules https://error-prone.picnic.tech/refasterrules/NullRules/
Is there a way to achieve that with the current setup?

@Stephan202
Copy link
Member

Hey @jai-ramakrishnan! For this you'd add -Xep:Refaster:OFF -XepOpt:Refaster:NamePattern=^NullRules\$.*

(The latter flag is a regex, so later you could e.g. do -XepOpt:Refaster:NamePattern=^(MapRules|NullRules)\$.*. Once you're ready to enable all-but-some rules, you can instead start listing the rules to exclude. E.g. using -XepOpt:Refaster:NamePattern=^(?!XRules\$)(?!YRules\$).*)

@jai-ramakrishnan
Copy link

Thanks a bunch @Stephan202. I can get it working partially with the negate pattern.

The combination of -XepDisableAllChecks -Xep:Refaster:OFF -XepOpt:Refaster:NamePattern=^NullRules\$.* -Xep:UnnecessaryParentheses:ERROR does not produce any warning/error in the build. However, if I remove the flag -XepDisableAllChecks and add -XepAllErrorsAsWarnings then the NullRules come into play and produce the desired warnings. Am I missing something obvious? I am using 0.14.0 error-prone-support and refaster-runner.

@Stephan202
Copy link
Member

@jai-ramakrishnan it's not you, it's me 🤦. I wrote -Xep:Refaster:OFF, but of course that should be -Xep:Refaster:ERROR or -Xep:Refaster:WARN. Copy-paste error; sorry!

Thanks for trying Error Prone Support!

@jai-ramakrishnan
Copy link

That does the trick @Stephan202. Thanks @Stephan202 and @rickie for all your hard work and open sourcing the rules.

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

No branches or pull requests

3 participants