-
Notifications
You must be signed in to change notification settings - Fork 629
Description
Follow up on #3307
The NoteSuppressedWarnings
detector which is a NonReportingDetector
reports now warnings.
This is inconsistent, and as every inconsistency this has side effects.
In Eclipse we used BugInstance.getDetectorFactory()
to retrieve information about the spotbugs plugin that contributes this detector, and if not available (which is the case for NonReportingDetector
), we were trying to scan the DetectorFactory for the matching bug patterns. However, we've restricted that to only factories which match to
DetectorFactory.isReportingDetector()condition. Again, this is not the case for
NonReportingDetector`:
spotbugs/eclipsePlugin/src/de/tobject/findbugs/reporter/MarkerReporter.java
Lines 203 to 218 in b5c7686
DetectorFactory detectorFactory = mp.bug.getDetectorFactory(); | |
if (detectorFactory != null) { | |
String pluginId = detectorFactory.getPlugin().getPluginId(); | |
if (pluginId != null) { | |
attributes.put(DETECTOR_PLUGIN_ID, pluginId); | |
} | |
} else { | |
// Fix for loading bugs from XML: they do not have detector factory set, so we guess one | |
BugPattern pattern = mp.bug.getBugPattern(); | |
Iterator<DetectorFactory> fit = DetectorFactoryCollection.instance().factoryIterator(); | |
while (fit.hasNext()) { | |
DetectorFactory df2 = fit.next(); | |
if (!df2.isReportingDetector()) { | |
continue; | |
} | |
Set<BugPattern> patterns = df2.getReportedBugPatterns(); |
We can add a workaround in Eclipse plugin like below, but it would be better if either the bug instances would have the factory added or the NoteSuppressedWarnings
would be a reporting detector. Later seem to be a problem as the comment says it has to be executed before all "reporting" detectors and so simply removing implements NonReportingDetector
from it causes a cycle & analysis crash.
diff --git a/eclipsePlugin/src/de/tobject/findbugs/reporter/MarkerReporter.java b/eclipsePlugin/src/de/tobject/findbugs/reporter/MarkerReporter.java
index 70259a2..e006d6c 100644
--- a/eclipsePlugin/src/de/tobject/findbugs/reporter/MarkerReporter.java
+++ b/eclipsePlugin/src/de/tobject/findbugs/reporter/MarkerReporter.java
@@ -59,2 +59,3 @@
import edu.umd.cs.findbugs.config.UserPreferences;
+import edu.umd.cs.findbugs.detect.NoteSuppressedWarnings;
@@ -215,3 +216,6 @@
if (!df2.isReportingDetector()) {
- continue;
+ // NoteSuppressedWarnings reports bugs even if it says it doesn't ...
+ if (!NoteSuppressedWarnings.class.getName().equals(df2.getFullName())) {
+ continue;
+ }
}
@gtoison : would be nice if you could look at it.