Java Code Examples for edu.umd.cs.findbugs.BugInstance#addClass()
The following examples show how to use
edu.umd.cs.findbugs.BugInstance#addClass() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spotbugs File: HugeSharedStringConstants.java License: GNU Lesser General Public License v2.1 | 5 votes |
@Override public void report() { for (Map.Entry<String, SortedSet<String>> e : map.entrySet()) { Set<String> occursIn = e.getValue(); if (occursIn.size() == 1) { continue; } XField field = definition.get(e.getKey()); if (field == null) { continue; } Integer length = stringSize.get(e.getKey()); int overhead = length * (occursIn.size() - 1); if (overhead < 3 * SIZE_OF_HUGE_CONSTANT) { continue; } String className = field.getClassName(); BugInstance bug = new BugInstance(this, "HSC_HUGE_SHARED_STRING_CONSTANT", overhead > 20 * SIZE_OF_HUGE_CONSTANT ? HIGH_PRIORITY : (overhead > 8 * SIZE_OF_HUGE_CONSTANT ? NORMAL_PRIORITY : LOW_PRIORITY)).addClass(className) .addField(field).addInt(length).addInt(occursIn.size()).describe(IntAnnotation.INT_OCCURRENCES); for (String c : occursIn) { if (!c.equals(className)) { bug.addClass(c); } } bugReporter.reportBug(bug); } }
Example 2
Source Project: spotbugs File: CheckExpectedWarnings.java License: GNU Lesser General Public License v2.1 | 5 votes |
public BugInstance makeWarning(String bugPattern, Object descriptor, int priority, ClassDescriptor cd) { BugInstance bug = new BugInstance(this, bugPattern, priority).addClass(cd); if (descriptor instanceof FieldDescriptor) { bug.addField((FieldDescriptor) descriptor); } else if (descriptor instanceof MethodDescriptor) { bug.addMethod((MethodDescriptor) descriptor); } else if (descriptor instanceof ClassDescriptor) { bug.addClass((ClassDescriptor) descriptor); } if (DEBUG) { System.out.println("Reporting " + bug); } return bug; }
Example 3
Source Project: spotbugs File: FindCircularDependencies.java License: GNU Lesser General Public License v2.1 | 5 votes |
@Override public void report() { removeDependencyLeaves(dependencyGraph); LoopFinder lf = new LoopFinder(); while (dependencyGraph.size() > 0) { String clsName = dependencyGraph.keySet().iterator().next(); Set<String> loop = lf.findLoop(dependencyGraph, clsName); boolean pruneLeaves; if (loop != null) { BugInstance bug = new BugInstance(this, "CD_CIRCULAR_DEPENDENCY", NORMAL_PRIORITY); for (String loopCls : loop) { bug.addClass(loopCls); } bugReporter.reportBug(bug); pruneLeaves = removeLoopLinks(dependencyGraph, loop); } else { dependencyGraph.remove(clsName); pruneLeaves = true; } if (pruneLeaves) { removeDependencyLeaves(dependencyGraph); } } dependencyGraph.clear(); }