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

Fix ForbiddenComment rule not checking for KDoc #3275

Merged
merged 5 commits into from
Dec 14, 2020
Merged

Fix ForbiddenComment rule not checking for KDoc #3275

merged 5 commits into from
Dec 14, 2020

Conversation

schalkms
Copy link
Member

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

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
Copy link

codecov bot commented Dec 11, 2020

Codecov Report

Merging #3275 (f387bd8) into master (fc5c993) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             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     
Impacted Files Coverage Δ Complexity Δ
...bosch/detekt/rules/exceptions/ReturnFromFinally.kt 85.71% <100.00%> (+6.40%) 9.00 <0.00> (-1.00) ⬆️
.../arturbosch/detekt/rules/style/ForbiddenComment.kt 100.00% <100.00%> (ø) 9.00 <1.00> (+2.00)

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 fc5c993...9e4d378. Read the comment docs.

"defined as forbidden in detekt."))
report(
CodeSmell(
issue, Entity.from(comment), "This comment contains text that has been " +
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
issue, Entity.from(comment), "This comment contains text that has been " +
issue, Entity.from(comment), "This comment contains '$it' that has been " +

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

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.

@arturbosch arturbosch added this to the 1.15.0 milestone Dec 11, 2020
config/detekt/detekt.yml Show resolved Hide resolved
@arturbosch arturbosch merged commit 84e42ec into detekt:master Dec 14, 2020
arturbosch pushed a commit that referenced this pull request Dec 21, 2020
* 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
arturbosch pushed a commit that referenced this pull request Jan 16, 2021
* 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
@schalkms schalkms deleted the fix-#3273-ForbiddenComment branch March 13, 2021 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ForbiddenComments don't report TODO: in KDoc
3 participants