Verify at compile time that issue id matches rule name#4047
Conversation
Codecov Report
@@ Coverage Diff @@
## main #4047 +/- ##
=========================================
Coverage 83.45% 83.45%
- Complexity 3181 3182 +1
=========================================
Files 465 465
Lines 9104 9104
Branches 1774 1774
=========================================
Hits 7598 7598
Misses 572 572
Partials 934 934 Continue to review full report at Codecov.
|
BraisGabin
left a comment
There was a problem hiding this comment.
Does this do the trick? Does core tests wait for all the rule modules to be compiled? testRuntimeOnly(projects.detektRules) does that?
|
Seems like it. I intentionally broke the build with e2d32db and the check failed. |
cortinico
left a comment
There was a problem hiding this comment.
I believe we should merge this, but at the same time I'd like those kind of checks to happen "earlier" in the rule lifecycle.
Specifically I believe we should update:
data class Issue(
val id: String,
val severity: Severity,
val description: String,
val debt: Debt
) {
to have a ctor that accepts a Rule as parameter. Or even we should remove the id from Issue entirely, as the Rule class is using it to expose the ruleId property:
final override val ruleId: RuleId get() = issue.id
So we're creating a tight couplign between the two classes, and we don't need to duplicate informations with the risk of having bugs like the one we just experienced.
|
Entirely agree. This is not more that a band-aid as this problem can easily be missed in the PR and the consequences are quite big. |
This relates to #4042 and adds a check that verifies that the issue ID matches the rule name.