Hey <@U8L93SRME>. Some rules do allow to change be...
# detekt
m
Hey @Nanchen. Some rules do allow to change behavior depending on the class or depending on Annotations added to certain objects. But in general most projects (also Android) would use one configuration for the entire codebase.
n
Hi @mauin, could you provide the document? I couldn’t find it… thanks~~ And what I wanna do is to use different configurations for different layers, such as: View layer is limited to 300 lines, but Presenter layer is limited to 150 lines… Not sure wether
detekt
could do it in specific classes, such as same configuration in classes which is using same suffix...
m
More detailed documentation for each rule is in the markdown files here: https://github.com/arturbosch/detekt/tree/master/detekt-generator/documentation We’re still working on extracting these markdown files into a simpler UI 🙂
However it might be possible to define different detekt profiles with different configurations. Then you could use the
filters
parameter to exclude certain parts of the codebase from this configuration.
But overall I don’t think we anticipated this use-case so far and are advocating more towards using the same configuration for the entire codebase.
n
Thanks for that, seems
filter
could be a way to resolve my problem, let me try it on my side.😄 On the other hand, in Android project, there are some specific scenarios which we could not use same configuration, there is an example: we have a hight user-interaction view, so we’ll define more than 10 functions in an interface, which will break the
TooManyFunctions
rule… so we wanna filter some specific classes
m
In case there are only few classes which you want to exclude you can also use the
@Suppress
annotation on those classes.
For example if you add a
@Suppress("TooManyFunctions")
annotation to that interface, the rule will not report any issues on that interface.
a
hey @Nanchen you can use different
profiles
for each package by specifying the
input
parameter, in CI you can run mutliple gradle detektCheck -Ddetekt.profile=presenter
n
cool! I will try it, thanks! 😆