0

I am adding Detekt to a new project. But, I find that some rules are too strict.

How can I implement my own thresholds for a few rules?

I don't want to use Baseline files, because this is new code and we don't want to consider some things code smells.

LeoColman
  • 6,950
  • 7
  • 34
  • 63
FailedUnitTest
  • 1,637
  • 3
  • 20
  • 43

1 Answers1

1

It's possible to configure Detekt via configuration files.

As per Detekt's documentation, with my emphasis:

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, write:

complexity:
TooManyFunctions:
  thresholdInFiles: 20

You'll want to create a config folder in the root of your project, and add detekt.yaml to it. This config will contain all the rules that you want to override the default, or all the rules (establishing the defaults as the correct value).

For more information, check the official documentation on configuration

LeoColman
  • 6,950
  • 7
  • 34
  • 63