Class UserPreferences

java.lang.Object
edu.umd.cs.findbugs.config.UserPreferences
All Implemented Interfaces:
Cloneable

public class UserPreferences extends Object implements Cloneable
User Preferences outside of any one Project. This consists of a class to manage the findbugs.prop file found in the user.home.
Author:
Dave Brosius
  • Field Details

    • EFFORT_MIN

      public static final String EFFORT_MIN
      See Also:
    • EFFORT_DEFAULT

      public static final String EFFORT_DEFAULT
      See Also:
    • EFFORT_MAX

      public static final String EFFORT_MAX
      See Also:
    • KEY_PLUGIN

      public static final String KEY_PLUGIN
      Key prefix for custom plugins, full key consists of a prefix + plugin index starting with 0
      See Also:
    • KEY_INCLUDE_FILTER

      public static final String KEY_INCLUDE_FILTER
      Key prefix for custom filters, full key consists of a prefix + filter index starting with 0
      See Also:
    • KEY_EXCLUDE_FILTER

      public static final String KEY_EXCLUDE_FILTER
      Key prefix for custom filters, full key consists of a prefix + filter index starting with 0
      See Also:
    • KEY_EXCLUDE_BUGS

      public static final String KEY_EXCLUDE_BUGS
      Key prefix for custom filters, full key consists of a prefix + filter index starting with 0
      See Also:
  • Method Details

    • createDefaultUserPreferences

      public static UserPreferences createDefaultUserPreferences()
      Create default UserPreferences.
      Returns:
      default UserPreferences
    • read

      public void read()
      Read persistent global UserPreferences from file in the user's home directory.
    • read

      public void read(@WillClose InputStream in) throws IOException
      Read user preferences from given input stream. The InputStream is guaranteed to be closed by this method.
      Parameters:
      in - the InputStream
      Throws:
      IOException
    • write

      public void write()
      Write persistent global UserPreferences to file in user's home directory.
    • write

      public void write(@WillClose OutputStream out) throws IOException
      Write UserPreferences to given OutputStream. The OutputStream is guaranteed to be closed by this method.
      Parameters:
      out - the OutputStream
      Throws:
      IOException
    • getRecentProjects

      public List<String> getRecentProjects()
      Get List of recent project filenames.
      Returns:
      List of recent project filenames
    • useProject

      public void useProject(String projectName)
      Add given project filename to the front of the recently-used project list.
      Parameters:
      projectName - project filename
    • removeProject

      public void removeProject(String projectName)
      Remove project filename from the recently-used project list.
      Parameters:
      projectName - project filename
    • enableDetector

      public void enableDetector(DetectorFactory factory, boolean enable)
      Set the enabled/disabled status of given Detector.
      Parameters:
      factory - the DetectorFactory for the Detector to be enabled/disabled
      enable - true if the Detector should be enabled, false if it should be Disabled
    • isDetectorEnabled

      public boolean isDetectorEnabled(DetectorFactory factory)
      Get the enabled/disabled status of given Detector.
      Parameters:
      factory - the DetectorFactory of the Detector
      Returns:
      true if the Detector is enabled, false if not
    • enableAllDetectors

      public void enableAllDetectors(boolean enable)
      Enable or disable all known Detectors.
      Parameters:
      enable - true if all detectors should be enabled, false if they should all be disabled
    • setProjectFilterSettings

      public void setProjectFilterSettings(ProjectFilterSettings filterSettings)
      Set the ProjectFilterSettings.
      Parameters:
      filterSettings - the ProjectFilterSettings
    • getFilterSettings

      public ProjectFilterSettings getFilterSettings()
      Get ProjectFilterSettings.
      Returns:
      the ProjectFilterSettings
    • getUserDetectorThreshold

      public int getUserDetectorThreshold()
      Get the detector threshold (min severity to report a warning).
      Returns:
      the detector threshold
    • setUserDetectorThreshold

      public void setUserDetectorThreshold(int threshold)
      Set the detector threshold (min severity to report a warning).
      Parameters:
      threshold - the detector threshold
    • setRunAtFullBuild

      public void setRunAtFullBuild(boolean enable)
      Set the enabled/disabled status of running findbugs automatically for full builds.
      Parameters:
      enable - true if running FindBugs at full builds should be enabled, false if it should be Disabled
    • isRunAtFullBuild

      public boolean isRunAtFullBuild()
      Get the enabled/disabled status of runAtFullBuild
      Returns:
      true if the running for full builds is enabled, false if not
    • setUserDetectorThreshold

      public void setUserDetectorThreshold(String threshold)
      Set the detector threshold (min severity to report a warning).
      Parameters:
      threshold - the detector threshold
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • clone

      public UserPreferences clone()
      Overrides:
      clone in class Object
    • getEffort

      public String getEffort()
    • setEffort

      public void setEffort(String effort)
    • getIncludeFilterFiles

      public Map<String,Boolean> getIncludeFilterFiles()
    • setIncludeFilterFiles

      public void setIncludeFilterFiles(Map<String,Boolean> includeFilterFiles)
    • getExcludeBugsFiles

      public Map<String,Boolean> getExcludeBugsFiles()
    • setExcludeBugsFiles

      public void setExcludeBugsFiles(Map<String,Boolean> excludeBugsFiles)
    • setExcludeFilterFiles

      public void setExcludeFilterFiles(Map<String,Boolean> excludeFilterFiles)
    • getExcludeFilterFiles

      public Map<String,Boolean> getExcludeFilterFiles()
    • setCustomPlugins

      public void setCustomPlugins(Map<String,Boolean> customPlugins)
      Additional plugins which could be used by IFindBugsEngine (if enabled), or which shouldn't be used (if disabled). If a plugin is not included in the set, it's enablement depends on it's default settings.
      Parameters:
      customPlugins - map with additional third party plugin locations (as absolute paths), never null, but might be empty
      See Also:
    • getCustomPlugins

      public Map<String,Boolean> getCustomPlugins()
      Additional plugins which could be used by IFindBugsEngine (if enabled), or which shouldn't be used (if disabled). If a plugin is not included in the set, it's enablement depends on it's default settings.
      Returns:
      map with additional third party plugins, might be empty, never null. The keys are either absolute plugin paths or plugin id's. Special case: if the path consists of one path segment then it represents the plugin id for a plugin to be disabled. A value of a particular key can be null (same as disabled)
      See Also:
    • getCustomPlugins

      public Set<String> getCustomPlugins(boolean enabled)
      Additional plugins which could be used or shouldn't be used (depending on given argument) by IFindBugsEngine. If a plugin is not included in the set, it's enablement depends on it's default settings.
      Returns:
      set with additional third party plugins, might be empty, never null. The elements are either absolute plugin paths or plugin id's. Special case: if the path consists of one path segment then it represents the plugin id for a plugin to be disabled.
      See Also:
    • getAnalysisFeatureSettings

      public AnalysisFeatureSetting[] getAnalysisFeatureSettings()
      Returns the effort level as an array of feature settings as expected by FindBugs.
      Returns:
      The array of feature settings corresponding to the current effort setting.