Why this matters
Empty catch blocks swallow exceptions, making it difficult to diagnose issues. Instead, log the exception or handle it appropriately.
Ensure that catch blocks contain meaningful exception handling logic and do not remain empty.
Empty catch blocks swallow exceptions, making it difficult to diagnose issues. Instead, log the exception or handle it appropriately.
Side-by-side examples engineers can pattern-match during review.
try {
process();
} catch (IOException e) {}try {
process();
} catch (IOException e) {
log.error("Error processing", e);
}try {
process();
} catch (IOException e) {}try {
process();
} catch (IOException e) {
log.error("Error processing", e);
}From the same buckets as this rule.
Check if loops use equality operators (== or !=) in termination conditions. These can lead to infinite loops if the condition is never met exactly. Instead, use relational operators like < or > for safer loop termination.