Package edu.umd.cs.findbugs
Class DetectorFactoryCollection
java.lang.Object
edu.umd.cs.findbugs.DetectorFactoryCollection
The DetectorFactoryCollection stores all of the DetectorFactory objects used
to create the Detectors which implement the various analyses. It is a
singleton class.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map
<String, BugPattern> protected final Map
<String, BugCategory> private Plugin
private static final boolean
private final Map
<String, DetectorFactory> private final Map
<String, DetectorFactory> private final List
<DetectorFactory> private static final Object
private static final Logger
private static DetectorFactoryCollection
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
DetectorFactoryCollection
(boolean loadCore, boolean forceLoad, Collection<Plugin> pluginsToLoad, Collection<Plugin> enabledPlugins) DetectorFactoryCollection
(Plugin onlyPlugin) protected
DetectorFactoryCollection
(Collection<Plugin> enabled) -
Method Summary
Modifier and TypeMethodDescriptionGet an Iterator over all registered bug patterns.Return an Iterator over the DetectorFactory objects for all registered Detectors.Get a Collection containing all known bug category keys.getBugCategory
(String category) Get the BugCategory object for a category key.getBugCode
(String shortBugType) Get a description for given "bug type".Get an Iterator over all registered bug patterns.static URL
getCoreResource
(String name) Return an Iterable over the DetectorFactory objects for all registered Detectors.getFactory
(String name) Look up a DetectorFactory by its short name.getFactoryByClassName
(String className) Look up a DetectorFactory by its class name.static String
getPluginById
(String pluginId) Get a Plugin by its unique id.private static String
See if the location of ${spotbugs.home} can be inferred from the location of findbugs.jar in the classpath.static DetectorFactoryCollection
instance()
Get the single instance of DetectorFactoryCollection, which knows each and every loaded plugin, independently of it's enablementboolean
isDisabledByDefault
(String bugPatternOrCode) static void
jawsDebugMessage
(String message) private void
(package private) void
loadPlugin
(Plugin plugin) lookupBugCode
(String shortBugType) lookupBugPattern
(String bugType) Look up bug pattern.Return an Iterator over all available Plugin objects.plugins()
Return an Collection of all available Plugin objects.boolean
Set the metadata for a bug category.void
registerBugCode
(BugCode bugCode) void
registerBugPattern
(BugPattern bugPattern) Register a BugPattern.(package private) void
registerDetector
(DetectorFactory factory) Register a DetectorFactory.static void
resetInstance
(DetectorFactoryCollection instance) Reset the factory singleton.private void
(package private) void
unLoadPlugin
(Plugin plugin) protected boolean
protected void
unRegisterBugCode
(BugCode bugCode) protected void
unRegisterBugPattern
(BugPattern bugPattern) (package private) void
unRegisterDetector
(DetectorFactory factory)
-
Field Details
-
LOGGER
-
DEBUG_JAWS
private static final boolean DEBUG_JAWS -
theInstance
-
lock
-
pluginByIdMap
-
corePlugin
-
factoryList
-
factoriesByName
-
factoriesByDetectorClassName
-
categoryDescriptionMap
-
bugPatternMap
-
bugCodeMap
-
globalOptions
-
globalOptionsSetter
-
-
Constructor Details
-
DetectorFactoryCollection
public DetectorFactoryCollection() -
DetectorFactoryCollection
-
DetectorFactoryCollection
-
DetectorFactoryCollection
private DetectorFactoryCollection(boolean loadCore, boolean forceLoad, @Nonnull Collection<Plugin> pluginsToLoad, @Nonnull Collection<Plugin> enabledPlugins)
-
-
Method Details
-
resetInstance
Reset the factory singleton.Implementation note: This method is public for tests only!
- Parameters:
instance
- use null to clear the instance
-
instance
Get the single instance of DetectorFactoryCollection, which knows each and every loaded plugin, independently of it's enablement -
setGlobalOptions
private void setGlobalOptions() -
pluginIterator
Return an Iterator over all available Plugin objects. -
plugins
Return an Collection of all available Plugin objects. -
getCorePlugin
-
getPluginById
Get a Plugin by its unique id.- Parameters:
pluginId
- the unique id- Returns:
- the Plugin with that id, or null if no such Plugin is found
-
factoryIterator
Return an Iterator over the DetectorFactory objects for all registered Detectors. -
getFactories
Return an Iterable over the DetectorFactory objects for all registered Detectors. -
isDisabledByDefault
-
getFactory
Look up a DetectorFactory by its short name.- Parameters:
name
- the short name- Returns:
- the DetectorFactory, or null if there is no factory with that short name
-
getFactoryByClassName
Look up a DetectorFactory by its class name.- Parameters:
className
- the class name- Returns:
- the DetectoryFactory, or null if there is no factory with that class name
-
registerDetector
Register a DetectorFactory. -
unRegisterDetector
-
inferSpotBugsHome
See if the location of ${spotbugs.home} can be inferred from the location of findbugs.jar in the classpath.- Returns:
- inferred ${spotbugs.home}, or null if we can't figure it out
-
getFindBugsHome
-
getCoreResource
-
loadCorePlugin
private void loadCorePlugin() -
jawsDebugMessage
-
loadPlugin
-
unLoadPlugin
-
registerBugCategory
Set the metadata for a bug category. If the category's metadata has already been set, this does nothing.- Parameters:
bc
- the BugCategory object holding the metadata for the category- Returns:
- false if the category's metadata has already been set, true otherwise
-
unRegisterBugCategory
-
registerBugPattern
Register a BugPattern.- Parameters:
bugPattern
- the BugPattern
-
unRegisterBugPattern
-
bugPatternIterator
Get an Iterator over all registered bug patterns. -
getBugPatterns
Get an Iterator over all registered bug patterns. -
lookupBugPattern
Look up bug pattern.- Parameters:
bugType
- the bug type for the bug pattern- Returns:
- the BugPattern, or null if it can't be found
-
registerBugCode
-
unRegisterBugCode
-
getBugCodes
-
getBugCode
Get a description for given "bug type". FIXME: this is referred to elsewhere as the "bug code" or "bug abbrev". Should make the terminology consistent everywhere. In this case, the bug type refers to the short prefix code prepended to the long and short bug messages.- Parameters:
shortBugType
- the short bug type code- Returns:
- the description of that short bug type code means
-
lookupBugCode
- Parameters:
shortBugType
- the short bug type code- Returns:
- the description of that short bug type code means
-
getBugCategory
Get the BugCategory object for a category key. Returns null if no BugCategory object can be found.- Parameters:
category
- the category key- Returns:
- the BugCategory object (may be null)
-
getBugCategories
Get a Collection containing all known bug category keys. E.g., "CORRECTNESS", "MT_CORRECTNESS", "PERFORMANCE", etc. Excludes hidden bug categories- Returns:
- Collection of bug category keys.
-
getBugCategoryObjects
-