error-prone-support
error-prone-support copied to clipboard
It should be possible to change a severity level per rule
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
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.)
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.
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?
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\$).*
)
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 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!
That does the trick @Stephan202. Thanks @Stephan202 and @rickie for all your hard work and open sourcing the rules.