Class Plugin
java.lang.Object
edu.umd.cs.findbugs.Plugin
- All Implemented Interfaces:
AutoCloseable
A FindBugs plugin. A plugin contains executable Detector classes, as well as
meta information describing those detectors (such as human-readable detector
and bug descriptions).
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enumprivate static interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final LinkedHashMap<String, BugCategory> private final LinkedHashSet<BugCode> private final LinkedHashSet<BugPattern> private BugRankerprivate final booleanprivate final DualKeyHashMap<Class<?>, String, ComponentPlugin<?>> private Stringprivate final List<DetectorFactory> private Plugin.EnabledStateprivate final booleanprivate Class<? extends IAnalysisEngineRegistrar> private final List<DetectorOrderingConstraint> private final List<DetectorOrderingConstraint> private final Map<String, FindBugsMain> private final Stringprivate final PluginLoaderprivate Stringprivate final Dateprivate Stringprivate @Nullable URIprivate static final Stringprivate final Stringprivate URI -
Constructor Summary
ConstructorsConstructorDescriptionPlugin(String pluginId, String version, Date releaseDate, @NonNull PluginLoader pluginLoader, boolean enabled, boolean cannotDisable) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBugCategory(BugCategory bugCategory) Add a BugCategory reported by the Plugin.voidaddBugCode(BugCode bugCode) Add a BugCode reported by the Plugin.voidaddBugPattern(BugPattern bugPattern) Add a BugPattern reported by the Plugin.(package private) <T> voidaddComponentPlugin(Class<T> componentKind, ComponentPlugin<T> plugin) static @Nullable Pluginstatic @Nullable PluginaddCustomPlugin(URI u, ClassLoader parent) static @Nullable Pluginstatic @Nullable PluginaddCustomPlugin(URL u, ClassLoader parent) voidaddDetectorFactory(DetectorFactory factory) Add a DetectorFactory for a Detector implemented by the Plugin.(package private) <T> voidaddFindBugsMain(Class<?> mainClass, String cmd, String description, String kind, boolean analysis) voidAdd an inter-pass Detector ordering constraint.voidAdd an intra-pass Detector ordering constraint.booleanvoidclose()Closes the underlyingPluginLoader, in turn this closes theURLClassLoader.private @Nullable DetectorFactorystatic Collection<String> static Collection<Plugin> Get Iterator over BugCategories objects in the Plugin.@Nullable BugCategorygetBugCategory(String id) Get Iterator over BugCode objects in the Plugin.Get the set of BugPatternsstatic @Nullable PlugingetByPluginId(String name) <T> ComponentPlugin<T> getComponentPlugin(Class<T> componentClass, String name) <T> Iterable<ComponentPlugin<T>> getComponentPlugins(Class<T> componentClass) Get Iterator over DetectorFactory objects in the Plugin.Class<? extends IAnalysisEngineRegistrar> Get the analysis engine registrar class that, when instantiated, can be used to register the plugin's analysis engines with the analysis cache.getFactoryByFullName(String fullName) Look up a DetectorFactory by full name.getFactoryByShortName(String shortName) Look up a DetectorFactory by short name.@Nullable FindBugsMaingetFindBugsMain(String cmd) @Nullable Plugin(package private) static @Nullable Plugin@Nullable StringGet the plugin provider.getResource(String name) @Nullable URI@Nullable StringGet the plugin website.@Nullable URIReturn an Iterator over the inter-pass Detector ordering constraints.Return an Iterator over the intra-pass Detector ordering constraints.booleanbooleanReturn whether or not the Plugin is enabled.booleanbooleanstatic PluginloadCustomPlugin(File f, @Nullable Project project) Loads the given plugin and enables it for the given project.static PluginloadCustomPlugin(URL urlString, @Nullable Project project) Loads the given plugin and enables it for the given project.(package private) static @Nullable Pluginstatic voidremoveCustomPlugin(Plugin plugin) static voidremovePlugin(URI uri) voidsetBugRanker(BugRanker ranker) voidsetDetailedDescription(String detailedDescription) voidsetEngineRegistrarClass(Class<? extends IAnalysisEngineRegistrar> engineRegistrarClass) Set the analysis engine registrar class that, when instantiated, can be used to register the plugin's analysis engines with the analysis cache.voidsetGloballyEnabled(boolean enabled) voidsetMyGlobalOption(String key, String value) voidsetProvider(String provider) Set plugin provider.voidsetShortDescription(String shortDescription) voidsetUpdateUrl(String url) voidsetWebsite(String website) Set plugin website.toString()
-
Field Details
-
USE_FINDBUGS_VERSION
- See Also:
-
allPlugins
-
pluginId
-
version
-
releaseDate
-
provider
-
website
-
updateUrl
-
shortDescription
-
detailedDescription
-
detectorFactoryList
-
mainPlugins
-
bugPatterns
-
bugCodeList
-
bugCategories
-
myGlobalOptions
-
componentPlugins
-
bugRanker
-
interPassConstraintList
-
intraPassConstraintList
-
engineRegistrarClass
-
pluginLoader
-
enabledByDefault
private final boolean enabledByDefault -
cannotDisable
private final boolean cannotDisable -
enabled
-
-
Constructor Details
-
Plugin
public Plugin(String pluginId, String version, Date releaseDate, @NonNull PluginLoader pluginLoader, boolean enabled, boolean cannotDisable) Constructor. Creates an empty plugin object.- Parameters:
pluginId- the plugin's unique identifier
-
-
Method Details
-
toString
-
isEnabledByDefault
public boolean isEnabledByDefault()Return whether or not the Plugin is enabled.- Returns:
- true if the Plugin is enabled, false if not
-
setProvider
Set plugin provider.- Parameters:
provider- the plugin provider
-
getProvider
Get the plugin provider.- Returns:
- the provider, or null if the provider was not specified
-
setUpdateUrl
- Throws:
URISyntaxException
-
getUpdateUrl
-
setMyGlobalOption
-
getMyGlobalOptions
-
setWebsite
Set plugin website.- Parameters:
website- the plugin website- Throws:
URISyntaxException
-
getWebsite
Get the plugin website.- Returns:
- the website, or null if the was not specified
-
getWebsiteURI
-
getVersion
-
getReleaseDate
-
setShortDescription
-
getShortDescription
-
getDetailedDescription
-
setDetailedDescription
-
addDetectorFactory
Add a DetectorFactory for a Detector implemented by the Plugin.- Parameters:
factory- the DetectorFactory
-
addBugPattern
Add a BugPattern reported by the Plugin.- Parameters:
bugPattern-
-
addBugCode
-
addBugCategory
Add a BugCategory reported by the Plugin.- Parameters:
bugCategory-
-
addOrCreateBugCategory
-
addInterPassOrderingConstraint
Add an inter-pass Detector ordering constraint.- Parameters:
constraint- the inter-pass Detector ordering constraint
-
addIntraPassOrderingConstraint
Add an intra-pass Detector ordering constraint.- Parameters:
constraint- the intra-pass Detector ordering constraint
-
getFactoryByShortName
Look up a DetectorFactory by short name.- Parameters:
shortName- the short name- Returns:
- the DetectorFactory
-
getFactoryByFullName
Look up a DetectorFactory by full name.- Parameters:
fullName- the full name- Returns:
- the DetectorFactory
-
getDetectorFactories
Get Iterator over DetectorFactory objects in the Plugin.- Returns:
- Iterator over DetectorFactory objects
-
getBugPatterns
Get the set of BugPatterns -
getBugCodes
-
getBugCategories
Get Iterator over BugCategories objects in the Plugin.- Returns:
- Iterator over BugCategory objects
-
getBugCategory
- Parameters:
id- may be null- Returns:
- return bug category with given id, may return null if the bug category is unknown
-
interPassConstraintIterator
Return an Iterator over the inter-pass Detector ordering constraints. -
intraPassConstraintIterator
Return an Iterator over the intra-pass Detector ordering constraints. -
getPluginId
-
getShortPluginId
-
setEngineRegistrarClass
Set the analysis engine registrar class that, when instantiated, can be used to register the plugin's analysis engines with the analysis cache.- Parameters:
engineRegistrarClass- The engine registrar class to set.
-
getEngineRegistrarClass
Get the analysis engine registrar class that, when instantiated, can be used to register the plugin's analysis engines with the analysis cache.- Returns:
- Returns the engine registrar class.
-
getPluginLoader
-
findFirstMatchingFactory
-
setBugRanker
-
getBugRanker
-
addFindBugsMain
<T> void addFindBugsMain(Class<?> mainClass, String cmd, String description, String kind, boolean analysis) throws SecurityException, NoSuchMethodException -
getFindBugsMain
-
getAllFindBugsMain
-
addComponentPlugin
-
getComponentPlugins
-
getComponentPlugin
-
getByPluginId
-
removePlugin
-
getAllPlugins
- Returns:
- a copy of the internal plugins collection
-
getAllPluginIds
-
getAllPluginsMap
-
getAllPluginsURIs
-
getPlugin
-
putPlugin
-
isCorePlugin
public boolean isCorePlugin() -
cannotDisable
public boolean cannotDisable() -
isGloballyEnabled
public boolean isGloballyEnabled() -
setGloballyEnabled
public void setGloballyEnabled(boolean enabled) -
isInitialPlugin
public boolean isInitialPlugin() -
getResource
-
getClassLoader
-
getParentPlugin
-
loadCustomPlugin
Loads the given plugin and enables it for the given project.- Parameters:
f- A non-null jar file of custom plugin.project- A nullable target project- Throws:
PluginException
-
loadCustomPlugin
public static Plugin loadCustomPlugin(URL urlString, @Nullable Project project) throws PluginException Loads the given plugin and enables it for the given project.- Throws:
PluginException
-
addCustomPlugin
- Throws:
PluginException
-
addCustomPlugin
- Throws:
PluginException
-
addCustomPlugin
- Throws:
PluginException
-
addCustomPlugin
- Throws:
PluginException
-
removeCustomPlugin
-
close
Closes the underlyingPluginLoader, in turn this closes theURLClassLoader. When loading a custom plugin from a .jar file this method needs to be called to release the reference on that file.- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-