detekt uses a yaml style configuration file for various things:
- rule set and rule properties
- build failure
- Kotlin file processors
- console and output formats
See the default-detekt-config.yml file for all defined configuration options and their default values.
Note: When using a custom config file, the default values are ignored unless you also set the
Rule sets and rules
detekt allows easily to just pick the rules you want and configure them the way you like. For example if you want to allow up to 20 functions inside a Kotlin file instead of the default threshold of 10, write:
complexity: TooManyFunctions: threshold: 20
To read about all supported rule sets and rules, use the side navigation
Path Filters / Excludes / Includes
Starting with version RC15 fine grained path filters can be defined for each rule or rule set:
complexity: TooManyFunctions: ... excludes: "**/internal/**" includes: "**/internal/util/NeedsToBeChecked.kt"
This gives the user more freedom in analyzing only specific files
and rule authors the ability to write library only rules.
This is the replacement for the
Be aware that detekt now expects globing patterns instead of regular expressions!
Console and Output Reports
Uncomment the reporters you don’t care about.
console-reports: active: true exclude: # - 'ProjectStatisticsReport' # - 'ComplexityReport' # - 'NotificationReport' # - 'FindingsReport' # - 'BuildFailureReport' output-reports: active: true exclude: # - 'HtmlOutputReport' # - 'TxtOutputReport' # - 'XmlOutputReport'
Processors are usually used to raise project metrics. Uncomment the ones you do not care about.
processors: active: true exclude: # - 'FunctionCountProcessor' # - 'PropertyCountProcessor' # - 'ClassCountProcessor' # - 'PackageCountProcessor' # - 'KtFileCountProcessor'