/** * Get the BugCode */ public @Nonnull BugCode getBugCode() { return DetectorFactoryCollection.instance().getBugCode(abbrev); } /**
public static synchronized void removeCustomPlugin(Plugin plugin) { Set<Entry<URI, Plugin>> entrySet = Plugin.allPlugins.entrySet(); for (Entry<URI, Plugin> entry : entrySet) { if(entry.getValue() == plugin) { Plugin.allPlugins.remove(entry.getKey()); PluginLoader.loadedPluginIds.remove(plugin.getPluginId()); break; } } DetectorFactoryCollection.instance().unLoadPlugin(plugin); }
/** * Get set of all BugPatterns this detector reports. An empty set means that * we don't know what kind of bug patterns might be reported. */ public Set<BugPattern> getReportedBugPatterns() { Set<BugPattern> result = new TreeSet<>(); StringTokenizer tok = new StringTokenizer(reports, ","); while (tok.hasMoreTokens()) { String type = tok.nextToken(); BugPattern bugPattern = DetectorFactoryCollection.instance().lookupBugPattern(type); if (bugPattern != null) { result.add(bugPattern); } } return result; }
/** * Constructor. This is not meant to be called directly; use one of the * factory methods instead. */ private ProjectFilterSettings() { DetectorFactoryCollection.instance(); // ensure detectors loaded // initially all known bug categories are active // using SortedSet to allow better revision control on saved sorted // properties this.activeBugCategorySet = new TreeSet<>(DetectorFactoryCollection.instance().getBugCategories()); this.hiddenBugCategorySet = new HashSet<>(); activeBugCategorySet.remove("NOISE"); hiddenBugCategorySet.add("NOISE"); setMinRank(DEFAULT_MIN_RANK); setMinPriority(DEFAULT_PRIORITY); this.displayFalseWarnings = false; }
private void addCategoryKey(String argument) { DetectorFactoryCollection i18n = DetectorFactoryCollection.instance(); for (String x : argument.split("[,|]")) { for (BugCategory category : i18n.getBugCategoryObjects()) { if (category.getAbbrev().equals(x) || category.getCategory().equals(x)) { this.categoryKey.add(category.getCategory()); break; } } } }
/** * Get the description of a bug category. Returns the category if no * description can be found. * * @param category * the category * @return the description of the category */ public String getBugCategoryDescription(String category) { BugCategory bc = DetectorFactoryCollection.instance().getBugCategory(category); return (bc != null ? bc.getShortDescription() : category); } }
public static void main(String[] args) throws Exception { FindBugs.setNoAnalysis(); DetectorFactoryCollection.instance(); if (args.length != 2) { System.out.println(USAGE); return; } new CopyBuggySource(args).execute(); }
public @Nonnull String getShortMessageWithoutCode(String key) { BugPattern bugPattern = DetectorFactoryCollection.instance().lookupBugPattern(key); if (bugPattern == null) { return L10N.getLocalString("err.missing_pattern", "Error: missing bug pattern for key") + " " + key; } return bugPattern.getShortDescription(); }
public static @CheckForNull Plugin addCustomPlugin(URL u, ClassLoader parent) throws PluginException { PluginLoader pluginLoader = PluginLoader.getPluginLoader(u, parent, false, true); Plugin plugin = pluginLoader.loadPlugin(); if (plugin != null) { DetectorFactoryCollection.instance().loadPlugin(plugin); } return plugin; }
@Override public void finishPass() { HashSet<BugPattern> claimedReported = new HashSet<>(); for (DetectorFactory d : DetectorFactoryCollection.instance().getFactories()) { claimedReported.addAll(d.getReportedBugPatterns()); } for (BugPattern b : DetectorFactoryCollection.instance().getBugPatterns()) { String category = b.getCategory(); if (!b.isDeprecated() && !"EXPERIMENTAL".equals(category) && !claimedReported.contains(b)) { AnalysisContext.logError("No detector claims " + b.getType()); } } }
/** * Get the BugPattern. */ public @Nonnull BugPattern getBugPattern() { BugPattern result = DetectorFactoryCollection.instance().lookupBugPattern(getType()); if (result != null) { return result; } AnalysisContext.logError("Unable to find description of bug pattern " + getType()); result = DetectorFactoryCollection.instance().lookupBugPattern("UNKNOWN"); if (result != null) { return result; } return BugPattern.REALLY_UNKNOWN; }
/** * Get an HTML document describing the bug pattern for given key in detail. * * @param key * which HTML details for retrieve */ public @Nonnull String getDetailHTML(String key) { BugPattern bugPattern = DetectorFactoryCollection.instance().lookupBugPattern(key); if (bugPattern == null) { return L10N.getLocalString("err.missing_pattern", "Error: missing bug pattern for key") + " " + key; } return bugPattern.getDetailHTML(); }
public String getCategoryAbbrev() { String categoryAbbrev = null; BugCategory bcat = DetectorFactoryCollection.instance().getBugCategory(getCategory()); if (bcat != null) { categoryAbbrev = bcat.getAbbrev(); } if (categoryAbbrev == null) { categoryAbbrev = TextUIBugReporter.OTHER_CATEGORY_ABBREV; } return categoryAbbrev; }
/** * Get a short message string. This is a concrete string (not a format * pattern) which briefly describes the type of bug, without mentioning * particular a particular class/method/field. * * @param key * which short message to retrieve */ public @Nonnull String getShortMessage(String key) { BugPattern bugPattern = DetectorFactoryCollection.instance().lookupBugPattern(key); if (bugPattern == null) { return L10N.getLocalString("err.missing_pattern", "Error: missing bug pattern for key") + " " + key; } return bugPattern.getAbbrev() + ": " + bugPattern.getShortDescription(); }
public static void main(String[] argv) throws Exception { DetectorFactoryCollection detectorFactoryCollection = DetectorFactoryCollection.instance(); ExecutionPlan execPlan = new ExecutionPlan(); for (String pluginId : argv) { Plugin plugin = detectorFactoryCollection.getPluginById(pluginId); if (plugin != null) { execPlan.addPlugin(plugin); } } execPlan.build(); System.out.println(execPlan.getNumPasses() + " passes in plan"); execPlan.print(); } }
/** * @param detectorName */ public void adjustForDetector(String detectorName) { DetectorFactory factory = DetectorFactoryCollection.instance().getFactoryByClassName(detectorName); detectorFactory = factory; if (factory != null) { this.priority += factory.getPriorityAdjustment(); boundPriority(); BugPattern bugPattern = getBugPattern(); if (SystemProperties.ASSERTIONS_ENABLED && !"EXPERIMENTAL".equals(bugPattern.getCategory()) && !factory.getReportedBugPatterns().contains(bugPattern)) { AnalysisContext.logError(factory.getShortName() + " doesn't note that it reports " + bugPattern + " in category " + bugPattern.getCategory()); } } }
public static void main(String[] args) throws Exception { FindBugs.setNoAnalysis(); DetectorFactoryCollection.instance(); // load plugins SortedBugCollection bugCollection = new SortedBugCollection(); int argCount = 0; if (argCount < args.length) { bugCollection.readXML(args[argCount++]); } else { bugCollection.readXML(System.in); } new TreemapVisualization().generateTreeMap(bugCollection); } }
public static void main(String[] args) throws Exception { FindBugs.setNoAnalysis(); DetectorFactoryCollection.instance(); // load plugins RebornIssues reborn = new RebornIssues(); CommandLine commandLine = new CommandLine(); int argCount = commandLine.parse(args, 0, 2, "Usage: " + RebornIssues.class.getName() + " [options] [<xml results> [<history>]] "); SortedBugCollection bugCollection = new SortedBugCollection(); if (argCount < args.length) { bugCollection.readXML(args[argCount++]); } else { bugCollection.readXML(System.in); } reborn.setBugCollection(bugCollection); reborn.execute(); } }
@Test public void testPlainCategories() { int count = 0; for (String category : DetectorFactoryCollection.instance().getBugCategories()) { if (!category.equals("NOISE")) { Assert.assertTrue(plain.containsCategory(category)); ++count; } } Assert.assertEquals(count, plain.getActiveCategorySet().size()); }
private void addBugPatterns(Set<String> bugTypeSet) { Element root = document.getRootElement(); for (String bugType : bugTypeSet) { BugPattern bugPattern = DetectorFactoryCollection.instance().lookupBugPattern(bugType); if (bugPattern == null) { continue; } Element details = root.addElement("BugPattern"); details.addAttribute("type", bugType).addAttribute("abbrev", bugPattern.getAbbrev()) .addAttribute("category", bugPattern.getCategory()); details.addElement("ShortDescription").addText(bugPattern.getShortDescription()); details.addElement("Details").addCDATA(bugPattern.getDetailText()); } }