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
Add option to add a reason to ForbiddenImport
#4909
Conversation
Codecov Report
@@ Coverage Diff @@
## main #4909 +/- ##
=========================================
Coverage 84.83% 84.84%
- Complexity 3511 3515 +4
=========================================
Files 497 497
Lines 11548 11551 +3
Branches 2138 2142 +4
=========================================
+ Hits 9797 9800 +3
Misses 686 686
Partials 1065 1065
Continue to review full report at Codecov.
|
...t-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenImportSpec.kt
Outdated
Show resolved
Hide resolved
detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenImport.kt
Outdated
Show resolved
Hide resolved
…/rules/style/ForbiddenImportSpec.kt Co-authored-by: marschwar <marschwar@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
* Improve tests * Improve issue message * Add utility to help testing ValueWithReason configurations * Add support for reasons in ForbiddenImport * Improve non-compilant * Update detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenImportSpec.kt Co-authored-by: marschwar <marschwar@users.noreply.github.com> * data class Co-authored-by: marschwar <marschwar@users.noreply.github.com>
There is no documentation for this? I got here from release notes, and I'm wondering how to use this [edit] Looks like this works for example: ForbiddenImport:
active: true
imports:
- reason: 'Use Kotest assertions instead.'
value: 'org.junit.Assert'
- reason: 'Use Kotest assertions instead.'
value: 'org.junit.Assert.*' |
Probably it is not. Do you want to create a PR to help improve the documentation? |
I'm really happy to be able to introduce this feature :). Thanks @marschwar for creating the necesary tooling to be able to implement it.
Important: This introduces a breaking change in
ForbiddenImport
. It no longer allows comma-separated imports as a String. It should use yml lists. I'm targetting this to1.22.0
because on1.21.0
we added make that all those usages will be a warning. Tell me is we should be more conservative.The reason that this is a draft is just to avoid accidental merges. But the code should be ready to merge.
Related with #3501