# detekt

Cody Engel

02/04/2020, 7:14 PM
Is there a good way to reuse exclude patterns with detekt? I’ve found it’s a lot of copy/paste of
excludes: "**/*Test.kt"


02/05/2020, 12:27 PM
There is no direct way to reuse a pattern. Perhaps this might come handy to you to achieve the same result:


02/05/2020, 1:55 PM
Unfortunately this doesn't help. The scenario is still wanting test classes scanned, but with a looser rule set. Neither approach was great. In one, you weren't sure what a rule was for test vs non-test code BUT you only had to define your test pattern once. The new allows you to see what a rule will do for all scenarios, but requires many updates if your test class pattern changes. It does allow for flexible test patterns, though. I suspect part of the motivation is MPP support? I don't know how feasible it is to add 'properties' to the config file. So I could define a property of `TEST_PATTERN`` and reference that in my excludes.

Cody Engel

02/05/2020, 7:42 PM
I think in this case using the include/exclude would suffice for my use case. While it’d be great for the test classes to conform to most of the rules, if they don’t it’s really not the end of the world imo
I’ve been upgrading from RC8 so a lot has changed 😅