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
Modifier and TypeFieldDescriptionThe command line options.The source files(s) or folder(s).Fields inherited from class rife.bld.operations.AbstractProcessOperation
classpath_, DEFAULT_JAVA_TOOL, errorProcessor_, errorProcessorThread_, javaOptions_, javaTool_, mainClass_, outputProcessor_, outputProcessorThread_, process_, successful_, workDirectory_
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbranchMatchingXpath
(String xPathQuery) Shows Abstract Syntax Tree(AST) branches that match given XPath query.configurationFile
(String 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.exclude
(Collection<String> 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.Part of theAbstractProcessOperation.execute()
operation, constructs the command list to use for building the process.executeIgnoredModules
(boolean isAllowIgnoreModules) Allows ignored modules to be run.format
(CheckstyleFormatOption 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.outputPath
(String file) Sets the output file.propertiesFile
(String file) Sets the property files to load.Specified the file(s) or folder(s) containing the source files to check.sourceDir
(Collection<String> dirs) Specified 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, execute, executeStartProcess, javaOptions, javaOptions, javaTool, javaTool, mainClass, mainClass, outputProcessor, outputProcessor, process, workDirectory, workDirectory
Methods inherited from class rife.bld.operations.AbstractOperation
executeOnce, executeOnce, silent, silent
-
Field Details
-
exclude
-
excludeRegex
-
options
The command line options. -
sourceDirs
The source files(s) or folder(s).
-
-
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
-
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:
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:
-
executeConstructProcessCommandList
Part of theAbstractProcessOperation.execute()
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:CheckstyleFormatOption.XML
,CheckstyleFormatOption.SARIF
,CheckstyleFormatOption.PLAIN
for the XML, sarif and default logger respectively.Defaults to
CheckstyleFormatOption.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
-
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
-
sourceDir
Specified 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
Specified 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
-