Edit me

detekt uses a yaml style configuration file for various things:

  • rule set and rule properties
  • build failure
  • test-pattern to exclude rule sets/rules for test classes
  • processors
  • console and output formats
  • autoCorrect support

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 --build-upon-default-config flag.

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 20 functions inside a kotlin file instead of the default threshold of 10, write:

    threshold: 20

To read about all supported rule sets and rules, use the side navigation Rule Sets.


The configuration file contains a whole section to treat test code differently. Specify test patterns to detect test code and exclude rules or rule sets for them.

test-pattern: # Configure exclusions for test sources
  active: true
  patterns: # Test file regexes
    - '.*/test/.*'
    - '.*Test.kt'
    - '.*Spec.kt'
    - 'comments'
    - 'NamingRules'
    - 'WildcardImport'
    - 'MagicNumber'
    - 'MaxLineLength'
    - 'LateinitUsage'
    - 'StringLiteralDuplication'
    - 'SpreadOperator'
    - 'TooManyFunctions'

Console and Output Reports

Uncomment the reporters you don’t care about.

  active: true
  #  - 'ProjectStatisticsReport'
  #  - 'ComplexityReport'
  #  - 'NotificationReport'
  #  - 'FindingsReport'
  #  - 'BuildFailureReport'

  active: true
  #  - 'HtmlOutputReport'
  #  - 'TxtOutputReport'
  #  - 'XmlOutputReport'


Processors are usually used to raise project metrics. Uncomment the ones you do not care about.

  active: true
  # - 'FunctionCountProcessor'
  # - 'PropertyCountProcessor'
  # - 'ClassCountProcessor'
  # - 'PackageCountProcessor'
  # - 'KtFileCountProcessor'

autoCorrect property

This option is still present due to legacy reasons. In the first milestone releases detekt also formatted kotlin code. Within the detekt team we decided to not mess with user code and let other tools do the formatting eg. intellij or KtLint. Still as detekt can be extended with custom rules, you are free to write rules which support auto correction. Only write correcting code within the withAutoCorrect()-function.