private @CheckForNull DetectorFactory findFirstMatchingFactory(FactoryChooser chooser) { for (DetectorFactory factory : getDetectorFactories()) { if (chooser.choose(factory)) { return factory; } } return null; }
/** * Enable or disable all known Detectors. * * @param enable * true if all detectors should be enabled, false if they should * all be disabled */ public void enableAllDetectors(boolean enable) { detectorEnablementMap.clear(); Collection<Plugin> allPlugins = Plugin.getAllPlugins(); for (Plugin plugin : allPlugins) { for (DetectorFactory factory : plugin.getDetectorFactories()) { detectorEnablementMap.put(factory.getShortName(), enable); } } }
private static int findRankUnknownPlugin(BugPattern pattern) { List<BugRanker> rankers = new ArrayList<>(); pluginLoop: for (Plugin plugin : Plugin.getAllPlugins()) { if (plugin.isCorePlugin()) { continue; } if (false) { rankers.add(plugin.getBugRanker()); continue pluginLoop; } for (DetectorFactory df : plugin.getDetectorFactories()) { if (df.getReportedBugPatterns().contains(pattern)) { if (PLUGIN_DEBUG) { System.out.println("Bug rank match " + plugin + " " + df + " for " + pattern); } rankers.add(plugin.getBugRanker()); continue pluginLoop; } } if (PLUGIN_DEBUG) { System.out.println("plugin " + plugin + " doesn't match " + pattern); } } rankers.add(getCoreRanker()); return rankBugPattern(pattern, rankers.toArray(new BugRanker[rankers.size()])); }
/** * Add a Plugin whose Detectors should be added to the execution plan. */ public void addPlugin(Plugin plugin) throws OrderingConstraintException { if (DEBUG) { System.out.println("Adding plugin " + plugin.getPluginId() + " to execution plan"); } pluginList.add(plugin); // Add ordering constraints copyTo(plugin.interPassConstraintIterator(), interPassConstraintList); copyTo(plugin.intraPassConstraintIterator(), intraPassConstraintList); // Add detector factories for (DetectorFactory factory : plugin.getDetectorFactories()) { if (DEBUG) { System.out.println(" Detector factory " + factory.getShortName()); } if (factoryMap.put(factory.getFullName(), factory) != null) { throw new OrderingConstraintException("Detector " + factory.getFullName() + " is defined by more than one plugin"); } } }
for (DetectorFactory factory : plugin.getDetectorFactories()) { LOG.info(" detector {}", factory.getShortName());
void unLoadPlugin(Plugin plugin) { pluginByIdMap.remove(plugin.getPluginId()); setGlobalOptions(); for (DetectorFactory factory : plugin.getDetectorFactories()) { unRegisterDetector(factory); } for (BugCategory bugCategory : plugin.getBugCategories()) { unRegisterBugCategory(bugCategory); } for (BugPattern bugPattern : plugin.getBugPatterns()) { unRegisterBugPattern(bugPattern); } for (BugCode bugCode : plugin.getBugCodes()) { unRegisterBugCode(bugCode); } }
void loadPlugin(Plugin plugin) { if (FindBugs.DEBUG) { System.out.println("Loading " + plugin.getPluginId()); } pluginByIdMap.put(plugin.getPluginId(), plugin); setGlobalOptions(); // Register all of the detectors that this plugin contains for (DetectorFactory factory : plugin.getDetectorFactories()) { registerDetector(factory); } for (BugCategory bugCategory : plugin.getBugCategories()) { registerBugCategory(bugCategory); } // Register the BugPatterns for (BugPattern bugPattern : plugin.getBugPatterns()) { registerBugPattern(bugPattern); } // Register the BugCodes for (BugCode bugCode : plugin.getBugCodes()) { registerBugCode(bugCode); } }
fakePlugin.addDetectorFactory(detectorFactory); dfc.registerDetector(detectorFactory); if (!dfc.factoryIterator().hasNext() || fakePlugin.getDetectorFactories().isEmpty()) { throw new IllegalStateException();
private @CheckForNull DetectorFactory findFirstMatchingFactory(FactoryChooser chooser) { for (DetectorFactory factory : getDetectorFactories()) { if (chooser.choose(factory)) { return factory; } } return null; }
/** * Enable or disable all known Detectors. * * @param enable * true if all detectors should be enabled, false if they should * all be disabled */ public void enableAllDetectors(boolean enable) { detectorEnablementMap.clear(); Collection<Plugin> allPlugins = Plugin.getAllPlugins(); for (Plugin plugin : allPlugins) { for (DetectorFactory factory : plugin.getDetectorFactories()) { detectorEnablementMap.put(factory.getShortName(), enable); } } }
private static int findRankUnknownPlugin(BugPattern pattern) { List<BugRanker> rankers = new ArrayList<BugRanker>(); pluginLoop: for (Plugin plugin : Plugin.getAllPlugins()) { if (plugin.isCorePlugin()) { continue; } if (false) { rankers.add(plugin.getBugRanker()); continue pluginLoop; } for (DetectorFactory df : plugin.getDetectorFactories()) { if (df.getReportedBugPatterns().contains(pattern)) { if (PLUGIN_DEBUG) { System.out.println("Bug rank match " + plugin + " " + df + " for " + pattern); } rankers.add(plugin.getBugRanker()); continue pluginLoop; } } if (PLUGIN_DEBUG) { System.out.println("plugin " + plugin + " doesn't match " + pattern); } } rankers.add(getCoreRanker()); return rankBugPattern(pattern, rankers.toArray(new BugRanker[rankers.size()])); }
/** * Add a Plugin whose Detectors should be added to the execution plan. */ public void addPlugin(Plugin plugin) throws OrderingConstraintException { if (DEBUG) { System.out.println("Adding plugin " + plugin.getPluginId() + " to execution plan"); } pluginList.add(plugin); // Add ordering constraints copyTo(plugin.interPassConstraintIterator(), interPassConstraintList); copyTo(plugin.intraPassConstraintIterator(), intraPassConstraintList); // Add detector factories for (DetectorFactory factory : plugin.getDetectorFactories()) { if (DEBUG) { System.out.println(" Detector factory " + factory.getShortName()); } if (factoryMap.put(factory.getFullName(), factory) != null) { throw new OrderingConstraintException("Detector " + factory.getFullName() + " is defined by more than one plugin"); } } }
System.out.printf(" %s%n", cloudPlugin.getDescription()); for (DetectorFactory factory : plugin.getDetectorFactories()) { System.out.printf(" detector %s%n", factory.getShortName());
void loadPlugin(Plugin plugin) { if (FindBugs.DEBUG) { System.out.println("Loading " + plugin.getPluginId()); } pluginByIdMap.put(plugin.getPluginId(), plugin); setGlobalOptions(); // Register all of the detectors that this plugin contains for (DetectorFactory factory : plugin.getDetectorFactories()) { registerDetector(factory); } for (BugCategory bugCategory : plugin.getBugCategories()) { registerBugCategory(bugCategory); } // Register the BugPatterns for (BugPattern bugPattern : plugin.getBugPatterns()) { registerBugPattern(bugPattern); } // Register the BugCodes for (BugCode bugCode : plugin.getBugCodes()) { registerBugCode(bugCode); } for (CloudPlugin cloud : plugin.getCloudPlugins()) { registerCloud(cloud); } }
void unLoadPlugin(Plugin plugin) { pluginByIdMap.remove(plugin.getPluginId()); setGlobalOptions(); for (DetectorFactory factory : plugin.getDetectorFactories()) { unRegisterDetector(factory); } for (BugCategory bugCategory : plugin.getBugCategories()) { unRegisterBugCategory(bugCategory); } for (BugPattern bugPattern : plugin.getBugPatterns()) { unRegisterBugPattern(bugPattern); } for (BugCode bugCode : plugin.getBugCodes()) { unRegisterBugCode(bugCode); } for (CloudPlugin cloud : plugin.getCloudPlugins()) { unRegisterCloud(cloud); } }