-
-
Notifications
You must be signed in to change notification settings - Fork 784
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
Fix ForbiddenComment rule not checking for KDoc #3275
Fix ForbiddenComment rule not checking for KDoc #3275
Conversation
ForbiddenComment now analyzes KDoc elements for forbidden comments. KDoc sections don't inherit from the PsiComment type. Hence, this rule needs to also gather and analyze KDocSection types. Fixes #3273
Codecov Report
@@ Coverage Diff @@
## master #3275 +/- ##
============================================
+ Coverage 80.07% 80.11% +0.03%
- Complexity 2653 2654 +1
============================================
Files 443 443
Lines 8096 8100 +4
Branches 1540 1538 -2
============================================
+ Hits 6483 6489 +6
Misses 789 789
+ Partials 824 822 -2
Continue to review full report at Codecov.
|
detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenComment.kt
Show resolved
Hide resolved
detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenComment.kt
Outdated
Show resolved
Hide resolved
detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenComment.kt
Outdated
Show resolved
Hide resolved
"defined as forbidden in detekt.")) | ||
report( | ||
CodeSmell( | ||
issue, Entity.from(comment), "This comment contains text that has been " + |
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.
issue, Entity.from(comment), "This comment contains text that has been " + | |
issue, Entity.from(comment), "This comment contains '$it' that has been " + |
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.
We can actually be specific here. This would help when just reading the reports.
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.
This would then report the whole comment. I'm not sure whether we want to print the whole text. Detekt already outputs the flagged entity.
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.
it
would be in that block TODO:
for example.
Do you mean it outputs it in the html report?
The console report would just print `"ForbiddenComment - This comment contains text that has been defined as forbidden in detekt." right?
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.
Yes, thanks for the explanation. I'll change it. That makes sense.
This allows to document rule violations in the noncompliant section.
revert back to old style
* Fix ForbiddenComment rule not checking for KDoc ForbiddenComment now analyzes KDoc elements for forbidden comments. KDoc sections don't inherit from the PsiComment type. Hence, this rule needs to also gather and analyze KDocSection types. Fixes #3273 * Remove wildcard import * Add ForbiddenComment suppression to rule itself This allows to document rule violations in the noncompliant section. * Format report statement accordingly revert back to old style * Update report message to include the violated value
* Fix ForbiddenComment rule not checking for KDoc ForbiddenComment now analyzes KDoc elements for forbidden comments. KDoc sections don't inherit from the PsiComment type. Hence, this rule needs to also gather and analyze KDocSection types. Fixes #3273 * Remove wildcard import * Add ForbiddenComment suppression to rule itself This allows to document rule violations in the noncompliant section. * Format report statement accordingly revert back to old style * Update report message to include the violated value
ForbiddenComment now analyzes KDoc elements for forbidden comments.
KDoc sections don't inherit from the PsiComment type.
Hence, this rule needs to also gather and analyze KDocSection types.
Fixes #3273