error-prone-support icon indicating copy to clipboard operation
error-prone-support copied to clipboard

It should be possible to change a severity level per rule

Open vprudnikov opened this issue 1 year ago • 7 comments

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

vprudnikov avatar Jun 01 '23 13:06 vprudnikov

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

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

Stephan202 avatar Jun 02 '23 04:06 Stephan202

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.

vprudnikov avatar Jun 02 '23 07:06 vprudnikov

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?

jai-ramakrishnan avatar Feb 12 '24 15:02 jai-ramakrishnan

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\$).*)

Stephan202 avatar Feb 12 '24 17:02 Stephan202

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.

jai-ramakrishnan avatar Feb 12 '24 22:02 jai-ramakrishnan

@jai-ramakrishnan it's not you, it's me :facepalm:. 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!

Stephan202 avatar Feb 13 '24 04:02 Stephan202

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

jai-ramakrishnan avatar Feb 13 '24 09:02 jai-ramakrishnan