Skip to content
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

merged 7 commits into from Jul 18, 2022

Add option to add a reason to ForbiddenImport #4909

merged 7 commits into from Jul 18, 2022


Copy link

@BraisGabin BraisGabin commented Jun 4, 2022

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 to 1.22.0 because on 1.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

@BraisGabin BraisGabin added this to the 1.22.0 milestone Jun 4, 2022
@BraisGabin BraisGabin marked this pull request as draft June 4, 2022 10:37
Copy link

codecov bot commented Jun 4, 2022

Codecov Report

Merging #4909 (ca80525) into main (5baf1f6) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head ca80525 differs from pull request most recent head 60ea388. Consider uploading reports for the commit 60ea388 to get more accurate results

@@            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           
Impacted Files Coverage Δ
...b/arturbosch/detekt/rules/style/ForbiddenImport.kt 96.00% <100.00%> (+0.54%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5baf1f6...60ea388. Read the comment docs.


Co-authored-by: marschwar <>
Copy link

@marschwar marschwar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


@BraisGabin BraisGabin marked this pull request as ready for review July 18, 2022 08:10
@BraisGabin BraisGabin merged commit b7e4268 into main Jul 18, 2022
@BraisGabin BraisGabin deleted the fix-3501 branch July 18, 2022 12:24
@cortinico cortinico added the notable changes Marker for notable changes in the changelog label Jul 19, 2022
VitalyVPinchuk pushed a commit to VitalyVPinchuk/detekt that referenced this pull request Jul 25, 2022
* 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 <>

* data class

Co-authored-by: marschwar <>
Copy link

arekolek commented Apr 2, 2024

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:

    active: true
      - reason: 'Use Kotest assertions instead.'
        value: 'org.junit.Assert'
      - reason: 'Use Kotest assertions instead.'
        value: 'org.junit.Assert.*'

Copy link
Member Author

Probably it is not. Do you want to create a PR to help improve the documentation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
api notable changes Marker for notable changes in the changelog rules
None yet

Successfully merging this pull request may close these issues.

None yet

4 participants