typetools / checker-framework

Pluggable type-checking for Java
http://checkerframework.org/
Other
1.02k stars 355 forks source link

Need to we have unique checker: prefix for suppressions to differentiate from checkstyle: #5193

Open andrejusc opened 2 years ago

andrejusc commented 2 years ago

For a Java project, which uses both Checkstyle and Checkers Framework, there is a need for ease of maintenance and gradual code quality improvements to differentiate in easy way which Suppressions belong to which part.

For checkstyle example is such identifiable by "checkstyle:" prefix:

@SuppressWarnings("checkstyle:RecordComponentNumber")

For Checkers FW (without usage of -ArequirePrefixInWarningSuppressions flag) is such:

@SuppressWarnings("argument")

and so for Checkers FW would like to have some dedicated flag like:

-AglobalPrefixInWarningSuppressions="checker:"

and/or have that by default to be handled by Checkers FW if specified inside @SuppressWarnings clause.

mernst commented 2 years ago

Each checker in the Checker Framework already has a unique prefix, such as "nullness:" or "resourceleak:". See https://checkerframework.org/manual/#suppresswarnings-annotation-syntax . You can use "allcheckers:" to mean all checkers, though -- for the reasons you noted -- it can be more informative to use a checker-specific prefix.

andrejusc commented 2 years ago

@mernst - maybe I didn't explain my ask clearly enough. What I want/need to have is such:

@SuppressWarnings("checker:nullness:assignment")

So instead of grepping code for nullness: prefix as one of many possible checkers related things - I could grep for global "checker:" prefix and know that every other things after that is Checkers related.

How to achieve that?

mernst commented 2 years ago

What you are requesting is currently not possible. You could submit a patch to enable it, though we generally try not to add features that are not needed by multiple users.

Another alternative would be to put the tag you desire in a comment, like so:

@SuppressWarnings("nullness:assignment")  // Checker Framework

That would enable the grep you want, without the need to change the warning suppression key.

andrejusc commented 2 years ago

@mernst - to this your point: "What you are requesting is currently not possible." - this issue is essentially Enh./Feature request and that is why I was suggesting to have extra argument, so could be potentially introduced in not so hard way.

I'd like to avoid extra commenting needed in source code just to depict some warnings' "namespace".

mernst commented 1 year ago

I'm going to close this issue for now. As I mentioned, we are open to a pull request if you would like to contribute an implementation of this feature.