The Code Review Journalreview desk · diff view

Review bench › Code Smells

Code Smells: How to Spot Them in Review and Actually Fix Them

Checklist entry · recorded 2026-10-23

1 Overview

Code smells are surface indications of deeper problems in software design. They are not bugs; they do not break functionality, but they often signal that the code will be hard to maintain, extend, or understand. In code review, spotting these smells early can save hours of refactoring later. However, many reviewers either miss them entirely or treat them as personal style preferences, leading to friction rather than improvement.

This article focuses on the practical identification and remediation of code smells during peer review. It is not about enforcing a rigid standard or replacing developer judgment. Instead, it offers a team-oriented process for recognizing common smells, discussing them constructively, and applying fixes that align with the team's context. The goal is to make code review a proactive tool for design improvement, not just a gate for correctness.

We will cover why typical advice like "keep functions small" or "avoid duplication" often fails in practice, how to build a shared vocabulary for smells, a repeatable review process, common pitfalls, and where tooling can help or hinder. By the end, you should have a concrete approach to turn code review into a continuous improvement loop for your codebase.

2 Why the usual advice misses the point

Most advice about code smells is either too abstract or too prescriptive. Saying "avoid long methods" or "don't repeat yourself" gives no guidance on when a method is too long or when duplication is acceptable. Without context, these rules become arbitrary, leading to debates about line counts or personal thresholds. Reviewers may flag a 30-line function as a smell while ignoring a 10-line function that hides a complex conditional. The result is noise, not improvement.

Another problem is that smells are often treated as absolute violations. In reality, a smell is a heuristic: it suggests a possible problem, but it might be perfectly fine in a given context. For example, a large class might be appropriate for a domain entity with many attributes, while a small class with a single method might be a sign of poor cohesion. Reviewers who lack context may demand changes that make the code worse. This erodes trust and wastes time.

Finally, the usual advice rarely addresses the social aspect of code review. Pointing out a smell can feel like a personal attack if not framed as a shared problem. Without a team-agreed vocabulary and a focus on learning, smell detection becomes a source of conflict. The better approach is to treat smells as conversation starters, not verdicts, and to tie them to concrete impacts like testability or change frequency.

3 The core idea in practice

The core idea is to use code smells as a shared language for discussing design trade-offs. Instead of saying "this is wrong," a reviewer might say, "This looks like a case of feature envy; the method seems more interested in another class's data. Could we move it there?" This shifts the focus from blame to improvement. To make this work, teams need a lightweight catalog of smells that are relevant to their codebase. Not all smells matter equally; some may be irrelevant for a given language or architecture.

In practice, reviewers should first understand the change's intent. What problem is it solving? Then, they can look for smells that would hinder that intent. For example, if a change adds a new feature, duplicated logic might be acceptable for speed, but if it's a refactoring, duplication is a red flag. The key is to prioritize smells that affect maintainability, such as long parameter lists, divergent change, or shotgun surgery. These often indicate deeper design issues that will slow down future work.

When a smell is identified, the reviewer should suggest a specific fix, not just point it out. For instance, "This long method could be split into two: one for validation and one for processing. Would that make it easier to test?" This turns the review into a collaborative design session. It also helps the author learn to spot the smell themselves next time. Over time, the team builds a shared understanding of which smells matter and how to address them, reducing the need for repeated discussions.

4 A repeatable review process

A repeatable process for handling code smells in review starts before the review begins. Authors should self-review their changes with a checklist of common smells relevant to the team. This doesn't mean fixing everything, but noting potential issues and explaining why they were left. For example, "I noticed this duplication but plan to refactor in a follow-up because it's needed for the current deadline." This sets context for reviewers.

During the review, reviewers should first check for correctness and then for smells. A simple technique is to read the code aloud or walk through it mentally, looking for signs of confusion: long methods, deep nesting, unclear names, or repeated patterns. When a smell is found, the reviewer should ask a question rather than make a demand. "Could this conditional be simplified by using a guard clause?" This invites discussion and avoids defensiveness. If the author agrees, they can fix it immediately or create a task. If not, they should explain why, and the reviewer can accept that.

After the review, teams should periodically reflect on the smells that came up. Are there recurring issues that could be addressed with a team convention or a small refactoring? For example, if multiple reviews flag long parameter lists, the team might agree to use parameter objects. This turns individual review comments into systemic improvements. The process is iterative: review, discuss, fix, and adjust. It requires discipline but pays off in a codebase that is easier to change and understand.

5 Common mistakes reviewers make

One common mistake is focusing on style over design. Reviewers may nitpick formatting or naming while missing a deeply nested conditional that will be hard to modify. Style is important, but it should be automated with linters and formatters, leaving human review for higher-level concerns. When style comments dominate, authors feel micromanaged and may ignore more substantive feedback.

Another mistake is flagging a smell without suggesting a fix. Saying "this method is too long" without offering a way to split it leaves the author guessing. It also assumes the author knows how to refactor, which may not be true. A better approach is to propose a specific change, even if it's just a sketch. This turns criticism into collaboration and helps the author learn.

A third mistake is ignoring context and team conventions. What is a smell in one codebase may be acceptable in another. For example, a large switch statement might be fine in a parser but a smell in a business rule engine. Reviewers who apply generic rules without understanding the domain will make unreasonable demands. Similarly, if the team has agreed to allow duplication for performance reasons, flagging it repeatedly wastes time. Always consider the project's constraints and prior decisions before calling out a smell.

6 Tooling that helps (and where it fails)

Static analysis tools can automatically detect many code smells, such as long methods, duplicated code, or complex conditionals. These tools are excellent for catching low-level issues consistently, freeing reviewers to focus on design. They can also be configured to match team thresholds, reducing false positives. For example, a tool can flag methods over a certain length or classes with too many responsibilities. Integrating such tools into the continuous integration pipeline ensures that smells are caught early, before review.

However, tooling has limits. It cannot understand intent or context. A tool might flag a long method that is actually a straightforward sequence of steps, while missing a subtle design flaw like inappropriate intimacy between classes. Tools also struggle with domain-specific smells, such as a missing abstraction that only a human would recognize. Over-reliance on tools can lead to a false sense of security and a checklist mentality.

Code review platforms can help by allowing comments on specific lines and facilitating discussion. They can also integrate with static analysis to show warnings inline. But the platform itself doesn't improve smell detection; it's just a medium. The real value comes from the team's ability to interpret tool output and combine it with human judgment. Use tools to handle the mechanical, and reserve human review for the conceptual.

7 Frequently asked questions

How do I convince my team to take code smells seriously? Start small. Pick one or two smells that are causing pain, like duplicated logic leading to bugs, and show how addressing them improves the code. Use concrete examples from your codebase. Avoid preaching; instead, propose a trial period where the team focuses on those smells in review. Celebrate successes and adjust as needed. Over time, the benefits will speak for themselves.

What if the author disagrees that something is a smell? That's fine. Smells are heuristics, not laws. Ask the author to explain their reasoning. If they have a valid justification, let it go. If not, discuss the potential impact. The goal is not to win an argument but to improve the code. If you can't agree, consider bringing in a third perspective or deferring the decision. Remember that not every smell needs to be fixed immediately; some can be logged as technical debt.

How can I spot smells faster? Practice. Review code regularly and consciously look for patterns. Keep a personal list of smells you encounter and how they were resolved. Pair with more experienced reviewers to learn their techniques. Over time, you'll develop an intuition for when something feels off. Also, read code written by others, especially in open-source projects, and try to identify smells and their fixes. The more you practice, the more automatic it becomes.