Search for bugs in Java classes with Findbugs.
Task package: | net.findbugs |
Java package: | org.schmant.task.findbugs |
Category: | Analyzing tasks |
Since: | 0.5 |
EntityFS-aware? | No* |
Implements: | ActionTaskFactory GeneratorTaskFactory ProcessTaskFactory |
Produces: | File (the target property. |
Description:
Analyze Java classes with
Findbugs and create a bug report. This task
starts Findbugs in a separate process using the findbugs
program.
This task requires a working Findbugs installation. This task searches for
the findbugs
program using the following algorithm:
- Use the value of the findbugsExecutable property, if set.
- Search for
findbugs
(Unix) orfindbugs.bat
(Windows) in the directories referenced by the$PATH
environment variable.
For more information on the different properties, see the Findbugs manual.
Required properties
Properties
assertions | top |
Should Java assertions be enabled? More fine-grained assertion settings can be set by setting JVM options.
- Setter method:
setAssertions(boolean b)
parameters:b
– Should assertions be enabled?- Default value:
false
(assertions are not enabled).- See also:
- jvmOptions
auxClasspathEntries | top |
A list of auxiliary classpath entries for classes that are needed by the analyzed classes, but should not be analyzed themselves.
- Setter method:
addAuxClasspathEntries(Object o)
Add one or several auxiliary classpath entries.parameters:- Setter method:
addAuxClasspathEntry(Object o)
Add one or several auxiliary classpath entries.parameters:- Setter method:
clearAuxClasspathEntries()
Clear the list of auxiliary classpath entries.
classesAndPackagesToAnalyze | top |
A comma-separated list of name patterns that match the classes and packages of classes to analyze.
This corresponds to the Findbugs onlyAnalyze
option.
- Setter method:
setClassesAndPackagesToAnalyze(String s)
parameters:s
– The patterns.- Default value:
- Empty (all classes are analyzed)
debug | top |
Make Findbugs print debug information.
- Setter method:
setDebug(boolean b)
parameters:b
– Enable debug?
decorators | top |
A list of ExtJavaTaskDecorator:s. Decorators are used to configure the program to run.
- Setter method:
addDecorator(ExtJavaTaskDecorator d)
Add a decorator to the end of the list.parameters:d
– A Java task decorator- Setter method:
addDecorators(Object o)
Add one or several Java task decorators.parameters:o
– One Java task decorator or an array or collection of Java task decorators (ExtJavaTaskDecorator objects).- Setter method:
clearDecorators()
Clear the list of decorators.
effortLevel | top |
Set the level of effort Findbugs should put into finding bugs.
The levels to choose among are:
- FindbugsEffortLevel.MIN
- FindbugsEffortLevel.NORMAL
- FindbugsEffortLevel.MAX
- Setter method:
setEffortLevel(FindbugsEffortLevel l)
parameters:l
– The effort level.- Default value:
- FindbugsEffortLevel.NORMAL
environmentVariables | top |
Environment variables for the program. By default, the variables set are added
to the environment of the Schmant script. See the
inheritEnvironmentVariables
property.
- Setter method:
addEnvironmentVariable(String name, String value)
parameters:name
– The environment variable name, for instancePATH
.value
– The value of the variable.- Setter method:
addEnvironmentVariables(Object o)
Add one or several environment variables.parameters:o
– A string or an array or collection of strings. Each string must have the formatNAME=VALUE
.- Setter method:
clearEnvironmentVariables()
Clear the collection of environment variables.- See also:
- inheritEnvironmentVariables
excludeFilterFile | top |
An XML file that contains bug instance filters for the bugs to exclude from the report.
This corresponds to the Findbugs exclude
option.
The file format is documented in the Findbugs manual.
- Setter method:
setExcludeFilterFile(Object o)
parameters:- See also:
- includeFilterFile
failOnErrors | top |
If the program exits with an error (an exit code != 0), should the task fail? See also ErrorIgnoringTF.
- Setter method:
setFailOnErrors(boolean b)
parameters:b
– Should the task fail on errors?- Default value:
-
true
(fails on errors)
findbugsExecutable | top |
The path up to and including the Findbugs executable (findbugs.bat
on Windows). If this is not set, the task looks for the executable in all
directories listed in the PATH
environment variable.
- Setter method:
setFindbugsExecutable(Object o)
Set the path up to and including the Findbugs executable.parameters:
findbugsReportFormat | top |
The Findbugs report format. The different report formats are:
- FindbugsReportFormat.XML
- FindbugsReportFormat.HTML
- FindbugsReportFormat.EMACS
- FindbugsReportFormat.XDOCS
This corresponds to the Findbugs
xml
, html
, emacs
and xdocs
options.
- Setter method:
setFindbugsReportFormat(FindbugsReportFormat f)
parameters:f
– The report format.- Default value:
- Not set (XML output?)
- See also:
- xmlWithMessages
- htmlStylesheet
findbugsReportLevel | top |
The Findbugs report level. The different report levels are:
- FindbugsReportLevel.LOW
- FindbugsReportLevel.MEDIUM
- FindbugsReportLevel.HIGH
- FindbugsReportLevel.RELAXED
This corresponds to the Findbugs
low
, medium
, high
and
relaxed
options.
- Setter method:
setFindbugsReportLevel(FindbugsReportLevel l)
parameters:l
– The Findbugs report level.- Default value:
- FindbugsReportLevel.MEDIUM.
htmlStylesheet | top |
If the report format is FindbugsReportFormat.HTML, set this property to a path to a XSL stylesheet to use as a custom stylesheet for the report.
- Setter method:
setHtmlStylesheet(String s)
parameters:s
– The path to a stylesheet.- Default value:
- Not set (the stylesheet
default.xsl
from the Findbugs Jar is used). - See also:
- findbugsReportFormat
includeFilterFile | top |
An XML file that contains bug instance filters for the bugs to include in the report.
This corresponds to the Findbugs include
option.
The file format is documented in the Findbugs manual.
- Setter method:
setIncludeFilterFile(Object o)
parameters:- See also:
- excludeFilterFile
inheritEnvironmentVariables | top |
Should the environment variables of the Schmant script be inherited?
- Setter method:
setInheritEnvironmentVariables(boolean b)
parameters:b
– Should environment variables be inherited?- Default value:
true
(environment variables are inherited)- See also:
- environmentVariables
javaExecutable | top |
The path to the java[.exe]
command.
Decorators may also set the Java executable to use. In
that case, that setting take precedence.
- Setter method:
setJavaExecutable(Object o)
parameters:- Default value:
- The Java executable to use is, in this order of precedence:
- A Java executable set by any of the
decorators
. - This property.
- A Java executable found in the catalog referenced by the
javaHome
property, if set. - A Java executable found in the catalog referenced by the
JAVA_HOME
environment variable, if set. - A Java executable found in the directories referenced by the
PATH
environment variable.
- A Java executable set by any of the
- See also:
- javaHome
javaHome | top |
The location of the Java Runtime Environment or Java Development Kit to use
- Setter method:
setJavaHome(Object o)
parameters:- See also:
- javaExecutable
javaVMType | top |
The Java virtual machine type to use (client or server).
- Setter method:
setJavaVMType(JavaVMType t)
parameters:t
– The virtual machine type:JavaVMType.CLIENT
JavaVMType.SERVER
- Default value:
- The JVM:s default virtual machine type, probably client.
jvmOptions | top |
Options for the java
command. Options are
arguments to java
given before the class to run, see the JDK
documentation on java
.
- Setter method:
addJvmOption(String s)
parameters:s
– Add an option- Setter method:
addJvmOptions(Object o)
parameters:o
– One JVM option or an array or collection of JVM options (strings).- Setter method:
clearJvmOptions()
Clear the list of JVM options.
logFooter | top |
The message that is logged to info
level
after the task has been successfully run.
- Setter method:
setLogFooter(String s)
parameters:s
– The footer message.- Default value:
- Empty (no footer message is logged.)
- See also:
- logHeader
logHeader | top |
The message that is logged to info
level
before the task is run.
- Setter method:
setLogHeader(String s)
parameters:s
– The header message.- Default value:
- A task class specific message.
- See also:
- logFooter
nested | top |
Should scanning of nested Jar or Zip files in the file list be enabled?
- Setter method:
setNested(boolean b)
parameters:b
– Should nested search be enabled?- Default value:
true
overwriteStrategy | top |
The overwrite strategy decides how the task will react if there already is an entity (file or directory) in a location where it wants to create a new entity.
If the strategy is to not overwrite existing entities, the task will fail when it cannot create the entities that it wants to create.
Non-empty directories are never overwritten, regardless of the chosen strategy.
- Setter method:
setOverwrite(boolean b)
Setting this to a value ofparameters:true
means that the DoOverwriteAndLogWarning strategy is used. A value of false gives the DontOverwriteAndThrowException strategy.b
– Should an existing entity be overwritten?- Setter method:
setOverwriteStrategy(OverwriteStrategy strat)
Set the overwrite strategy.parameters:strat
– The overwrite strategy.- Default value:
- DontOverwriteAndThrowException
- See also:
- target
projectFile | top |
A Findbugs project file, if a predefined Findbugs project should
be analyzed. The project file name often ends in .fb
- Setter method:
setProjectFile(Object o)
parameters:
reportLevel | top |
This property is used to change the Report level for all task created by this task factory. The report level is changed for the thread running the task when the it is run, and is restored to its previous level when the it is done.
- Setter method:
setReportLevel(Level l)
Set the report levelparameters:l
– The new report level.
sortByClass | top |
Should the reported bug instances be sorted by class name in the report?
- Setter method:
setSortByClass(boolean b)
parameters:b
– Sort by class?- Default value:
false
(bug instances are sorted by bug instance type)
sourceCodeContainers | top |
A collection of directories and/or Jar files containing source code for the classes to analyze.
- Setter method:
addSourceCodeContainer(Object o)
Add one or several directories and/or Jar files.parameters:- Setter method:
addSourceCodeContainers(Object o)
Add one or several directories and/or Jar files.parameters:- Setter method:
clearSourceCodeContainers()
Clear the collection of source code containers.
sources (required) | top |
A collection of class directories and/or Jar files containing the classes to analyze.
- Setter method:
addSource(Object o)
Add one or several source files and/or directories.parameters:- Setter method:
addSources(Object o)
Add one or several source files and/or directories.parameters:- Setter method:
clearSources()
Discard all sources.- Setter method:
setSource(Object o)
Set one or several source files and/or directories, discarding previously set sources.parameters:- Setter method:
setSources(Object o)
Set one or several source files and/or directories, discarding previously set sources.parameters:
stderrStrategy | top |
A ProcessOutputStrategy
for handling the program's output to stderr
.
- Setter method:
setStderrStrategy(ProcessOutputStrategy s)
parameters:s
– Thestderr
strategy.- Default value:
- A LoggingProcessOutputStrategy
that logs output to the
Level.SEVERE
- See also:
- stdoutStrategy
stdoutStrategy | top |
A ProcessOutputStrategy
for handling the program's output to stdout
.
- Setter method:
setStdoutStrategy(ProcessOutputStrategy s)
parameters:s
– Thestdout
strategy.- Default value:
- A LoggingProcessOutputStrategy
that logs output to the
Level.INFO
- See also:
- stderrStrategy
systemProperties | top |
A collection of Java system properties that are given to
the Findbugs program. This corresponds to arguments given to Java using the
-D
flag.
- Setter method:
addSystemProperties(Object o)
Add one or several system properties.parameters:o
– One system property or an array or collection of system properties. Each system property is either a string on the form name=value or a TwoObjects<String, String> object with the name as the first object.- Setter method:
addSystemProperty(String name, String value)
Add one system property.parameters:name
– The system property name.value
– The system property value.- Setter method:
clearSystemProperties()
Clear the system property collection.
target (required) | top |
The report file to generate.
- Setter method:
setTarget(Object o)
parameters:- See also:
- overwriteStrategy
traceLogging | top |
If trace logging is enabled for a task, it reports its configuration before it is run.
Trace logging may also be enabled globally for all tasks by calling TraceMode.setTraceMode(boolean).
- Setter method:
setTraceLogging(boolean b)
Enable or disable trace logging.parameters:b
– Enable trace logging?
workingDirectory | top |
The working directory for the program. (The directory that the program is started in.)
- Setter method:
setWorkingDirectory(Object o)
parameters:- Default value:
- The Schmant process' working directory. The Schmant launcher scripts sets this to the directory where the current script file is.
xmlWithMessages | top |
If the report format is
FindbugsReportFormat.XML, set this property to true
to
include human-readable messages in the generated XML report.
- Setter method:
setXmlWithMessages(boolean b)
parameters:b
– Enable messages in XML report?- Default value:
false
(the generated XML will not contain human-readable messages.- See also:
- findbugsReportFormat
Examples
Example 1
Compile all Java projects in a ProjectRepository and run Findbugs on them.
Groovy
JavaScript
JRuby
Jython
* That a task is not EntityFS-aware means that it is not aware of DirectoryView filters (it uses them as plain Directory:s) and also that it usually requires that the entities it takes as arguments are in a File-based file file system. (That they are ECFileResolvable.) A non File-resolvable entity can be made so by using the SchmantFileSystems.makeFileResolvable(org.entityfs.EFile) method.