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 users and rule authors to specify a reason per configured value #4611
Conversation
detekt-api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/ConfigProperty.kt
Outdated
Show resolved
Hide resolved
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.
* I do not really like the nameof the `ExplainedValues` type and `explainedValues` config delegate. Any idea what we could call the combination of a configured value and the reasoning why the value is configured?
ValueWithReason
? I don't think it's better... it's the only other option that I find.
* Do you agree on the representation in the `config.yml` (see `detekt-core/src/test/resources/explained-values.yml`)?
I like it.
* Should the reason be shown in the documentation? If so, any ideas on how to do that? (This would be a separate PR)
I don't think so. I don't think that it could provide any value for the reader.
detekt-api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/ConfigProperty.kt
Outdated
Show resolved
Hide resolved
detekt-api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/ConfigProperty.kt
Outdated
Show resolved
Hide resolved
detekt-api/src/test/kotlin/io/gitlab/arturbosch/detekt/api/ConfigPropertySpec.kt
Outdated
Show resolved
Hide resolved
…figProperty.kt Co-authored-by: Brais Gabín <braisgabin@gmail.com>
…figProperty.kt Co-authored-by: Brais Gabín <braisgabin@gmail.com>
I think I also prefer |
I haven't looked into the code, but if I understand correctly it relies on a separate explained-values.yml file right? I would rather move this file inside the config on a top level |
No, that is not correct the ForbiddenImport:
active: true
imports:
- 'org.assertj.core.api.Assertions' it could become ForbiddenImport:
active: true
imports:
- value: 'org.assertj.core.api.Assertions'
reason: 'import Assertions.assertThat directly' |
Codecov Report
@@ Coverage Diff @@
## main #4611 +/- ##
============================================
- Coverage 84.80% 84.73% -0.08%
Complexity 3453 3453
============================================
Files 492 493 +1
Lines 11328 11397 +69
Branches 2086 2103 +17
============================================
+ Hits 9607 9657 +50
- Misses 673 682 +9
- Partials 1048 1058 +10
Continue to review full report at Codecov.
|
Gotcha 👍 Looks great then. |
Could we add this feature with 1.21? |
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.
Sorry for the late review! I missed the notification about this.
@marschwar I think that we can merge this. Could you fix the conflicts? |
…-reasons # Conflicts: # detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/ConfigurationSpec.kt # detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/RuleCollectorSpec.kt
I have yet to figure out how to format the RuleCollectorSpec |
Ready to be merged from my point of view unless you would like me to add more tests? |
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.
Good to go
Thank you!
What does this PR address?
A few times there was the request to be able to specify a custom error message or a reason for certain setting. See #3501 for example. This will allow rule authors to enable this features for all rules that have configurable list of string values such as
This is only providing the option to do so and does not change any rules.
Thanks to @BraisGabin for collaborating on this.