Detekt
Detekt is a linter for Kotlin.
detekt is composed of several linter commands.
detekt
runs detekt with the built-in default config and any overrides in .detekt.yaml
.
You can enable the detekt
linter with:
detekt-explicit
disables the default config and uses .detekt.yaml
as the source of truth.
You can enable the detekt-explicit
linter with:
detekt-gradle
runs detekt using Gradle. Only use if you already are using Gradle for the rest of your build setup.
You can enable the detekt-gradle
linter with:
Auto Enabling
Detekt will never be auto-enabled. It must be enabled manually.
Settings
Detekt supports the following config files:
.detekt.yaml
You can move these files to .trunk/configs
and trunk check
will still find them. See Moving Linters for more info.
Usage Notes
Detekt is usually invoked through gradle, which allows specifying additional configuration in build.gradle
. We do not yet automatically parse your Gradle scripts to infer your detekt
configuration; instead, what we do is this:
detekt
invokesdetekt-cli
with the--build-upon-default-config
flag (this appears to be more common than the alternative).detekt-explicit
invokesdetekt-cli
without the--build-upon-default-config
flag.
You will also need to provide a valid detekt config as .detekt.yaml
(an empty .detekt.yaml
is valid, if you don't want to configure detekt
). If you already have a detekt config, then you can symlink it like so:
To use ./gradlew detekt
to invoke Detekt, you can add detekt-gradle@SYSTEM
to your enabled
list. Note that since you're running Detekt via Gradle, you should also add the paths to your Detekt configurations to direct_configs
, e.g.
Links
Detekt Trunk Code Quality integration source
Trunk Code Quality's open source plugins repo
Last updated