Enable detekt rule: EmptyCatchBlock#315
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughEnabled the Detekt rule Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@backend/detekt.yml`:
- Around line 82-83: Several empty catch blocks exist that will break the new
EmptyCatchBlock rule; locate the empty catches in the classes mentioned
(LogQueryParserIntegrationTest, UptimeCheckExecutor, LogService, LogRoutes,
DashboardAlertService) and replace each empty catch with proper handling: either
log the exception with context via the project's logger, rethrow or wrap it in a
meaningful exception, perform required cleanup, or—if truly intentional—add a
concise comment and apply a targeted suppression (e.g.,
`@Suppress`("EmptyCatchBlock")) on that specific catch; ensure you update the
specific methods containing those catches (test method in
LogQueryParserIntegrationTest, the executor method in UptimeCheckExecutor, the
failing handler methods in LogService, the route handler in LogRoutes, and the
alert method in DashboardAlertService) rather than broadly suppressing the rule.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| EmptyCatchBlock: | ||
| active: false | ||
| active: true |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Search for empty catch blocks in Kotlin source files and verify detekt passes
echo "=== Searching for empty catch blocks in Kotlin files ==="
# Search for catch blocks that might be empty (catch with underscore parameter and empty or whitespace-only body)
rg -n --type kotlin -U 'catch\s*\([^)]*\)\s*\{\s*\}' backend/src/
echo -e "\n=== Running detekt to verify no violations ==="
cd backend && ./gradlew detekt --console=plain 2>&1 | tail -20Repository: moneat-io/moneat
Length of output: 1252
Address the 8 empty catch blocks before enabling this rule.
The codebase contains empty catch blocks that will cause the build to fail when this rule is enabled with maxIssues: 0:
LogQueryParserIntegrationTest.kt:108UptimeCheckExecutor.kt:131LogService.kt:592,714,928LogRoutes.kt:491-492DashboardAlertService.kt:359
These violations must be fixed before merging this change. Either remove the empty catch blocks, add logging/error handling, or suppress the rule for specific cases where they are intentional.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@backend/detekt.yml` around lines 82 - 83, Several empty catch blocks exist
that will break the new EmptyCatchBlock rule; locate the empty catches in the
classes mentioned (LogQueryParserIntegrationTest, UptimeCheckExecutor,
LogService, LogRoutes, DashboardAlertService) and replace each empty catch with
proper handling: either log the exception with context via the project's logger,
rethrow or wrap it in a meaningful exception, perform required cleanup, or—if
truly intentional—add a concise comment and apply a targeted suppression (e.g.,
`@Suppress`("EmptyCatchBlock")) on that specific catch; ensure you update the
specific methods containing those catches (test method in
LogQueryParserIntegrationTest, the executor method in UptimeCheckExecutor, the
failing handler methods in LogService, the route handler in LogRoutes, and the
alert method in DashboardAlertService) rather than broadly suppressing the rule.
Description
Enable the
EmptyCatchBlockdetekt rule inbackend/detekt.ymlby settingactive: true.Ran
./gradlew detektand./gradlew detektFormat— no existing violations found,maxIssues: 0maintained.Related Issue
Fixes #307
Type of Change
Checklist
Summary by CodeRabbit
Chores
Notes