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
Correct documentation/recommendation of EmptyCatchBlock rule #2603
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2603 +/- ##
============================================
+ Coverage 25.17% 26.92% +1.74%
+ Complexity 395 394 -1
============================================
Files 379 379
Lines 7420 6734 -686
Branches 1225 1224 -1
============================================
- Hits 1868 1813 -55
+ Misses 5423 4792 -631
Partials 129 129 Continue to review full report at Codecov.
|
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.
Thanks for improving the documentation! This was really a necessary step and helps to guide the user.
Please see my attached comments.
detekt-rules/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyCatchBlock.kt
Outdated
Show resolved
Hide resolved
detekt-rules/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyCatchBlock.kt
Outdated
Show resolved
Hide resolved
detekt-rules/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyCatchBlock.kt
Outdated
Show resolved
Hide resolved
detekt-rules/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyCatchBlockSpec.kt
Outdated
Show resolved
Hide resolved
Co-Authored-By: M Schalk <30376729+schalkms@users.noreply.github.com>
Fixes #2602
The current code smell recommendation for empty catch blocks is wrong:
Empty catch blocks cannot be removed, since that results in compilation errors.
This PR updates the documentation to give more guidance in line with how the rule is currently implemented. The recommendation seems to be to clarify the exception is intentionally ignored by naming the exception as such.
However, this also raises the question whether this should really be part of the 'empty block' ruleset. To me this is more akin to the
TooGenericExceptionCaught
rule. This is exemplified by the fact that I had to modify theEmptyRule
class in order to be able to modify the messages. In addition, one could argue this requires a higher severity than the 'minor' severity inherited fromEmptyRule
.