Package rife.bld.extension
Class DetektOperation
Performs static code analysis with Detekt.
- Since:
- 1.0
- Author:
- Erik C. Thauvin
-
Field Summary
Fields inherited from class rife.bld.operations.AbstractProcessOperation
DEFAULT_JAVA_TOOL, environment_, errorProcessor_, errorProcessorThread_, javaOptions_, javaTool_, mainClass_, module_, modulePath_, outputProcessor_, outputProcessorThread_, process_, successful_, workDirectory_
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallRules
(boolean allRules) Activates all available (even unstable) rules.autoCorrect
(boolean autoCorrect) Allow rules to autocorrect code if they support it.baseline()
Retrieves the baseline xml file.If a baseline xml file is passed in, only new code smells not in the baseline are printed in the console.If a baseline xml file is passed in, only new code smells not in the baseline are printed in the console.If a baseline xml file is passed in, only new code smells not in the baseline are printed in the console.basePath()
Retrieves the base path.Specifies a directory as the base path.Specifies a directory as the base path.Specifies a directory as the base path.buildUponDefaultConfig
(boolean buildUponDefaultConfig) Preconfigures detekt with a bunch of rules and some opinionated defaults for you.Paths where to find user class files and jar dependencies.EXPERIMENTAL: Paths where to find user class files and jar dependencies.EXPERIMENTAL: Paths where to find user class files and jar dependencies.EXPERIMENTAL: Paths where to find user class files and jar dependencies.classPath
(Collection<File> paths) EXPERIMENTAL: Paths where to find user class files and jar dependencies.classPathPaths
(Collection<Path> paths) EXPERIMENTAL: Paths where to find user class files and jar dependencies.classPathStrings
(Collection<String> paths) EXPERIMENTAL: Paths where to find user class files and jar dependencies.config()
Paths to config files.Paths to the config files (path/to/config.yml
).Paths to the config files (path/to/config.yml
).Paths to the config files (path/to/config.yml
).config
(Collection<File> configs) Paths to the config files (path/to/config.yml
).configPaths
(Collection<Path> configs) Paths to the config files (path/to/config.yml
).Retrieves the path of the config resource.configResource
(File resource) Path to the config resource on detekt's classpath (path/to/config.yml
).configResource
(String resource) Path to the config resource on detekt's classpath (path/to/config.yml
).configResource
(Path resource) Path to the config resource on detekt's classpath (path/to/config.yml
).configStrings
(Collection<String> configs) Paths to the config files (path/to/config.yml
).createBaseline
(boolean createBaseline) Treats current analysis findings as a smell baseline for future detekt runs.debug
(boolean debug) Prints extra information about configurations and extensions.disableDefaultRuleSets
(boolean disable) Disables default rule sets.excludes()
Returns the globbing patterns describing paths to exclude from the analysis.Globbing patterns describing paths to exclude from the analysis.excludes
(Collection<String> patterns) Globbing patterns describing paths to exclude from the analysis.void
execute()
Performs the operation.Part of theexecute()
operation, constructs the command list to use for building the process.fromProject
(BaseProject project) Configures the operation from aBaseProject
.generateConfig
(boolean generate) Export default config.includes()
Returns the globbing patterns describing paths to include in the analysis.Globbing patterns describing paths to include in the analysis.includes
(Collection<String> patterns) Globbing patterns describing paths to include in the analysis.input()
Returns the input paths to analyze.Input paths to analyze.Input paths to analyze.Input paths to analyze.input
(Collection<File> paths) Input paths to analyze.inputPaths
(Collection<Path> paths) Input paths to analyze.inputStrings
(Collection<String> paths) Input paths to analyze.EXPERIMENTAL: Use a custom JDK home directory to include into the classpath.EXPERIMENTAL: Target version of the generated JVM bytecode that was generated during compilation and is now being used for type resolutionlanguageVersion
(String version) EXPERIMENTAL: Compatibility mode for Kotlin language version X.Y, reports errors for all language features that came out later.maxIssues
(int max) Return exit code 0 only when found issues count does not exceed specified issues count.parallel
(boolean parallel) Enables parallel compilation and analysis of source files.plugins()
Extra path to plugins jars.Extra paths to plugin jars.Extra paths to plugin jars.Extra paths to plugin jars.plugins
(Collection<File> jars) Extra paths to plugin jars.pluginsPaths
(Collection<Path> jars) Extra paths to plugin jars.pluginsStrings
(Collection<String> jars) Extra paths to plugin jars.Generates a report for givenreport-id
and stores it on given 'path'.Methods inherited from class rife.bld.operations.AbstractProcessOperation
classpath, classpath, classpath, environment, environment, environment, 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
-
DetektOperation
public DetektOperation()
-
-
Method Details
-
allRules
Activates all available (even unstable) rules.- Parameters:
allRules
-true
orfalse
- Returns:
- this operation instance
-
autoCorrect
Allow rules to autocorrect code if they support it. The default rule sets do NOT support autocorrecting and won't change any line in the users code base. However, custom rules can be written to support autocorrecting. The additional 'formatting' rule set, added withPlugins
, does support it and needs this flag.- Parameters:
autoCorrect
-true
orfalse
- Returns:
- this operation instance
-
basePath
Specifies a directory as the base path. Currently, it impacts all file paths in the formatted reports. File paths in console output and txt report are not affected and remain as absolute paths.- Parameters:
path
- the directory path- Returns:
- this operation instance
-
basePath
Specifies a directory as the base path. Currently, it impacts all file paths in the formatted reports. File paths in console output and txt report are not affected and remain as absolute paths.- Parameters:
path
- the directory path- Returns:
- this operation instance
-
basePath
Retrieves the base path.- Returns:
- the directory path
-
basePath
Specifies a directory as the base path. Currently, it impacts all file paths in the formatted reports. File paths in console output and txt report are not affected and remain as absolute paths.- Parameters:
path
- the directory path- Returns:
- this operation instance
-
baseline
If a baseline xml file is passed in, only new code smells not in the baseline are printed in the console.- Parameters:
baseline
- the baseline xml file- Returns:
- this operation instance
-
baseline
If a baseline xml file is passed in, only new code smells not in the baseline are printed in the console.- Parameters:
baseline
- the baseline xml file- Returns:
- this operation instance
-
baseline
If a baseline xml file is passed in, only new code smells not in the baseline are printed in the console.- Parameters:
baseline
- the baseline xml file- Returns:
- this operation instance
-
baseline
Retrieves the baseline xml file.- Returns:
- the baseline xml file
-
buildUponDefaultConfig
Preconfigures detekt with a bunch of rules and some opinionated defaults for you. Allows additional provided configurations to override the defaults.- Parameters:
buildUponDefaultConfig
-true
orfalse
- Returns:
- this operation instance
-
classPath
EXPERIMENTAL: Paths where to find user class files and jar dependencies. Used for type resolution.- Parameters:
paths
- one or more files- Returns:
- this operation instance
- See Also:
-
classPath
EXPERIMENTAL: Paths where to find user class files and jar dependencies. Used for type resolution.- Parameters:
paths
- one or more files- Returns:
- this operation instance
- See Also:
-
classPath
EXPERIMENTAL: Paths where to find user class files and jar dependencies. Used for type resolution.- Parameters:
paths
- one or more files- Returns:
- this operation instance
- See Also:
-
classPath
EXPERIMENTAL: Paths where to find user class files and jar dependencies. Used for type resolution.- Parameters:
paths
- the paths- Returns:
- this operation instance
- See Also:
-
classPath
Paths where to find user class files and jar dependencies.- Returns:
- the paths
-
classPathPaths
EXPERIMENTAL: Paths where to find user class files and jar dependencies. Used for type resolution.- Parameters:
paths
- the paths- Returns:
- this operation instance
- See Also:
-
classPathStrings
EXPERIMENTAL: Paths where to find user class files and jar dependencies. Used for type resolution.- Parameters:
paths
- the paths- Returns:
- this operation instance
- See Also:
-
config
Paths to the config files (path/to/config.yml
).- Parameters:
configs
- one or more config files- Returns:
- this operation instance
- See Also:
-
config
Paths to the config files (path/to/config.yml
).- Parameters:
configs
- one or more config files- Returns:
- this operation instance
- See Also:
-
config
Paths to the config files (path/to/config.yml
).- Parameters:
configs
- one or more config files- Returns:
- this operation instance
- See Also:
-
config
Paths to the config files (path/to/config.yml
).- Parameters:
configs
- the config files- Returns:
- this operation instance
- See Also:
-
config
Paths to config files.- Returns:
- the config files paths.
-
configPaths
Paths to the config files (path/to/config.yml
).- Parameters:
configs
- the config files- Returns:
- this operation instance
- See Also:
-
configResource
Path to the config resource on detekt's classpath (path/to/config.yml
).- Parameters:
resource
- the config resource path- Returns:
- this operation instance
-
configResource
Path to the config resource on detekt's classpath (path/to/config.yml
).- Parameters:
resource
- the config resource path- Returns:
- this operation instance
-
configResource
Path to the config resource on detekt's classpath (path/to/config.yml
).- Parameters:
resource
- the config resource path- Returns:
- this operation instance
-
configResource
Retrieves the path of the config resource.- Returns:
- the config resource path
-
configStrings
Paths to the config files (path/to/config.yml
).- Parameters:
configs
- the config files- Returns:
- this operation instance
- See Also:
-
createBaseline
Treats current analysis findings as a smell baseline for future detekt runs.- Parameters:
createBaseline
-true
orfalse
- Returns:
- this operation instance
-
debug
Prints extra information about configurations and extensions.- Parameters:
debug
-true
orfalse
- Returns:
- this operation instance
-
disableDefaultRuleSets
Disables default rule sets.- Parameters:
disable
-true
orfalse
- Returns:
- this operation instance
-
excludes
Globbing patterns describing paths to exclude from the analysis.- Parameters:
patterns
- one or more pattern- Returns:
- this operation instance
-
excludes
Globbing patterns describing paths to exclude from the analysis.- Parameters:
patterns
- a collection of patterns- Returns:
- this operation instance
-
excludes
Returns the globbing patterns describing paths to exclude from the analysis.- Returns:
- the globbing patterns
-
execute
Performs the operation.- Overrides:
execute
in classAbstractProcessOperation<DetektOperation>
- Throws:
InterruptedException
- when the operation was interruptedIOException
- when an exception occurred during the execution of the processExitStatusException
- when the exit status was changed during the operation
-
executeConstructProcessCommandList
Part of theexecute()
operation, constructs the command list to use for building the process.- Specified by:
executeConstructProcessCommandList
in classAbstractProcessOperation<DetektOperation>
-
fromProject
Configures the operation from aBaseProject
.Sets the following:
- Specified by:
fromProject
in classAbstractProcessOperation<DetektOperation>
- Parameters:
project
- the project to configure the operation from- Returns:
- this operation instance
-
generateConfig
Export default config. Path can be specified withconfig
option.Default path:
default-detekt-config.yml
- Parameters:
generate
-true
orfalse
- Returns:
- this operation instance
-
includes
Globbing patterns describing paths to include in the analysis. Useful in combination withexcludes
patterns.- Parameters:
patterns
- one or more patterns- Returns:
- this operation instance
-
includes
Globbing patterns describing paths to include in the analysis. Useful in combination withexcludes
patterns.- Parameters:
patterns
- a collection of patterns- Returns:
- this operation instance
-
includes
Returns the globbing patterns describing paths to include in the analysis.- Returns:
- the globbing patterns
-
input
Input paths to analyze. If not specified the current working directory is used.- Parameters:
paths
- the paths- Returns:
- this operation instance
- See Also:
-
input
Input paths to analyze. If not specified the current working directory is used.- Parameters:
paths
- one or more paths- Returns:
- this operation instance
- See Also:
-
input
Input paths to analyze. If not specified the current working directory is used.- Parameters:
paths
- one or more paths- Returns:
- this operation instance
- See Also:
-
input
Input paths to analyze. If not specified the current working directory is used.- Parameters:
paths
- one or more paths- Returns:
- this operation instance
- See Also:
-
input
Returns the input paths to analyze.- Returns:
- the input paths
-
inputPaths
Input paths to analyze. If not specified the current working directory is used.- Parameters:
paths
- the paths- Returns:
- this operation instance
- See Also:
-
inputStrings
Input paths to analyze. If not specified the current working directory is used.- Parameters:
paths
- the paths- Returns:
- this operation instance
- See Also:
-
jdkHome
EXPERIMENTAL: Use a custom JDK home directory to include into the classpath.- Parameters:
path
- the JDK home directory path- Returns:
- this operation instance
-
jvmTarget
EXPERIMENTAL: Target version of the generated JVM bytecode that was generated during compilation and is now being used for type resolutionDefault: 1.8
- Parameters:
target
- the target version- Returns:
- this operation instance
-
languageVersion
EXPERIMENTAL: Compatibility mode for Kotlin language version X.Y, reports errors for all language features that came out later.Possible Values: [1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1]
- Parameters:
version
- the version- Returns:
- this operation instance
-
maxIssues
Return exit code 0 only when found issues count does not exceed specified issues count.- Parameters:
max
- the issues code- Returns:
- this operation instance
-
parallel
Enables parallel compilation and analysis of source files. Do some benchmarks first before enabling this flag. Heuristics show performance benefits starting from 2000 lines of Kotlin code.- Parameters:
parallel
-true
orfalse
- Returns:
- this operation instance
-
plugins
Extra paths to plugin jars.- Parameters:
jars
- one or more jars- Returns:
- this operation instance
- See Also:
-
plugins
Extra paths to plugin jars.- Parameters:
jars
- one or more jars- Returns:
- this operation instance
- See Also:
-
plugins
Extra paths to plugin jars.- Parameters:
jars
- one or more jars- Returns:
- this operation instance
- See Also:
-
plugins
Extra paths to plugin jars.- Parameters:
jars
- the jars paths- Returns:
- this operation instance
- See Also:
-
plugins
Extra path to plugins jars.- Returns:
- the jars paths
-
pluginsPaths
Extra paths to plugin jars.- Parameters:
jars
- the jars paths- Returns:
- this operation instance
- See Also:
-
pluginsStrings
Extra paths to plugin jars.- Parameters:
jars
- the jars paths- Returns:
- this operation instance
- See Also:
-
report
Generates a report for givenreport-id
and stores it on given 'path'.- Parameters:
reports
- one or more reports- Returns:
- this operation instance
-