Class Plugin

java.lang.Object
edu.umd.cs.findbugs.Plugin
All Implemented Interfaces:
AutoCloseable

public class Plugin extends Object implements 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).
Author:
David Hovemeyer
See Also:
  • 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

      public String toString()
      Overrides:
      toString in class Object
    • isEnabledByDefault

      public boolean isEnabledByDefault()
      Return whether or not the Plugin is enabled.
      Returns:
      true if the Plugin is enabled, false if not
    • setProvider

      public void setProvider(String provider)
      Set plugin provider.
      Parameters:
      provider - the plugin provider
    • getProvider

      @CheckForNull public String getProvider()
      Get the plugin provider.
      Returns:
      the provider, or null if the provider was not specified
    • setUpdateUrl

      public void setUpdateUrl(String url) throws URISyntaxException
      Throws:
      URISyntaxException
    • getUpdateUrl

      @CheckForNull public URI getUpdateUrl()
    • setMyGlobalOption

      public void setMyGlobalOption(String key, String value)
    • setWebsite

      public void setWebsite(String website) throws URISyntaxException
      Set plugin website.
      Parameters:
      website - the plugin website
      Throws:
      URISyntaxException
    • getWebsite

      @CheckForNull public String getWebsite()
      Get the plugin website.
      Returns:
      the website, or null if the was not specified
    • getWebsiteURI

      @CheckForNull public URI getWebsiteURI()
    • getVersion

      public String getVersion()
    • getReleaseDate

      public Date getReleaseDate()
    • setShortDescription

      public void setShortDescription(String shortDescription)
    • getShortDescription

      public String getShortDescription()
    • getDetailedDescription

      public String getDetailedDescription()
    • setDetailedDescription

      public void setDetailedDescription(String detailedDescription)
    • addDetectorFactory

      public void addDetectorFactory(DetectorFactory factory)
      Add a DetectorFactory for a Detector implemented by the Plugin.
      Parameters:
      factory - the DetectorFactory
    • addBugPattern

      public void addBugPattern(BugPattern bugPattern)
      Add a BugPattern reported by the Plugin.
      Parameters:
      bugPattern -
    • addBugCode

      public void addBugCode(BugCode bugCode)
      Add a BugCode reported by the Plugin.
      Parameters:
      bugCode -
    • addBugCategory

      public void addBugCategory(BugCategory bugCategory)
      Add a BugCategory reported by the Plugin.
      Parameters:
      bugCategory -
    • addOrCreateBugCategory

      public BugCategory addOrCreateBugCategory(String id)
    • addInterPassOrderingConstraint

      public void addInterPassOrderingConstraint(DetectorOrderingConstraint constraint)
      Add an inter-pass Detector ordering constraint.
      Parameters:
      constraint - the inter-pass Detector ordering constraint
    • addIntraPassOrderingConstraint

      public void addIntraPassOrderingConstraint(DetectorOrderingConstraint constraint)
      Add an intra-pass Detector ordering constraint.
      Parameters:
      constraint - the intra-pass Detector ordering constraint
    • getFactoryByShortName

      public DetectorFactory getFactoryByShortName(String shortName)
      Look up a DetectorFactory by short name.
      Parameters:
      shortName - the short name
      Returns:
      the DetectorFactory
    • getFactoryByFullName

      public DetectorFactory getFactoryByFullName(String fullName)
      Look up a DetectorFactory by full name.
      Parameters:
      fullName - the full name
      Returns:
      the DetectorFactory
    • getDetectorFactories

      public Collection<DetectorFactory> getDetectorFactories()
      Get Iterator over DetectorFactory objects in the Plugin.
      Returns:
      Iterator over DetectorFactory objects
    • getBugPatterns

      public Set<BugPattern> getBugPatterns()
      Get the set of BugPatterns
    • getBugCodes

      public Set<BugCode> getBugCodes()
      Get Iterator over BugCode objects in the Plugin.
      Returns:
      Iterator over BugCode objects
    • getBugCategories

      public Collection<BugCategory> getBugCategories()
      Get Iterator over BugCategories objects in the Plugin.
      Returns:
      Iterator over BugCategory objects
    • getBugCategory

      @CheckForNull public BugCategory getBugCategory(String id)
      Parameters:
      id - may be null
      Returns:
      return bug category with given id, may return null if the bug category is unknown
    • interPassConstraintIterator

      public Iterator<DetectorOrderingConstraint> interPassConstraintIterator()
      Return an Iterator over the inter-pass Detector ordering constraints.
    • intraPassConstraintIterator

      public Iterator<DetectorOrderingConstraint> intraPassConstraintIterator()
      Return an Iterator over the intra-pass Detector ordering constraints.
    • getPluginId

      public String getPluginId()
    • getShortPluginId

      public String getShortPluginId()
    • setEngineRegistrarClass

      public void setEngineRegistrarClass(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.
      Parameters:
      engineRegistrarClass - The engine registrar class to set.
    • getEngineRegistrarClass

      public Class<? extends IAnalysisEngineRegistrar> 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

      public PluginLoader getPluginLoader()
    • setBugRanker

      public void setBugRanker(BugRanker ranker)
    • getBugRanker

      public BugRanker getBugRanker()
    • getFindBugsMain

      @CheckForNull public FindBugsMain getFindBugsMain(String cmd)
    • getAllFindBugsMain

      public Collection<FindBugsMain> getAllFindBugsMain()
    • getComponentPlugins

      public <T> Iterable<ComponentPlugin<T>> getComponentPlugins(Class<T> componentClass)
    • getComponentPlugin

      public <T> ComponentPlugin<T> getComponentPlugin(Class<T> componentClass, String name)
    • getByPluginId

      @CheckForNull public static Plugin getByPluginId(String name)
    • removePlugin

      public static void removePlugin(URI uri)
    • getAllPlugins

      public static Collection<Plugin> getAllPlugins()
      Returns:
      a copy of the internal plugins collection
    • getAllPluginIds

      public static Collection<String> getAllPluginIds()
    • getAllPluginsMap

      public static Map<URI,Plugin> getAllPluginsMap()
      Returns:
      a copy of the internal plugins collection
    • getAllPluginsURIs

      public static Set<URI> getAllPluginsURIs()
    • isCorePlugin

      public boolean isCorePlugin()
    • cannotDisable

      public boolean cannotDisable()
    • isGloballyEnabled

      public boolean isGloballyEnabled()
    • setGloballyEnabled

      public void setGloballyEnabled(boolean enabled)
    • isInitialPlugin

      public boolean isInitialPlugin()
    • getResource

      public URL getResource(String name)
    • getClassLoader

      public ClassLoader getClassLoader()
    • getParentPlugin

      @CheckForNull public Plugin getParentPlugin()
    • loadCustomPlugin

      public static Plugin loadCustomPlugin(File f, @CheckForNull Project project) throws PluginException
      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, @CheckForNull Project project) throws PluginException
      Loads the given plugin and enables it for the given project.
      Throws:
      PluginException
    • addCustomPlugin

      @CheckForNull public static Plugin addCustomPlugin(URL u) throws PluginException
      Throws:
      PluginException
    • addCustomPlugin

      @CheckForNull public static Plugin addCustomPlugin(URI u) throws PluginException
      Throws:
      PluginException
    • addCustomPlugin

      @CheckForNull public static Plugin addCustomPlugin(URL u, ClassLoader parent) throws PluginException
      Throws:
      PluginException
    • addCustomPlugin

      @CheckForNull public static Plugin addCustomPlugin(URI u, ClassLoader parent) throws PluginException
      Throws:
      PluginException
    • removeCustomPlugin

      public static void removeCustomPlugin(Plugin plugin)
    • close

      public void close() throws IOException
      Closes the underlying PluginLoader, in turn this closes the URLClassLoader. When loading a custom plugin from a .jar file this method needs to be called to release the reference on that file.
      Specified by:
      close in interface AutoCloseable
      Throws:
      IOException