Package rife.bld.extension
Class PmdOperation
Performs static code analysis with PMD.
- Since:
- 1.0
- Author:
- Erik C. Thauvin
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets the location of the cache file for incremental analysis.Sets the location of the cache file for incremental analysis.Sets the location of the cache file for incremental analysis.collectFilesRecursively(boolean collectFilesRecursively) When specified, any directory mentioned withinputPaths()will only be searched for files that are direct children.Returns the default language versions.final PmdOperationdefaultLanguageVersions(Collection<LanguageVersion>... languageVersion) Sets the default language version to be used for all input files.defaultLanguageVersions(LanguageVersion... languageVersion) Sets the default language version to be used for all input files.Specifies the character set encoding of the source code files.Specifies the character set encoding of the source code files.excludes()Returns the paths to exclude from the analysis.Sets paths to exclude from the analysis.final PmdOperationexcludes(boolean clear, Collection<Path>... excludes) Sets paths to exclude from the analysis.Sets paths to exclude from the analysis, replacing any previous entries.final PmdOperationexcludes(Collection<Path>... excludes) Sets paths to exclude from the analysis, replacing any previous entries.excludesFiles(boolean clear, File... excludes) Sets paths to exclude from the analysis.final PmdOperationexcludesFiles(boolean clear, Collection<File>... excludes) Sets paths to exclude from the analysis.excludesFiles(File... excludes) Sets paths to exclude from the analysis, replacing any previous entries.final PmdOperationexcludesFiles(Collection<File>... excludes) Sets paths to exclude from the analysis, replacing any previous entries.excludesStrings(boolean clear, String... excludes) Sets paths to exclude from the analysis.final PmdOperationexcludesStrings(boolean clear, Collection<String>... excludes) Sets paths to exclude from the analysis.excludesStrings(String... excludes) Sets paths to exclude from the analysis, replacing any previous entries.final PmdOperationexcludesStrings(Collection<String>... excludes) Sets paths to exclude from the analysis, replacing any previous entries.voidexecute()Performs the PMD code analysis operation.failOnError(boolean failOnError) Sets whether the build will exit on recoverable errors.failOnViolation(boolean failOnViolation) Sets whether the build will continue on violations.forceLanguageVersion(LanguageVersion languageVersion) Forces a language to be used for all input files, irrespective of file names.fromProject(BaseProject project) Configures a PMD operation from aBaseProject.ignoreFile(File ignoreFile) Sets the path to the file containing a list of files to ignore, one path per line.ignoreFile(String ignoreFile) Sets the path to the file containing a list of files to ignore, one path per line.ignoreFile(Path ignoreFile) Sets the path to the file containing a list of files to ignore, one path per line.includeLineNumber(boolean includeLineNumber) Enables or disables line number in source file URIs.incrementalAnalysis(boolean incrementalAnalysis) Enables or disables incremental analysis.initConfiguration(String commandName) Creates a new initialized configuration.Returns paths to source files or directories containing source files to analyze.inputPaths(boolean clear, File... inputPath) Sets paths to source files or directories containing source files to analyze.inputPaths(boolean clear, String... inputPath) Sets paths to source files or directories containing source files to analyze.inputPaths(boolean clear, Path... inputPath) Sets paths to source files or directories containing source files to analyze.final PmdOperationinputPaths(boolean clear, Collection<Path>... inputPath) Sets paths to source files or directories containing source files to analyze.inputPaths(File... inputPath) Sets paths to source files or directories containing source files to analyze, replacing any previous entries.inputPaths(String... inputPath) Sets paths to source files or directories containing source files to analyze, replacing any previous entries.inputPaths(Path... inputPath) Sets paths to source files or directories containing source files to analyze, replacing any previous entries.final PmdOperationinputPaths(Collection<Path>... inputPath) Sets paths to source files or directories containing source files to analyze, replacing any previous entries.final PmdOperationinputPathsFiles(boolean clear, Collection<File>... inputPath) Sets paths to source files or directories containing source files to analyze.final PmdOperationinputPathsFiles(Collection<File>... inputPath) Sets paths to source files or directories containing source files to analyze, replacing any previous entries.inputPathsStrings(boolean clear, Collection<String> inputPath) Sets paths to source files or directories containing source files to analyze.inputPathsStrings(Collection<String> inputPath) Sets paths to source files or directories containing source files to analyze, replacing any previous entries.minimumPriority(RulePriority priority) Sets the minimum priority threshold when loading Rules from RuleSets.performPmdAnalysis(String commandName, PMDConfiguration config) Performs the PMD analysis with the given config.Returns the prepended classpath.prependAuxClasspath(String... classpath) Prepend the specified classpath-like string to the current ClassLoader of the configuration.Returns paths to shorten paths that are output in the report.relativizeRoots(File... relativeRoot) Adds several paths to shorten paths that are output in the report.relativizeRoots(String... relativeRoot) Adds several paths to shorten paths that are output in the report.relativizeRoots(Path... relativeRoot) Adds several paths to shorten paths that are output in the report.final PmdOperationrelativizeRoots(Collection<Path>... relativeRoot) Adds several paths to shorten paths that are output in the report.final PmdOperationrelativizeRootsFiles(Collection<File>... relativeRoot) Adds several paths to shorten paths that are output in the report.final PmdOperationrelativizeRootsStrings(Collection<String>... relativeRoot) Adds several paths to shorten paths that are output in the report.Returns the path to the report file.reportFile(File reportFile) Sets the path to the report page.reportFile(String reportFile) Sets the path to the report page.reportFile(Path reportFile) Sets the path to the report page.reportFormat(String reportFormat) Sets the output format of the analysis report.reportProperties(Properties reportProperties) Sets the Report properties.ruleSets()Returns the rule set paths.Sets rule set paths.final PmdOperationruleSets(boolean clear, Collection<String>... ruleSet) Sets rule set paths.final PmdOperationSets rule set paths.Sets new rule set paths, replacing any previous entries.final PmdOperationruleSets(Collection<String>... ruleSet) Sets new rule set paths, replacing any previous entries.final PmdOperationSets new rule set paths, replacing any previous entries.final PmdOperationruleSetsRules(boolean clear, Collection<JavaRules>... ruleSet) Sets rule set paths.final PmdOperationruleSetsRules(Collection<JavaRules>... ruleSet) Sets new rule set paths, replacing any previous entries.showSuppressed(boolean showSuppressed) Enables or disables adding the suppressed rule violations to the report.suppressedMarker(String suppressedMarker) Specifies the comment token that marks lines which should be ignored.threads(int threads) Sets the number of threads to be used.Sets the input URI to process for source code objects.Methods inherited from class rife.bld.operations.AbstractOperation
executeOnce, executeOnce, silent, silent
-
Field Details
-
LOGGER
The default logger.
-
-
Constructor Details
-
PmdOperation
public PmdOperation()
-
-
Method Details
-
execute
Performs the PMD code analysis operation.- Specified by:
executein classAbstractOperation<PmdOperation>- Throws:
Exception
-
cache
Sets the location of the cache file for incremental analysis.- Parameters:
cache- the cache file path- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
cache
Sets the location of the cache file for incremental analysis.- Parameters:
cache- the cache file- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
cache
Sets the location of the cache file for incremental analysis.- Parameters:
cache- the cache file path- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
collectFilesRecursively
When specified, any directory mentioned withinputPaths()will only be searched for files that are direct children. By default, subdirectories are recursively included.- Parameters:
collectFilesRecursively- whether to collect files recursively or not- Returns:
- this operation
- Since:
- 1.3.0
-
defaultLanguageVersions
Sets the default language version to be used for all input files.- Parameters:
languageVersion- one or more language versions- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
defaultLanguageVersions
@SafeVarargs public final PmdOperation defaultLanguageVersions(Collection<LanguageVersion>... languageVersion) Sets the default language version to be used for all input files.- Parameters:
languageVersion- a collection of language versions- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
defaultLanguageVersions
Returns the default language versions.- Returns:
- the language versions
- Since:
- 1.0
- See Also:
-
encoding
Specifies the character set encoding of the source code files. The default isUTF-8.The valid values are the standard character sets of
Charset.- Parameters:
encoding- the encoding name- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
encoding
Specifies the character set encoding of the source code files. The default isUTF-8.The valid values are the standard character sets of
Charset.- Parameters:
encoding- the charset- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
excludes
Sets paths to exclude from the analysis, replacing any previous entries.- Parameters:
excludes- one or more paths to exclude- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
excludes
Sets paths to exclude from the analysis, replacing any previous entries.- Parameters:
excludes- paths to exclude- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
excludes
Returns the paths to exclude from the analysis.- Returns:
- the exclude paths
- Since:
- 1.0
- See Also:
-
excludes
Sets paths to exclude from the analysis.- Parameters:
clear- whether to clear existing entries before adding the new onesexcludes- one or more paths to exclude- Returns:
- this operation
- Since:
- 1.5.0
- See Also:
-
excludes
Sets paths to exclude from the analysis.- Parameters:
clear- whether to clear existing entries before adding the new onesexcludes- paths to exclude- Returns:
- this operation
- Since:
- 1.5.0
- See Also:
-
excludesFiles
Sets paths to exclude from the analysis, replacing any previous entries.- Parameters:
excludes- a collection of paths to exclude- Returns:
- this operation
- Since:
- 1.2.0
- See Also:
-
excludesFiles
Sets paths to exclude from the analysis, replacing any previous entries.- Parameters:
excludes- one or more paths to exclude- Returns:
- this operation
- Since:
- 1.2.0
- See Also:
-
excludesFiles
Sets paths to exclude from the analysis.- Parameters:
clear- whether to clear existing entries before adding the new onesexcludes- one or more paths to exclude- Returns:
- this operation
- Since:
- 1.5.0
- See Also:
-
excludesFiles
Sets paths to exclude from the analysis.- Parameters:
clear- whether to clear existing entries before adding the new onesexcludes- a collection of paths to exclude- Returns:
- this operation
- Since:
- 1.5.0
- See Also:
-
excludesStrings
Sets paths to exclude from the analysis, replacing any previous entries.- Parameters:
excludes- a collection of paths to exclude- Returns:
- this operation
- Since:
- 1.2.0
- See Also:
-
excludesStrings
Sets paths to exclude from the analysis, replacing any previous entries.- Parameters:
excludes- one or more paths to exclude- Returns:
- this operation
- Since:
- 1.2.0
- See Also:
-
excludesStrings
Sets paths to exclude from the analysis.- Parameters:
clear- whether to clear existing entries before adding the new onesexcludes- one or more paths to exclude- Returns:
- this operation
- Since:
- 1.5.0
- See Also:
-
excludesStrings
@SafeVarargs public final PmdOperation excludesStrings(boolean clear, Collection<String>... excludes) Sets paths to exclude from the analysis.- Parameters:
clear- whether to clear existing entries before adding the new onesexcludes- a collection of paths to exclude- Returns:
- this operation
- Since:
- 1.5.0
- See Also:
-
failOnError
Sets whether the build will exit on recoverable errors.Default is:
trueNote: If only violations are found, see
failOnViolation- Parameters:
failOnError- whether to exit and fail the build if recoverable errors occurred- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
failOnViolation
Sets whether the build will continue on violations.Note: If additionally recoverable errors occurred, see
failOnError- Parameters:
failOnViolation- whether to exit and fail the build if violations are found- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
forceLanguageVersion
Forces a language to be used for all input files, irrespective of file names.- Parameters:
languageVersion- the language version- Returns:
- this operation
- Since:
- 1.0
-
fromProject
Configures a PMD operation from aBaseProject.The defaults are:
- cache=
build/pmd/pmd-cache - encoding=
UTF-8 - incrementalAnalysis=
true - inputPaths=
[src/main, src/test] - reportFile=
build/pmd/pmd-report.txt - reportFormat=
text - rulePriority=
LOW - ruleSets=
JavaRules.QUICK_START - suppressedMarker=
NOPMD
- Parameters:
project- the project- Returns:
- this operation
- Since:
- 1.0
- cache=
-
ignoreFile
Sets the path to the file containing a list of files to ignore, one path per line.- Parameters:
ignoreFile- the ignore file path- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
ignoreFile
Sets the path to the file containing a list of files to ignore, one path per line.- Parameters:
ignoreFile- the ignore file- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
ignoreFile
Sets the path to the file containing a list of files to ignore, one path per line.- Parameters:
ignoreFile- the ignore file path- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
includeLineNumber
Enables or disables line number in source file URIs.While clicking on the URI works in IntelliJ IDEA, Visual Studio Code, etc.; it might not in terminal emulators.
Default:
true- Parameters:
includeLineNumber- whether to include the line number in source file URIs- Returns:
- this operation
- Since:
- 1.0
-
incrementalAnalysis
Enables or disables incremental analysis.- Parameters:
incrementalAnalysis- whether to enable incremental analysis- Returns:
- this operation
- Since:
- 1.0
-
initConfiguration
Creates a new initialized configuration.- Parameters:
commandName- the command name- Returns:
- a fully configured
PMDConfiguration - Since:
- 1.0
-
inputPaths
Sets paths to source files or directories containing source files to analyze, replacing any previous entries.- Parameters:
inputPath- one or more paths- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
inputPaths
Sets paths to source files or directories containing source files to analyze, replacing any previous entries.- Parameters:
inputPath- one or more paths- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
inputPaths
Sets paths to source files or directories containing source files to analyze, replacing any previous entries.- Parameters:
inputPath- one or more paths- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
inputPaths
Sets paths to source files or directories containing source files to analyze, replacing any previous entries.- Parameters:
inputPath- a collection of input paths- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
inputPaths
Returns paths to source files or directories containing source files to analyze.- Returns:
- the input paths
- Since:
- 1.0
- See Also:
-
inputPaths
Sets paths to source files or directories containing source files to analyze.- Parameters:
clear- whether to clear existing entries before adding the new onesinputPath- one or more paths- Returns:
- this operation
- Since:
- 1.5.0
- See Also:
-
inputPaths
Sets paths to source files or directories containing source files to analyze.- Parameters:
clear- whether to clear existing entries before adding the new onesinputPath- one or more paths- Returns:
- this operation
- Since:
- 1.5.0
- See Also:
-
inputPaths
Sets paths to source files or directories containing source files to analyze.- Parameters:
clear- whether to clear existing entries before adding the new onesinputPath- one or more paths- Returns:
- this operation
- Since:
- 1.5.0
- See Also:
-
inputPaths
Sets paths to source files or directories containing source files to analyze.- Parameters:
clear- whether to clear existing entries before adding the new onesinputPath- a collection of input paths- Returns:
- this operation
- Since:
- 1.5.0
- See Also:
-
inputPathsFiles
Sets paths to source files or directories containing source files to analyze, replacing any previous entries.- Parameters:
inputPath- a collection of input paths- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
inputPathsFiles
@SafeVarargs public final PmdOperation inputPathsFiles(boolean clear, Collection<File>... inputPath) Sets paths to source files or directories containing source files to analyze.- Parameters:
clear- whether to clear existing entries before adding the new onesinputPath- a collection of input paths- Returns:
- this operation
- Since:
- 1.5.0
- See Also:
-
inputPathsStrings
Sets paths to source files or directories containing source files to analyze, replacing any previous entries.- Parameters:
inputPath- a collection of input paths- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
inputPathsStrings
Sets paths to source files or directories containing source files to analyze.- Parameters:
clear- whether to clear existing entries before adding the new onesinputPath- a collection of input paths- Returns:
- this operation
- Since:
- 1.5.0
- See Also:
-
minimumPriority
Sets the minimum priority threshold when loading Rules from RuleSets.- Parameters:
priority- the minimum rule priority- Returns:
- this operation
- Since:
- 1.0
-
performPmdAnalysis
public PmdAnalysisResults performPmdAnalysis(String commandName, PMDConfiguration config) throws ExitStatusException Performs the PMD analysis with the given config.- Parameters:
commandName- the command nameconfig- the configuration- Returns:
- the analysis results
- Throws:
ExitStatusException- if an error occurs- Since:
- 1.0
-
prependAuxClasspath
Prepend the specified classpath-like string to the current ClassLoader of the configuration. If no ClassLoader is currently configured, the ClassLoader used to load the PMDConfiguration class will be used as the parent ClassLoader of the created ClassLoader.If the classpath String looks like a URL to a file (i.e., starts with
file://) the file will be read with each line representing an entry on the classpath.- Parameters:
classpath- one or more classpath entries- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
prependAuxClasspath
Returns the prepended classpath.- Returns:
- the classpath
- Since:
- 1.0
- See Also:
-
relativizeRoots
Adds several paths to shorten paths that are output in the report.- Parameters:
relativeRoot- one or more relative root paths- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
relativizeRoots
Adds several paths to shorten paths that are output in the report.- Parameters:
relativeRoot- one or more relative root paths- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
relativizeRoots
Adds several paths to shorten paths that are output in the report.- Parameters:
relativeRoot- one or more relative root paths- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
relativizeRoots
Adds several paths to shorten paths that are output in the report.- Parameters:
relativeRoot- a collection of relative root paths- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
relativizeRoots
Returns paths to shorten paths that are output in the report.- Returns:
- the relative root paths
- Since:
- 1.0
- See Also:
-
relativizeRootsFiles
Adds several paths to shorten paths that are output in the report.- Parameters:
relativeRoot- a collection of relative root paths- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
relativizeRootsStrings
Adds several paths to shorten paths that are output in the report.- Parameters:
relativeRoot- a collection of relative root paths- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
reportFile
Sets the path to the report page.- Parameters:
reportFile- the report file path- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
reportFile
Sets the path to the report page.- Parameters:
reportFile- the report file- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
reportFile
Sets the path to the report page.- Parameters:
reportFile- the report file path- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
reportFile
Returns the path to the report file.- Returns:
- the report file path
- Since:
- 1.0
- See Also:
-
reportFormat
Sets the output format of the analysis report. The default istext.- Parameters:
reportFormat- the report format- Returns:
- this operation
- Since:
- 1.0
-
reportProperties
Sets the Report properties. These are used to create the Renderer.- Parameters:
reportProperties- the report properties- Returns:
- this operation
- Since:
- 1.0
-
ruleSets
Sets new rule set paths, replacing any previous entries.- Parameters:
ruleSet- one or more rule set paths- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
ruleSets
Sets new rule set paths, replacing any previous entries.- Parameters:
ruleSet- one or more rule set paths- Returns:
- this operation
- Since:
- 1.0
- See Also:
-
ruleSets
Sets new rule set paths, replacing any previous entries.- Parameters:
ruleSet- a collection of rule set paths- Returns:
- this operation
- Since:
- 1.5.0
- See Also:
-
ruleSets
Returns the rule set paths.- Returns:
- the rule sets
- Since:
- 1.0
- See Also:
-
ruleSets
Sets rule set paths.- Parameters:
clear- whether to clear existing entries before adding the new onesruleSet- one or more rule set paths- Returns:
- this operation
- Since:
- 1.5.0
- See Also:
-
ruleSets
Sets rule set paths.- Parameters:
clear- whether to clear existing entries before adding the new onesruleSet- one or more rule set paths- Returns:
- this operation
- Since:
- 1.5.0
- See Also:
-
ruleSets
Sets rule set paths.- Parameters:
clear- whether to clear existing entries before adding the new onesruleSet- a collection of rule set paths- Returns:
- this operation
- Since:
- 1.5.0
- See Also:
-
ruleSetsRules
Sets new rule set paths, replacing any previous entries.- Parameters:
ruleSet- a collection of rule set paths- Returns:
- this operation
- Since:
- 1.5.0
- See Also:
-
ruleSetsRules
@SafeVarargs public final PmdOperation ruleSetsRules(boolean clear, Collection<JavaRules>... ruleSet) Sets rule set paths.- Parameters:
clear- whether to clear existing entries before adding the new onesruleSet- a collection of rule set paths- Returns:
- this operation
- Since:
- 1.5.0
- See Also:
-
showSuppressed
Enables or disables adding the suppressed rule violations to the report.- Parameters:
showSuppressed- whether to add suppressed violations to the report- Returns:
- this operation
- Since:
- 1.0
-
suppressedMarker
Specifies the comment token that marks lines which should be ignored. The default isNOPMD.- Parameters:
suppressedMarker- the suppressed marker token- Returns:
- this operation
- Since:
- 1.0
-
threads
Sets the number of threads to be used. The default is1.- Parameters:
threads- the number of threads- Returns:
- this operation
- Since:
- 1.0
-
uri
Sets the input URI to process for source code objects.- Parameters:
inputUri- the input URI- Returns:
- this operation
- Since:
- 1.0
-