New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow globally defined exclusion pattern #2581
Comments
I like the current way to exclude because it allows you to tune your config a lot. But I have the same problem as @jcornaz. I think that detekt should support the current exclusion method and the proposed in #775 or similar. My proposal is: exclusion-patterns:
- patterns:
- **/test/**
- **/androidTest/**
- **/*.Test.kt
- **/*.Spec.kt
- **/*.Spek.kt
rules:
- VariableNaming
- FunctionNaming
- patterns:
- *DTO.kt
rules:
- Rule4
- Rule8
... |
To give more context I'm going to explain my use case: Every time that I update detekt I run This was not a big problem because I have just a few changes in my configuration file so the changes to check were few. But two month ago I added a new source route for my tests. And now I need to revert 24 lines each time that I update detekt. With the proposed format I should just need to revert one removed line. |
New format proposed in #2851 exclusion-patterns:
- 'dont apply in tests':
patterns:
- '**/test/**'
- '**/androidTest/**'
- '**/commonTest/**'
rules:
- 'comments'
- 'mappers are an special case too':
patterns:
- '**/jvmTest/**'
- '**/jsTest/**'
- '**/iosTest/**'
rules:
- 'potential-bugs>LateinitUsage'
- 'style>MagicNumber'
- 'style>WildcardImport' |
Hi! Any plans on implementing this in a near future? Maybe I can somehow help? I would also benefit from such feature as we have some automatically generated class which break few rules and we don't won't modify n rules configs to skip it. |
Not really. We had some attempts in the past, but none of them landed. |
I think that the last comments about this are here: #3651 (comment) so 2.0 have this feature in its core. If we want to implement this before 2.0, I think that the key should be a It would not be perfect because it would be nice to avoid the run of that rule in those files but maybe it could help. You can even give it a try by your own: https://detekt.github.io/detekt/extensions.html and if you find a general solution we could merge it. |
This issue is stale because it has been open 90 days with no activity. Please comment or this will be closed in 7 days. |
#3251 (comment) should do the trick. Maybe we could add this to the documentation. But I think that we can close this for now. |
Expected Behavior
I would like to be able to globally edit the exclusion patterns, rather than chaning them one by one for each rules.
Current Behavior
Currently each rules has its own exclusion pattern. That leads to a lot of repetition in the config files, and it is especially annoying and error prone when it is time to change the patterns as we are forced to go through all of them one by one.
Context
I introduced new test source sets in a project and I have to tell detekt to ignore that sourceset for a bunch of rules. Which rules? Simple, all the rules that are already excluding the test sources.
But instead of having to change one line to tell detekt what are the patterns of test sources, I have to go through each rules and edit them one by one.
The configuration styled proposed by #775 would have been perfect.
The text was updated successfully, but these errors were encountered: