https://kotlinlang.org logo
#detekt
Title
# detekt
r

rocketraman

10/05/2023, 6:06 PM
Is there any way to override detekt rules in a certain package? More in 🧵.
The use case is that I have a package which contains classes which are db migrations. The classes are named
0000_Something
which conflicts with my global
ClassNaming
. Obviously I can suppress
ClassNaming
for every class, but it would be nice to just have a rule in that package which actually enforces a different
ClassNaming
.
m

mkrussel

10/05/2023, 6:22 PM
I know you can exclude the files in the package from the check to avoid needing to suppress. I'm not sure there's a way to have a different rule config though.
r

rocketraman

10/05/2023, 6:25 PM
Where would you exclude the package?
m

mkrussel

10/05/2023, 6:26 PM
Each rule should be configurable with an
excludes
option. https://detekt.dev/docs/introduction/configurations#path-filters--excludes--includes
👍 1
r

rocketraman

10/05/2023, 6:29 PM
That's 25% of the solution, thanks.
b

Brais Gabin

10/05/2023, 8:28 PM
With detekt 2.0 we want to be able to run multiple instances of the same rule. This way you can exclude some paths in one instance and exclude the other paths in other instances. Would that resolve your use case 100%?
👌 1
3 Views