Java Code Smells: 7 Patterns to Catch in Code Review (With Fixes) (video)
A practical list of Java code smells — empty catch blocks, long methods, large classes, too many parameters, deep nesting, hardcoded credentials, and missing logging — with before-and-after examples.
Transcript
Java Code Smells: 7 Patterns to Catch in Code Review (With Fixes). Here's the short version.
A code smell is not a bug — it is a pattern that makes bugs more likely and changes more expensive. Java codebases tend to accumulate the same handful of smells, especially in long-lived enterprise services.
Empty catch blocks. An empty catch swallows the exception and lets the caller believe the operation succeeded. In Java it often appears around checked exceptions that a developer wanted to “make go away”.
Here's the problem in code: the failure disappears.
And here's the fix: log with context, then decide.
Long methods. Methods past roughly 60 lines usually do more than one thing. Extract each step into a well-named private method so the top-level method reads like a summary.
Want to find these issues in your own code? Connect your GitHub repository to CodeInspector. You'll get findings with the file, line, severity, and a recommended fix, plus HTML and PDF reports for your team. Start free at codeinspector.app.
More videos
- CodeInspector product demo (0:54)
- CodeInspector Now Works Inside Claude: Scan and Fix Code in One Conversation (video) (1:20)
- throw vs throw ex in C#: Why throw ex Destroys Your Stack Trace (video) (1:22)
- Thread.Sleep vs Task.Delay in C#: Which to Use and Why (video) (1:38)
- Task.Result and .Wait() Deadlocks in C#: Why Sync-over-Async Hangs (video) (1:47)
- ILogger Best Practices in .NET: Structured Logging That Helps You Debug (video) (1:20)