Class UserPreferences
java.lang.Object
edu.umd.cs.findbugs.config.UserPreferences
- All Implemented Interfaces:
Cloneable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final charSeparator string for values composed from a string and booleanprivate static final Stringprivate Stringstatic final Stringprivate static final Stringstatic final Stringstatic final Stringprivate static final Stringprivate static final Stringprivate ProjectFilterSettingsprivate static final Stringstatic final StringKey prefix for custom filters, full key consists of a prefix + filter index starting with 0static final StringKey prefix for custom filters, full key consists of a prefix + filter index starting with 0static final StringKey prefix for custom filters, full key consists of a prefix + filter index starting with 0private static final Stringstatic final StringKey prefix for custom plugins, full key consists of a prefix + plugin index starting with 0private static final intprivate booleanprivate static final Stringprivate LinkedList<String> private static final Stringprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()static UserPreferencesCreate default UserPreferences.voidenableAllDetectors(boolean enable) Enable or disable all known Detectors.voidenableDetector(DetectorFactory factory, boolean enable) Set the enabled/disabled status of given Detector.booleanReturns the effort level as an array of feature settings as expected by FindBugs.Additional plugins which could be used byIFindBugsEngine(if enabled), or which shouldn't be used (if disabled).getCustomPlugins(boolean enabled) Additional plugins which could be used or shouldn't be used (depending on given argument) byIFindBugsEngine.Get ProjectFilterSettings.booleanGet List of recent project filenames.intGet the detector threshold (min severity to report a warning).inthashCode()booleanisDetectorEnabled(DetectorFactory factory) Get the enabled/disabled status of given Detector.booleanGet the enabled/disabled status of runAtFullBuildParses the -adjustPriority parameter into a map: detector / bug pattern -> priority changevoidread()Read persistent global UserPreferences from file in the user's home directory.voidread(InputStream in) Read user preferences from given input stream.readProperties(Properties props, String keyPrefix) Helper method to read array of strings out of the properties file, using a Findbugs style format.voidremoveProject(String projectName) Remove project filename from the recently-used project list.private static StringresolveRelativePath(String maybeRelativePath, Path prefsDir) voidresolveRelativePaths(String preferencesPath) Resolve relative paths stored in the user preferences.voidsetAdjustPriority(Map<String, String> adjustPriority) voidsetCustomPlugins(Map<String, Boolean> customPlugins) Additional plugins which could be used byIFindBugsEngine(if enabled), or which shouldn't be used (if disabled).voidvoidsetExcludeBugsFiles(Map<String, Boolean> excludeBugsFiles) voidsetExcludeFilterFiles(Map<String, Boolean> excludeFilterFiles) voidsetIncludeFilterFiles(Map<String, Boolean> includeFilterFiles) voidsetMergeSimilarWarnings(boolean mergeSimilarWarnings) voidsetProjectFilterSettings(ProjectFilterSettings filterSettings) Set the ProjectFilterSettings.voidsetRunAtFullBuild(boolean enable) Set the enabled/disabled status of running findbugs automatically for full builds.voidsetUserDetectorThreshold(int threshold) Set the detector threshold (min severity to report a warning).voidsetUserDetectorThreshold(String threshold) Set the detector threshold (min severity to report a warning).voiduseProject(String projectName) Add given project filename to the front of the recently-used project list.voidwrite()Write persistent global UserPreferences to file in user's home directory.voidwrite(OutputStream out) Write UserPreferences to given OutputStream.private static voidwriteProperties(Properties props, String keyPrefix, Map<String, Boolean> filters) Helper method to write array of strings out of the properties file, using a Findbugs style format.
-
Field Details
-
BOOL_SEPARATOR
private static final char BOOL_SEPARATORSeparator string for values composed from a string and boolean- See Also:
-
EFFORT_MIN
- See Also:
-
EFFORT_DEFAULT
- See Also:
-
EFFORT_MAX
- See Also:
-
KEY_PLUGIN
Key prefix for custom plugins, full key consists of a prefix + plugin index starting with 0- See Also:
-
PREF_FILE_NAME
- See Also:
-
MAX_RECENT_FILES
private static final int MAX_RECENT_FILES- See Also:
-
DETECTOR_THRESHOLD_KEY
- See Also:
-
FILTER_SETTINGS_KEY
- See Also:
-
FILTER_SETTINGS2_KEY
- See Also:
-
RUN_AT_FULL_BUILD
- See Also:
-
EFFORT_KEY
- See Also:
-
KEY_INCLUDE_FILTER
Key prefix for custom filters, full key consists of a prefix + filter index starting with 0- See Also:
-
KEY_EXCLUDE_FILTER
Key prefix for custom filters, full key consists of a prefix + filter index starting with 0- See Also:
-
KEY_EXCLUDE_BUGS
Key prefix for custom filters, full key consists of a prefix + filter index starting with 0- See Also:
-
KEY_MERGE_SIMILAR_WARNINGS
- See Also:
-
KEY_ADJUST_PRIORITY
- See Also:
-
recentProjectsList
-
detectorEnablementMap
-
filterSettings
-
runAtFullBuild
private boolean runAtFullBuild -
effort
-
includeFilterFiles
-
excludeFilterFiles
-
excludeBugsFiles
-
customPlugins
-
mergeSimilarWarnings
private boolean mergeSimilarWarnings -
adjustPriority
-
-
Constructor Details
-
UserPreferences
private UserPreferences()
-
-
Method Details
-
createDefaultUserPreferences
Create default UserPreferences.- Returns:
- default UserPreferences
-
read
public void read()Read persistent global UserPreferences from file in the user's home directory. -
read
Read user preferences from given input stream. The InputStream is guaranteed to be closed by this method.- Parameters:
in- the InputStream- Throws:
IOException
-
parseAdjustPriorities
-
write
public void write()Write persistent global UserPreferences to file in user's home directory. -
write
Write UserPreferences to given OutputStream. The OutputStream is guaranteed to be closed by this method.- Parameters:
out- the OutputStream- Throws:
IOException
-
getRecentProjects
-
useProject
Add given project filename to the front of the recently-used project list.- Parameters:
projectName- project filename
-
removeProject
Remove project filename from the recently-used project list.- Parameters:
projectName- project filename
-
enableDetector
Set the enabled/disabled status of given Detector.- Parameters:
factory- the DetectorFactory for the Detector to be enabled/disabledenable- true if the Detector should be enabled, false if it should be Disabled
-
isDetectorEnabled
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
Set the ProjectFilterSettings.- Parameters:
filterSettings- the 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
Set the detector threshold (min severity to report a warning).- Parameters:
threshold- the detector threshold
-
equals
-
hashCode
-
clone
-
getEffort
-
setEffort
-
getIncludeFilterFiles
-
setIncludeFilterFiles
-
getExcludeBugsFiles
-
setExcludeBugsFiles
-
setExcludeFilterFiles
-
getExcludeFilterFiles
-
setCustomPlugins
Additional plugins which could be used byIFindBugsEngine(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
Additional plugins which could be used byIFindBugsEngine(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
Additional plugins which could be used or shouldn't be used (depending on given argument) byIFindBugsEngine. 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:
-
readProperties
Helper method to read array of strings out of the properties file, using a Findbugs style format.- Parameters:
props- The properties file to read the array from.keyPrefix- The key prefix of the array.- Returns:
- The array of Strings, or an empty array if no values exist.
-
writeProperties
private static void writeProperties(Properties props, String keyPrefix, Map<String, Boolean> filters) Helper method to write array of strings out of the properties file, using a Findbugs style format.- Parameters:
props- The properties file to write the array to.keyPrefix- The key prefix of the array.filters- The filters array to write to the properties.
-
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.
-
getMergeSimilarWarnings
public boolean getMergeSimilarWarnings()- Returns:
- true if similar warnings should be merged, false otherwise
-
setMergeSimilarWarnings
public void setMergeSimilarWarnings(boolean mergeSimilarWarnings) - Parameters:
mergeSimilarWarnings- true if similar warnings should be merged, false otherwise
-
resolveRelativePaths
Resolve relative paths stored in the user preferences. If the preferences contain relative filter paths, modifies the paths to be absolute. For that, the directory of given file will be used first, and if that does not match, the parent directory will be used to resolve relative paths. If none of the paths match existing files, preferences will stay unchanged.- Parameters:
preferencesPath- the path to the user preferences file, used to resolve relative paths
-
resolveRelativePaths
-
resolveRelativePath
-
getAdjustPriority
-
setAdjustPriority
-