Hello :wave: have a usecase where I want to ignor...
# detekt
s
Hello 👋 have a usecase where I want to ignore LongMethod if the method has a specific name. Is that possible?
g
That’s currently not supported. But it’s probably valid to be added as a config 🤔 What’s your specific use case?
s
We use Airbnb's Epoxy Controllers to write screens which could be seen as a programmatic way of filling vertical linear layouts in recyclerviews. This is a small example but you can get the idea. In some scenarios we have long controllers with different epoxy views. We were extracting into different methods to avoid the long method but we feel like it is also okay to leave it all in the same method since it is linear
So my usecase would be something like: ignore methods named
getController
t
Some would argue that it is really a long method but does not have to be. Can you split it? I don't have much experience with Epoxy but having such long methods with logic spread in the lines are invitation for bugs.
g
As a rule of thumb, we try to avoid having framework specific customization in detekt.
ignore methods named 
getController
We could do something like this, but this will catch all the
getController
in your codebase. Even those that are not Epoxy related (you would have to customize the rule to refine the inspection…)
My suggestion is that either: • You increase the
LongMethod
threshold for this rule • You fork the rule and have a custom implementation with your filtering • You refactor the code as @taso suggested (like you could extract the
designTextInputLayout
body into another function)
👍 2
s
Thanks for the suggestions and apologies on the late reply, due to the above being considered more UI logic that it is linear it looks strange to extract into methods just for detekt compliance. I will look into the custom implementation although it could be global for everyone if we have something like MagicNumber exclude but for method names, we could just rename getController to something more specific
Copy code
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
g
I see. Don't you mind opening an issue on detekt to discuss this?
s
Sure! Will do that today
👍 1
https://github.com/detekt/detekt/issues/3251 hope I explained it properly 😄 thanks for the help!