Package rife.bld.extension
Class CheckstyleOperation
java.lang.Object
rife.bld.operations.AbstractOperation<T>
rife.bld.operations.AbstractProcessOperation<CheckstyleOperation>
rife.bld.extension.CheckstyleOperation
Static code analysis using Checkstyle.
- Since:
- 1.0
- Author:
- Erik C. Thauvin
-
Field Summary
Fields inherited from class rife.bld.operations.AbstractProcessOperation
classpath_, DEFAULT_JAVA_TOOL, errorProcessor_, errorProcessorThread_, javaOptions_, javaTool_, mainClass_, module_, modulePath_, outputProcessor_, outputProcessorThread_, process_, successful_, workDirectory_
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbranchMatchingXpath
(String xPathQuery) Shows Abstract Syntax Tree(AST) branches that match given XPath query.configurationFile
(File file) Specifies the location of the file that defines the configuration modules.configurationFile
(String file) Specifies the location of the file that defines the configuration modules.configurationFile
(Path file) Specifies the location of the file that defines the configuration modules.debug
(boolean isDebug) Prints all debug logging of Checkstyle utility.Directory/file to exclude from Checkstyle.Directory/file to exclude from Checkstyle.Directory/file to exclude from Checkstyle.exclude
(Collection<File> paths) Directory/file to exclude from Checkstyle.excludePaths
(Collection<Path> paths) Directory/file to exclude from Checkstyle.excludeRegex
(String... regex) Directory/file pattern to exclude from Checkstyle.excludeRegex
(Collection<String> regex) Directory/file pattern to exclude from Checkstyle.excludeStrings
(Collection<String> paths) Directory/file to exclude from Checkstyle.void
execute()
Part of theexecute()
operation, constructs the command list to use for building the process.executeIgnoredModules
(boolean isAllowIgnoreModules) Allows ignored modules to be run.format
(OutputFormat format) Specifies the output format.fromProject
(BaseProject project) Configures theBaseProject
.generateXpathSuppression
(boolean xPathSuppression) Generates to output a suppression xml to use to suppress all violations from user's config.javadocTree
(boolean isTree) This option is used to print the Parse Tree of the Javadoc comment.options()
Returns the command line options.outputPath
(File file) Sets the output file.outputPath
(String file) Sets the output file.outputPath
(Path file) Sets the output file.propertiesFile
(File file) Sets the property files to load.propertiesFile
(String file) Sets the property files to load.propertiesFile
(Path file) Sets the property files to load.Returns the file(s) or folders(s) containing the sources files to checkSpecifies the file(s) or folder(s) containing the source files to check.Specifies the file(s) or folder(s) containing the source files to check.Specifies the file(s) or folder(s) containing the source files to check.sourceDir
(Collection<File> dirs) Specifies the file(s) or folder(s) containing the source files to check.sourceDirPaths
(Collection<Path> dirs) Specifies the file(s) or folder(s) containing the source files to check.sourceDirStrings
(Collection<String> dirs) Specifies the file(s) or folder(s) containing the source files to check.suppressionLineColumnNumber
(String lineColumnNumber) Prints xpath suppressions at the file's line and column position.tabWith
(int length) Sets the length of the tab character.tree
(boolean isTree) This option is used to display the Abstract Syntax Tree (AST) without any comments of the specified file.treeWithComments
(boolean isTree) This option is used to display the Abstract Syntax Tree (AST) with comment nodes excluding Javadoc of the specified file.treeWithJavadoc
(boolean isTree) This option is used to display the Abstract Syntax Tree (AST) with Javadoc nodes of the specified file.Methods inherited from class rife.bld.operations.AbstractProcessOperation
classpath, classpath, classpath, errorProcessor, errorProcessor, executeStartProcess, javaOptions, javaOptions, javaTool, javaTool, mainClass, mainClass, module, module, modulePath, modulePath, modulePath, outputProcessor, outputProcessor, process, workDirectory, workDirectory
Methods inherited from class rife.bld.operations.AbstractOperation
executeOnce, executeOnce, silent, silent
-
Constructor Details
-
CheckstyleOperation
public CheckstyleOperation()
-
-
Method Details
-
branchMatchingXpath
Shows Abstract Syntax Tree(AST) branches that match given XPath query.- Parameters:
xPathQuery
- the xPath query- Returns:
- the checkstyle operation
-
configurationFile
Specifies the location of the file that defines the configuration modules. The location can either be a filesystem location, or a name passed to theClassLoader.getResource()
method. A configuration file is required.- Parameters:
file
- the file- Returns:
- the checkstyle operation
-
configurationFile
Specifies the location of the file that defines the configuration modules. The location can either be a filesystem location, or a name passed to theClassLoader.getResource()
method. A configuration file is required.- Parameters:
file
- the file- Returns:
- the checkstyle operation
-
configurationFile
Specifies the location of the file that defines the configuration modules. The location can either be a filesystem location, or a name passed to theClassLoader.getResource()
method. A configuration file is required.- Parameters:
file
- the file- Returns:
- the checkstyle operation
-
debug
Prints all debug logging of Checkstyle utility.- Parameters:
isDebug
-true
orfalse
- Returns:
- the checkstyle operation
-
exclude
Directory/file to exclude from Checkstyle. The path can be the full, absolute path, or relative to the current path. Multiple excludes are allowed.- Parameters:
path
- one or more paths- Returns:
- the checkstyle operation
- See Also:
-
exclude
Directory/file to exclude from Checkstyle. The path can be the full, absolute path, or relative to the current path. Multiple excludes are allowed.- Parameters:
path
- one or more paths- Returns:
- the checkstyle operation
- See Also:
-
exclude
Directory/file to exclude from Checkstyle. The path can be the full, absolute path, or relative to the current path. Multiple excludes are allowed.- Parameters:
path
- one or more paths- Returns:
- the checkstyle operation
- See Also:
-
exclude
Directory/file to exclude from Checkstyle. The path can be the full, absolute path, or relative to the current path. Multiple excludes are allowed.- Parameters:
paths
- the paths- Returns:
- the checkstyle operation
- See Also:
-
excludePaths
Directory/file to exclude from Checkstyle. The path can be the full, absolute path, or relative to the current path. Multiple excludes are allowed.- Parameters:
paths
- the paths- Returns:
- the checkstyle operation
- See Also:
-
excludeRegex
Directory/file pattern to exclude from Checkstyle. Multiple exclude are allowed.- Parameters:
regex
- the pattern to exclude- Returns:
- the checkstyle operation
- See Also:
-
excludeRegex
Directory/file pattern to exclude from Checkstyle. Multiple exclude are allowed.- Parameters:
regex
- the patterns to exclude- Returns:
- the checkstyle operation
- See Also:
-
excludeStrings
Directory/file to exclude from Checkstyle. The path can be the full, absolute path, or relative to the current path. Multiple excludes are allowed.- Parameters:
paths
- the paths- Returns:
- the checkstyle operation
- See Also:
-
execute
- Overrides:
execute
in classAbstractProcessOperation<CheckstyleOperation>
- Throws:
IOException
InterruptedException
ExitStatusException
-
executeConstructProcessCommandList
Part of theexecute()
operation, constructs the command list to use for building the process.- Specified by:
executeConstructProcessCommandList
in classAbstractProcessOperation<CheckstyleOperation>
-
fromProject
Configures theBaseProject
.- Specified by:
fromProject
in classAbstractProcessOperation<CheckstyleOperation>
-
executeIgnoredModules
Allows ignored modules to be run.- Parameters:
isAllowIgnoreModules
-true
orfalse
- Returns:
- the checkstyle operation
-
format
Specifies the output format. Valid values:OutputFormat.XML
,OutputFormat.SARIF
,OutputFormat.PLAIN
for the XML, sarif and default logger respectively.Defaults to
OutputFormat.PLAIN
.- Parameters:
format
- the output format- Returns:
- the checkstyle operation
-
generateXpathSuppression
Generates to output a suppression xml to use to suppress all violations from user's config. Instead of printing every violation, all violations will be caught and single suppressions xml file will be printed out. Used only with theconfigurationFile
option. Output location can be specified with theoutput
option.- Parameters:
xPathSuppression
-true
orfalse
- Returns:
- the checkstyle operation
-
javadocTree
This option is used to print the Parse Tree of the Javadoc comment. The file has to contain only Javadoc comment content excluding '/**' and '*/' at the beginning and at the end respectively. It can only be used on a single file and cannot be combined with other options.- Parameters:
isTree
-true
orfalse
- Returns:
- the checkstyle operation
-
options
Returns the command line options.- Returns:
- the command line options
-
outputPath
Sets the output file.Defaults to stdout.
- Parameters:
file
- the output file- Returns:
- the checkstyle operation
-
outputPath
Sets the output file.Defaults to stdout.
- Parameters:
file
- the output file- Returns:
- the checkstyle operation
-
outputPath
Sets the output file.Defaults to stdout.
- Parameters:
file
- the output file- Returns:
- the checkstyle operation
-
propertiesFile
Sets the property files to load.- Parameters:
file
- the file- Returns:
- the checkstyle operation
-
propertiesFile
Sets the property files to load.- Parameters:
file
- the file- Returns:
- the checkstyle operation
-
propertiesFile
Sets the property files to load.- Parameters:
file
- the file- Returns:
- the checkstyle operation
-
sourceDir
Specifies the file(s) or folder(s) containing the source files to check.- Parameters:
dir
- one or more directories- Returns:
- the checkstyle operation
- See Also:
-
sourceDir
Specifies the file(s) or folder(s) containing the source files to check.- Parameters:
dir
- one or more directories- Returns:
- the checkstyle operation
- See Also:
-
sourceDir
Specifies the file(s) or folder(s) containing the source files to check.- Parameters:
dir
- one or more directories- Returns:
- the checkstyle operation
- See Also:
-
sourceDir
Specifies the file(s) or folder(s) containing the source files to check.- Parameters:
dirs
- the directories- Returns:
- the checkstyle operation
- See Also:
-
sourceDir
Returns the file(s) or folders(s) containing the sources files to check- Returns:
- the files or directories
-
sourceDirPaths
Specifies the file(s) or folder(s) containing the source files to check.- Parameters:
dirs
- the directories- Returns:
- the checkstyle operation
- See Also:
-
sourceDirStrings
Specifies the file(s) or folder(s) containing the source files to check.- Parameters:
dirs
- the directories- Returns:
- the checkstyle operation
- See Also:
-
suppressionLineColumnNumber
Prints xpath suppressions at the file's line and column position. Argument is the line and column number (separated by a:
) in the file that the suppression should be generated for. The option cannot be used with other options and requires exactly one file to run on to be specified.Note that the generated result will have few queries, joined by pipe(
|
). Together they will match all AST nodes on specified line and column. You need to choose only one and recheck that it works. Usage of all of them is also ok, but might result in undesirable matching and suppress other issues.- Parameters:
lineColumnNumber
- the line column number- Returns:
- the checkstyle operation
-
tabWith
Sets the length of the tab character. Used only with thesuppressionLineColumnNumber
option.Default value is
8
.- Parameters:
length
- the length- Returns:
- the checkstyle operation
-
tree
This option is used to display the Abstract Syntax Tree (AST) without any comments of the specified file. It can only be used on a single file and cannot be combined with other options.- Parameters:
isTree
-true
orfalse
- Returns:
- the checkstyle operation
-
treeWithComments
This option is used to display the Abstract Syntax Tree (AST) with comment nodes excluding Javadoc of the specified file. It can only be used on a single file and cannot be combined with other options.- Parameters:
isTree
-true
orfalse
- Returns:
- the checkstyle operation
-
treeWithJavadoc
This option is used to display the Abstract Syntax Tree (AST) with Javadoc nodes of the specified file. It can only be used on a single file and cannot be combined with other options.- Parameters:
isTree
-true
orfalse
- Returns:
- the checkstyle operation
-