Use annotations to configure rules in rules-complexity#3768
Conversation
The issue message had to be changed as the issue is used to extract the rule id which is used to lookup the threshold from the config.
Codecov Report
@@ Coverage Diff @@
## main #3768 +/- ##
============================================
- Coverage 83.52% 83.46% -0.07%
+ Complexity 2915 2900 -15
============================================
Files 452 452
Lines 8765 8749 -16
Branches 1665 1665
============================================
- Hits 7321 7302 -19
- Misses 542 545 +3
Partials 902 902 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Thanks for pushing this initiative forward. This really improves detekt's code base. No misuse of the comments anymore.
I have a few open questions.
- I guess the
generatormodule also needs an update in order to output the correct website sources. Am I right? - Do we need any other updates to the documentation? I'm thinking about the
Contributing.mdin order to not mislead new contributors or users. Detekt's docs become outdated quite often. It's sometimes forgotten when introducing changes.
|
The |
Cool. I missed this, unfortunately. |
|
|
||
| companion object { | ||
| const val DEFAULT_CONDITIONS_COUNT = 4 | ||
| private const val DEFAULT_CONDITIONS_COUNT = 4 |
There was a problem hiding this comment.
Probably out of scope but I think that inline this values will improve the readability of this code.
There was a problem hiding this comment.
Great point. I was afraid to trigger magic number violations but it seems to work
| "NamedArguments", | ||
| Severity.Maintainability, | ||
| "Function invocation with more than $threshold parameters must all be named", | ||
| "Parameters of function invocation must all be named", |
There was a problem hiding this comment.
Can't we use the threshold? The description that you set here is not correct.
There was a problem hiding this comment.
That is a great catch. Unfortunately that is not possible. When threshold is evaluated, the ruleId is used to lookup the config key. In order to get the ruleId, the issue is created. -> infinite loop
How about: "Prefer named arguments for functions to improve readability." This is semi-consistent with rules like ComplexInterface or ComplexCondition where only the general rule is described without mentioning the exact threshold.
There was a problem hiding this comment.
This is actually a bug today: Even if the threshold in configuration is 4, the issue.description will always be Function invocation with more than 3 parameters must all be named because the existing description is reading value from the threshold constructor argument.
This belongs to #3670 and replaces all configuration kdoc tags in
rules-complexitywith annotations. There are a few decisions to make:simple properties
fallback properties
transformed properties
I am fairly ambivalent about this and I don't know if that is something we even have to agree upon. I am curious about your thoughts.