Install the cli
There are different ways to install the Command Line Interface (CLI):
brew install detekt
scoop install detekt
curl -sSLO https://github.com/detekt/detekt/releases/download/v1.22.0-RC1/detekt-cli-1.22.0-RC1.zip
Use the cli
detekt will exit with one of the following exit codes:
|0||detekt ran normally and maxIssues count was not reached in BuildFailureReport.|
|1||An unexpected error occurred|
|2||MaxIssues count was reached in BuildFailureReport.|
|3||Invalid detekt configuration file detected.|
The following parameters are shown when
--help is entered.
Usage: detekt [options]
Activates all available (even unstable) rules.
Allow rules to auto correct code if they support it. The default rule
sets do NOT support auto correcting and won't change any line in the
users code base. However custom rules can be written to support auto
correcting. The additional 'formatting' rule set, added with
'--plugins', does support it and needs this flag.
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.
If a baseline xml file is passed in, only new code smells not in the
baseline are printed in the console.
Preconfigures detekt with a bunch of rules and some opinionated defaults
for you. Allows additional provided configurations to override the
EXPERIMENTAL: Paths where to find user class files and depending jar
files. Used for type resolution.
Path to the config file (path/to/config.yml). Multiple configuration
files can be specified with ',' or ';' as separator.
Path to the config resource on detekt's classpath (path/to/config.yml).
Treats current analysis findings as a smell baseline for future detekt
Prints extra information about configurations and extensions.
Disables default rule sets.
Globbing patterns describing paths to exclude from the analysis.
DEPRECATED: please use '--build-upon-default-config' together with
'--all-rules'. Same as 'build-upon-default-config' but explicitly
running all available rules. With this setting only exit code 0 is
returned when the analysis does not find a single code smell. Additional
configuration files can override rule properties which includes turning
off specific rules.
Export default config. Path can be specified with --config option
(default path: default-detekt-config.yml)
Shows the usage.
Globbing patterns describing paths to include in the analysis. Useful in
combination with 'excludes' patterns.
Input paths to analyze. Multiple paths are separated by comma. If not
specified the current working directory is used.
EXPERIMENTAL: Target version of the generated JVM bytecode that was
generated during compilation and is now being used for type resolution
(1.6, 1.8, 9, 10, 11, 12, 13, 14, 15, 16 or 17)
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]
Return exit code 0 only when found issues count does not exceed
specified issues count.
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.
Extra paths to plugin jars separated by ',' or ';'.
Generates a report for given 'report-id' and stores it on given 'path'.
Entry should consist of: [report-id:path]. Available 'report-id' values:
'txt', 'xml', 'html', 'md', 'sarif'. These can also be used in
combination with each other e.g. '-r txt:reports/detekt.txt -r
Prints the detekt CLI version.