-
Notifications
You must be signed in to change notification settings - Fork 36
Allow to set severity per signature #253
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
Allow to set severity per signature #253
Conversation
2a210f3
to
b66a66b
Compare
@uschindler I don't know enough about Gradle to add that functionality there as well. Is it acceptable to only allow that parametrisation from Maven for now? |
I have not checked this at all. You also need to add the command line settings. Gradle is as simple as Maven. Just add getters and setters like in Maven or Ant. |
b66a66b
to
9bfc24c
Compare
9bfc24c
to
962dcdb
Compare
@uschindler Any chance to include this in a release? |
Oh haven't seen that you updated it for Gradle.... Will need to review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. I like that we now have finally a SuppressionResult. All the methods returning String was a bit of desaster. I wanted to change this since long time, but it was too much work. But you took care of it. Thanks!
There is a small incompatibility with Java 7 (the current minimum version), I will fix it! (Map#getOrDefault()
is missing).
|
||
|
||
private ViolationSeverity getSeverityForKey(String key) { | ||
return severityPerSignature.getOrDefault(key, failOnViolation ? ViolationSeverity.ERROR : ViolationSeverity.WARNING); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getOrDefault does not exist in Java 7, which is still minimum version. Will fix this later.
This is the compile failure with Java 7:
|
This commit fixes the Java 7 problem: 2a91113 I will do some further checks and adjust. This is a good first step. Thanks! |
I have to fix the ant task because it only allows to set supressed signature one (via attribute), but to set multiple ones. For it to work there needs to be a subelement for this, e.g. look at this: https://github.com/policeman-tools/forbidden-apis/blob/main/src/main/java/de/thetaphi/forbiddenapis/ant/BundledSignaturesType.java Of course documentation needs update, too. |
Hi @kwin, Ant was changed to add the severityOverride using subelements: <forbiddenapis classpathref="path.all" targetVersion="${jdk.version}">
<fileset refid="main.classes"/>
<bundledSignatures name="jdk-unsafe"/>
java.util.Locale#ENGLISH @ We are speaking chinese here!
java.lang.** @ You are crazy that you disallow all java.lang
java.io.** @ You are crazy that you disallow all java.io
<severityOverride severity="warning">java.util.Locale#ENGLISH</severityOverride>
<severityOverride severity="debug">
java.lang.**
java.io.**
</severityOverride>
</forbiddenapis> I will have a separate look at Gradle, too. Gradle is also more flexible, so it might be better to set the priority using a "map" like structure there, too. Gradle is not limited to simple setters, you can call all the methods provided by the task. So separating into the 2 lists of sigantures is not ideal. If I do not have a better idea, I'd like to release 3.9 soon. People are waiting already. Can you just have a quick look on the PR? |
I marked the new API/setting with |
This closes #252 and #219