Class DetektOperation
- 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.analysisMode(AnalysisMode mode) Sets the analysis mode used by detekt.apiVersion(@Nullable ApiVersion version) Kotlin API version used by the code under analysis.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 default for you.Paths where to find user class files and jar dependencies.Paths where to find user class files and jar dependencies.Paths where to find user class files and jar dependencies.Paths where to find user class files and jar dependencies.final DetektOperationclassPath(Collection<File> paths) Paths where to find user class files and jar dependencies.final DetektOperationclassPathPaths(Collection<Path> paths) Paths where to find user class files and jar dependencies.final DetektOperationclassPathStrings(Collection<String> paths) 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).final DetektOperationconfig(Collection<File> configs) Paths to the config files (path/to/config.yml).final DetektOperationconfigPaths(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).final DetektOperationconfigStrings(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.final DetektOperationexcludes(Collection<String> patterns) Globbing patterns describing paths to exclude from the analysis.voidexecute()Performs the operation.Part of theexecute()operation, constructs the command list to use for building the process.failOnSeverity(Severity severity) Specifies the minimum severity that causes the build to fail.fromProject(BaseProject project) Configures the operation from aBaseProject.Retrieves the path of the generated config.generateConfig(File path) Export default config to the provided path.generateConfig(String path) Export default config to the provided path.generateConfig(Path path) Export default config to the provided path.includes()Returns the globbing patterns describing paths to include in the analysis.Globbing patterns describing paths to include in the analysis.final DetektOperationincludes(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 analyzeInput paths to analyze.final DetektOperationinput(Collection<File> paths) Input paths to analyze.final DetektOperationinputPaths(Collection<Path> paths) Input paths to analyze.final DetektOperationinputStrings(Collection<String> paths) Input paths to analyze.jdkHome()Retrieves the JDK home directory.Use a custom JDK home directory to include into the classpath.Use a custom JDK home directory to include into the classpath.Use a custom JDK home directory to include into the classpath.Target version of the generated JVM bytecode that was generated during compilation and is now being used for type resolution.languageVersion(@Nullable LanguageVersion version) Compatibility mode for Kotlin language version X.Y, reports errors for all language features that came out later.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.final DetektOperationplugins(Collection<File> jars) Extra paths to plugin jars.final DetektOperationpluginsPaths(Collection<Path> jars) Extra paths to plugin jars.final DetektOperationpluginsStrings(Collection<String> jars) Extra paths to plugin jars.Generates a report for givenreport-idand stores it on given 'path'.Methods inherited from class rife.bld.operations.AbstractProcessOperation
classpath, classpath, classpath, classpath, classpath, environment, environment, environment, errorProcessor, errorProcessor, executeStartProcess, javaOptions, javaOptions, javaTool, javaTool, mainClass, mainClass, module, module, modulePath, modulePath, modulePath, modulePath, modulePath, outputProcessor, outputProcessor, process, workDirectory, workDirectoryMethods inherited from class rife.bld.operations.AbstractOperation
executeOnce, executeOnce, silent, silent, verbose, verbose
-
Constructor Details
-
DetektOperation
public DetektOperation()
-
-
Method Details
-
execute
Performs the operation.- Overrides:
executein 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 operationNullPointerException- ifprojectisnull
-
executeConstructProcessCommandList
Part of theexecute()operation, constructs the command list to use for building the process.- Specified by:
executeConstructProcessCommandListin classAbstractProcessOperation<DetektOperation>
-
fromProject
Configures the operation from aBaseProject.Sets the following:
- The
baselinetodetekt-baseline.xml, if it exists in the project's work directory - The
excludesto excludebuildandresourcesdirectories, if not already set - The Detekt classpath from JARS in the
project's bld lib directory
- Specified by:
fromProjectin classAbstractProcessOperation<DetektOperation>- Parameters:
project- the project to configure the operation from- Returns:
- this operation instance
- Throws:
NullPointerException- ifprojectisnull
- The
-
allRules
Activates all available (even unstable) rules.Default is
false- Parameters:
allRules-trueorfalse- Returns:
- this operation instance
-
analysisMode
Sets the analysis mode used by detekt.AnalysisMode.FULL- Comprehensive but requires the correct compiler options to be provided.AnalysisMode.LIGHT- Cannot utilize compiler information and some rules cannot be run in this mode.
AnalysisMode.LIGHT- Parameters:
mode- the analysis mode- Returns:
- this operation instance
- Throws:
NullPointerException- ifmodeisnull
-
apiVersion
Kotlin API version used by the code under analysis.Some rules use this information to provide more specific rule violation messages.
- Parameters:
version- the api version- 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 'ktlint' rule set, added with
Plugins, does support it and needs this flag.Default is
false- Parameters:
autoCorrect-trueorfalse- 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 are not affected and remain as absolute paths.
- Parameters:
path- the directory path- Returns:
- this operation instance
- Throws:
NullPointerException- ifpathisnullIllegalArgumentException- ifpathis empty or blank- See Also:
-
basePath
Specifies a directory as the base path.Currently, it impacts all file paths in the formatted reports. File paths in console output are not affected and remain as absolute paths.
- Parameters:
path- the directory path- Returns:
- this operation instance
- Throws:
NullPointerException- ifpathisnull- See Also:
-
basePath
Retrieves the base path.- Returns:
- the directory path
- See Also:
-
basePath
Specifies a directory as the base path.Currently, it impacts all file paths in the formatted reports. File paths in console output are not affected and remain as absolute paths.
- Parameters:
path- the directory path- Returns:
- this operation instance
- Throws:
NullPointerException- ifpathisnull- See Also:
-
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
- Throws:
NullPointerException- ifbaselineisnullIllegalArgumentException- ifbaselineis empty or blank- See Also:
-
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
- Throws:
NullPointerException- ifbaselineisnull- See Also:
-
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
- Throws:
NullPointerException- ifbaselineisnull- See Also:
-
baseline
Retrieves the baseline XML file.- Returns:
- the baseline XML file
- See Also:
-
buildUponDefaultConfig
Preconfigures detekt with a bunch of rules and some opinionated default for you.Allows additional provided configurations to override the defaults.
- Parameters:
buildUponDefaultConfig-trueorfalse- Returns:
- this operation instance
-
classPath
Paths where to find user class files and jar dependencies.Used for type resolution.
- Parameters:
paths- one or more files- Returns:
- this operation instance
- Throws:
NullPointerException- ifpathsisnullor containsnullelementsIllegalArgumentException- ifpathsis empty- See Also:
-
classPath
Paths where to find user class files and jar dependencies.Used for type resolution.
- Parameters:
paths- one or more files- Returns:
- this operation instance
- Throws:
NullPointerException- ifpathsisnullor containsnullelementsIllegalArgumentException- ifpathsis empty- See Also:
-
classPath
Paths where to find user class files and jar dependencies.Used for type resolution.
- Parameters:
paths- one or more files- Returns:
- this operation instance
- Throws:
NullPointerException- ifpathsisnullor containsnullelementsIllegalArgumentException- ifpathsis empty or contains empty elements- See Also:
-
classPath
Paths where to find user class files and jar dependencies.Used for type resolution.
- Parameters:
paths- the paths- Returns:
- this operation instance
- Throws:
NullPointerException- ifpathsisnullor containsnullelementsIllegalArgumentException- ifpathsis empty- See Also:
-
classPath
Paths where to find user class files and jar dependencies.- Returns:
- the classpath
-
classPathPaths
Paths where to find user class files and jar dependencies.Used for type resolution.
- Parameters:
paths- the paths- Returns:
- this operation instance
- Throws:
NullPointerException- ifpathsisnullor containsnullelementsIllegalArgumentException- ifpathsis empty- See Also:
-
classPathStrings
Paths where to find user class files and jar dependencies.Used for type resolution.
- Parameters:
paths- the paths- Returns:
- this operation instance
- Throws:
NullPointerException- ifpathsisnullor containsnullelementsIllegalArgumentException- ifpathsis empty or contains empty elements- See Also:
-
config
Paths to the config files (path/to/config.yml).- Parameters:
configs- one or more config files- Returns:
- this operation instance
- Throws:
NullPointerException- ifconfigsisnullor containsnullelementsIllegalArgumentException- ifconfigsis empty- See Also:
-
config
Paths to the config files (path/to/config.yml).- Parameters:
configs- one or more config files- Returns:
- this operation instance
- Throws:
NullPointerException- ifconfigsisnullor containsnullelementsIllegalArgumentException- ifconfigsis empty- See Also:
-
config
Paths to the config files (path/to/config.yml).- Parameters:
configs- one or more config files- Returns:
- this operation instance
- Throws:
NullPointerException- ifconfigsisnullor containsnullelementsIllegalArgumentException- ifconfigsis empty or contains empty elements- See Also:
-
config
Paths to the config files (path/to/config.yml).- Parameters:
configs- the config files- Returns:
- this operation instance
- Throws:
NullPointerException- ifconfigsisnullor containsnullelementsIllegalArgumentException- ifconfigsis empty- 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
- Throws:
NullPointerException- ifconfigsisnullor containsnullelementsIllegalArgumentException- ifconfigsis empty- 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
- Throws:
NullPointerException- ifresourceisnullIllegalArgumentException- ifresourceis empty or blank- 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
- Throws:
NullPointerException- ifresourceisnull- 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
- Throws:
NullPointerException- ifresourceisnull- See Also:
-
configResource
Retrieves the path of the config resource.- Returns:
- the config resource path
- See Also:
-
configStrings
Paths to the config files (path/to/config.yml).- Parameters:
configs- the config files- Returns:
- this operation instance
- Throws:
NullPointerException- ifconfigsisnullor containsnullelementsIllegalArgumentException- ifconfigsis empty or contains empty elements- See Also:
-
createBaseline
Treats current analysis findings as a smell baseline for future detekt runs.Default is
false- Parameters:
createBaseline-trueorfalse- Returns:
- this operation instance
-
debug
Prints extra information about configurations and extensions.Default is
false- Parameters:
debug-trueorfalse- Returns:
- this operation instance
-
disableDefaultRuleSets
Disables default rule sets.Default is
false- Parameters:
disable-trueorfalse- Returns:
- this operation instance
-
excludes
Globbing patterns describing paths to exclude from the analysis.- Parameters:
patterns- one or more pattern- Returns:
- this operation instance
- Throws:
NullPointerException- ifpatternsisnullor containsnullelementsIllegalArgumentException- ifpatternsis empty or contains empty elements- See Also:
-
excludes
Globbing patterns describing paths to exclude from the analysis.- Parameters:
patterns- a collection of patterns- Returns:
- this operation instance
- Throws:
NullPointerException- ifpatternsisnullor containsnullelementsIllegalArgumentException- ifpatternsis empty or contains empty elements- See Also:
-
excludes
Returns the globbing patterns describing paths to exclude from the analysis.- Returns:
- the globbing patterns
-
failOnSeverity
Specifies the minimum severity that causes the build to fail.When the value is set to
Severity.NEVERdetekt will not fail regardless of the number of issues and their severities.Default is
Severity.ERROR- Parameters:
severity- the severity- Returns:
- this operation instance
- Throws:
NullPointerException- ifseverityisnull
-
generateConfig
Export default config to the provided path.- Parameters:
path- the path- Returns:
- this operation instance
- Throws:
NullPointerException- ifpathisnullIllegalArgumentException- ifpathis empty or blank- See Also:
-
generateConfig
Export default config to the provided path.- Parameters:
path- the path- Returns:
- this operation instance
- Throws:
NullPointerException- ifpathisnull- See Also:
-
generateConfig
Export default config to the provided path.- Parameters:
path- the path- Returns:
- this operation instance
- Throws:
NullPointerException- ifpathisnull- See Also:
-
generateConfig
Retrieves the path of the generated config.- Returns:
- the config path
- See Also:
-
includes
Globbing patterns describing paths to include in the analysis.Useful in combination with
excludespatterns.- Parameters:
patterns- one or more patterns- Returns:
- this operation instance
- Throws:
NullPointerException- ifpatternsisnullor containsnullelementsIllegalArgumentException- ifpatternsis empty or contains empty elements- See Also:
-
includes
Globbing patterns describing paths to include in the analysis.Useful in combination with
excludespatterns.- Parameters:
patterns- a collection of patterns- Returns:
- this operation instance
- Throws:
NullPointerException- ifpatternsisnullor containsnullelementsIllegalArgumentException- ifpatternsis empty or contains empty elements- See Also:
-
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
- Throws:
NullPointerException- ifpathsisnullor containsnullelementsIllegalArgumentException- ifpathsis empty- See Also:
-
input
Input paths to analyzeIf not specified the current working directory is used.
- Parameters:
paths- one or more paths- Returns:
- this operation instance
- Throws:
NullPointerException- ifpathsisnullor containsnullelementsIllegalArgumentException- ifpathsis empty or contains empty elements- 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
- Throws:
NullPointerException- ifpathsisnullor containsnullelementsIllegalArgumentException- ifpathsis empty- 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
- Throws:
NullPointerException- ifpathsisnullor containsnullelementsIllegalArgumentException- ifpathsis empty- 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
- Throws:
NullPointerException- ifpathsisnullor containsnullelementsIllegalArgumentException- ifpathsis empty- See Also:
-
inputStrings
Input paths to analyze.If not specified the current working directory is used.
- Parameters:
paths- the paths- Returns:
- this operation instance
- Throws:
NullPointerException- ifpathsisnullor containsnullelementsIllegalArgumentException- ifpathsis empty or contains empty elements- See Also:
-
jdkHome
Use a custom JDK home directory to include into the classpath.- Parameters:
path- the JDK home directory path- Returns:
- this operation instance
- Throws:
NullPointerException- ifpathisnullIllegalArgumentException- ifpathis blank- See Also:
-
jdkHome
Use a custom JDK home directory to include into the classpath.- Parameters:
path- the JDK home directory path- Returns:
- this operation instance
- Throws:
NullPointerException- ifpathisnull- See Also:
-
jdkHome
Use a custom JDK home directory to include into the classpath.- Parameters:
path- the JDK home directory path- Returns:
- this operation instance
- Throws:
NullPointerException- ifpathisnull- See Also:
-
jdkHome
Retrieves the JDK home directory.- Returns:
- the JDK home directory path
- See Also:
-
jvmTarget
Target version of the generated JVM bytecode that was generated during compilation and is now being used for type resolution.Default: 1.8
- Parameters:
target- the target version- Returns:
- this operation instance
- Throws:
NullPointerException- iftargetisnull
-
languageVersion
Compatibility mode for Kotlin language version X.Y, reports errors for all language features that came out later.- Parameters:
version- the version- Returns:
- this operation instance
- Throws:
NullPointerException- ifversionisnull
-
parallel
Enables parallel compilation and analysis of source files.Do some benchmarks first before enabling this flag. Heuristics show performance benefits starting from 000 lines of Kotlin code.
Default is
false- Parameters:
parallel-trueorfalse- Returns:
- this operation instance
-
plugins
Extra paths to plugin jars.- Parameters:
jars- one or more jars- Returns:
- this operation instance
- Throws:
NullPointerException- ifjarsisnullor containsnullelementsIllegalArgumentException- ifjarsis empty or contains empty elements- See Also:
-
plugins
Extra paths to plugin jars.- Parameters:
jars- one or more jars- Returns:
- this operation instance
- Throws:
NullPointerException- ifjarsisnullor containsnullelementsIllegalArgumentException- ifjarsis empty- See Also:
-
plugins
Extra paths to plugin jars.- Parameters:
jars- one or more jars- Returns:
- this operation instance
- Throws:
NullPointerException- ifjarsisnullor containsnullelementsIllegalArgumentException- ifjarsis empty- See Also:
-
plugins
Extra paths to plugin jars.- Parameters:
jars- the jars paths- Returns:
- this operation instance
- Throws:
NullPointerException- ifjarsisnullor containsnullelementsIllegalArgumentException- ifjarsis empty- 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
- Throws:
NullPointerException- ifjarsisnullor containsnullelementsIllegalArgumentException- ifjarsis empty- See Also:
-
pluginsStrings
Extra paths to plugin jars.- Parameters:
jars- the jars paths- Returns:
- this operation instance
- Throws:
NullPointerException- ifjarsisnullor containsnullelementsIllegalArgumentException- ifjarsis empty or contains empty elements- See Also:
-
report
Generates a report for givenreport-idand stores it on given 'path'.- Parameters:
reports- one or more reports- Returns:
- this operation instance
- Throws:
NullPointerException- ifreportsisnullor containsnullelementsIllegalArgumentException- ifreportsis empty
-