Bug 392045 - Please add support for file with additional values for @SuppressWarnings()
Summary: Please add support for file with additional values for @SuppressWarnings()
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7.2   Edit
Hardware: All All
: P3 normal with 35 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact: Jay Arthanareeswaran CLA
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-16 06:23 EDT by Aaron Digulla CLA
Modified: 2023-06-27 11:06 EDT (History)
20 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aaron Digulla CLA 2012-10-16 06:23:17 EDT
Currently, the project settings just allow me to warn or ignore when the compiler encounters an unknown string value in java.lang.SuppressWarnings.

Please add an option to supply a file where I can specify additional valid values which the compiler should accept.

Example:

# Known PMD warnings
PMD.CloseResource
PMD.UselessOverridingMethod

AFAIK, PMD is currently the only tool which uses the @SuppressWarnings annotation but for future compatibility, it might be good to either have a way to specify several of these files or to have an "include" syntax.
Comment 1 Sébastien Laoût CLA 2016-03-23 04:49:25 EDT
Hello,

Checkstyle also use this annotation.

This is becoming quite annoying because on every website, they tell us to completely disable the "Unsupported @SuppressWarnings" warning!
This is defeating the feature.

For instance:
http://stackoverflow.com/questions/5017569/unsupported-suppresswarnings-pmd-donotcallsystemexit

It would be cool, instead of a user-filled text file, that:

1) either each plugin can use an extension point to inject their own list of known warnings

2) or better, each plugin can use an extension point to register a callback, and Eclipse would call this method:
boolean isKnownWarning(String warningId)
For Eclipse to throw "Unsupported @SuppressWarnings("unknown")"

3) or even better, same as solution 2 + a second callback to check if the warning is necessary or not:
boolean isWarningNecessary(String warningId, Project project, JavaThing classMethodOrVariable)
So that Eclipse can ALSO throw an "Unnecessary @SuppressWarnings("checkstyle:javadocmethod")" if there would be no "checkstyle:javadocmethod" in the given class, method or variable, or if Checkstyle is disabled for that project...

Best regards,
Sébastien Laoût.
Comment 2 Sébastien Laoût CLA 2016-03-23 04:52:55 EDT
Android Studio also used this feature:
http://stackoverflow.com/questions/25870418/unsupported-suppresswarnings-clonedoesntcallsuperclone-fieldcanbelocal-objecta

I know Android Studio is not based on Eclipse anymore, but it's a hint at potential other uses of the plugin extension point.
Comment 3 Sébastien Laoût CLA 2016-03-23 05:02:14 EDT
One last comment, and I wont SPAM you anymore ;-)

Here is a list of plugins I found on Internet, that would also profit from the extension point:

UCDetector:
https://sourceforge.net/p/ucdetector/discussion/791296/thread/a78ef693/

JBIDE (whatever this tool is...):
https://issues.jboss.org/browse/JBIDE-10187

SQUID: @SuppressWarnings("squid:xxxx")
http://sonarqube-archive.15.x6.nabble.com/Removing-Eclipse-Warnings-for-SuppressWarnings-quot-squid-XXX-quot-td5032976.html

To avoid the problem, FindBugs went so far to use their own SuppressWarnings in their own package (quite misleading!):
edu.umd.cs.findbugs.annotations.SuppressWarnings("SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE")
http://comments.gmane.org/gmane.comp.java.findbugs.general/2578
Comment 4 Nobody - feel free to take it CLA 2016-03-31 06:53:15 EDT
(In reply to Sébastien Laoût from comment #3)
> One last comment, and I wont SPAM you anymore ;-)
> 
> Here is a list of plugins I found on Internet, that would also profit from
> the extension point:
> 
> UCDetector:
> https://sourceforge.net/p/ucdetector/discussion/791296/thread/a78ef693/
> 
> JBIDE (whatever this tool is...):
> https://issues.jboss.org/browse/JBIDE-10187
> 
> SQUID: @SuppressWarnings("squid:xxxx")
> http://sonarqube-archive.15.x6.nabble.com/Removing-Eclipse-Warnings-for-
> SuppressWarnings-quot-squid-XXX-quot-td5032976.html
> 
> To avoid the problem, FindBugs went so far to use their own SuppressWarnings
> in their own package (quite misleading!):
> edu.umd.cs.findbugs.annotations.
> SuppressWarnings("SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE")
> http://comments.gmane.org/gmane.comp.java.findbugs.general/2578

The Checker Framework also uses @SuppressWarnings http://types.cs.washington.edu/checker-framework/tutorial/webpages/security-error-eclipse.html
Comment 5 David Pursehouse CLA 2018-09-04 20:25:18 EDT
ErrorProne also recommends using @SuppressWarnings and this can result in the "Unsupported @SuppressWarnings" warning in Eclipse.

See for example https://errorprone.info/bugpattern/FutureReturnValueIgnored
Comment 6 Darko Palic CLA 2018-09-08 12:22:17 EDT
Any updates on this feature?

Also if some persons will be found to contribute, will it be included in the mainstream?
Could someone from the core team answer the question, so we can maybe fix it on our own?
Comment 7 Ian Robertson CLA 2019-03-10 19:00:34 EDT
Another possibility to consider would be to not warn about an unsupported warning token when the token in question is not actually causing a warning to be supressed. I assume this warning is provided to warn about possible typos; presumably if the term matches something, its unlikely to be a typo.
Comment 8 Jay Arthanareeswaran CLA 2019-03-11 08:02:28 EDT
(In reply to Darko Palic from comment #6)
> Any updates on this feature?
> 
> Also if some persons will be found to contribute, will it be included in the
> mainstream?
> Could someone from the core team answer the question, so we can maybe fix it
> on our own?

Yes, that'll be nice.
Comment 9 Robert Lechner CLA 2019-06-14 03:24:32 EDT
See also bug 122475
Comment 10 Eclipse Genie CLA 2023-02-24 07:08:25 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.