The Code Review Journalreview desk · diff view

Review bench › Code Smells

SonarQube vs. Semgrep vs. Human Review for Code Smells

Checklist entry · recorded 2026-10-25

1 Overview

Code smells are surface signals that something in the code may be harder to understand, change, or test than it needs to be. They are not bugs by themselves, and they are not proof of bad engineering. A long method, a duplicated conditional, a class that knows too much about another class, or a parameter list that keeps growing are all familiar examples. The practical question for a review team is not whether smells exist, because they always do, but who or what should notice them and how much weight that notice deserves.

Automated analyzers and human reviewers approach this question from different directions. Pattern-based and rule-based tools scan code quickly and consistently, flagging constructs that match known heuristics. Human reviewers bring context: they know which parts of the system are under active change, which shortcuts are deliberate, and which smells are symptoms of a deeper design problem. Neither side is sufficient alone. A team that relies only on tooling will drown in low-value warnings, while a team that relies only on human attention will miss mechanical issues that are cheap to catch automatically.

The goal of this article is to describe a division of labor. Automated analysis handles the repetitive, rule-shaped part of smell detection. Human review handles the judgment-heavy part: whether a smell matters here, now, and for this codebase. Getting that division right keeps reviews focused and keeps reviewers from burning out on issues a machine could have raised earlier.

2 Why the usual advice misses the point

The usual advice tends to frame the choice as a contest. One camp says automated analysis is objective and tireless, so configure more rules and let the tools decide. Another camp says tools cannot understand intent, so ignore their output and trust experienced reviewers. Both positions are partly right and mostly unhelpful, because they treat the two approaches as substitutes when they are complements operating at different layers of the problem.

A deeper issue is that smell detection is not the same as smell prioritization. A tool can report that a function exceeds a complexity threshold, but it cannot know that the function is a stable, well-tested piece of the system that nobody needs to touch. A reviewer can sense that a small helper is awkward, but may not notice that the same pattern has been copied into a dozen files over the past year. The first kind of signal is cheap and broad; the second is expensive and narrow. Mixing them without a clear process produces either noise fatigue or blind spots.

There is also a cultural failure mode. When automated findings are treated as a score or a gate, engineers learn to satisfy the checker rather than improve the code. When human opinions are treated as the only valid signal, reviews become inconsistent and depend heavily on who happens to be assigned. The advice misses the point because it asks which detector is better instead of asking what each detector is good at and how the team should route findings between them.

3 The core idea in practice

The core idea is to separate detection from judgment and to give each stage a clear owner. Automated analysis runs before human review and produces a candidate list of smells. That list is not a verdict; it is a set of prompts. Some prompts will be dismissed quickly because the code is intentionally structured that way. Others will be escalated to a human reviewer with a specific question attached, such as whether the duplication is worth extracting or whether the long method hides several responsibilities.

In practice this means configuring analyzers to be strict enough to catch mechanical issues but not so strict that every pull request carries a wall of warnings. Teams often start with a small, curated rule set focused on issues they actually care about, then expand gradually as they learn which rules produce useful signal. The key discipline is that a finding must lead to one of three outcomes: fix it, consciously accept it with a brief note, or escalate it to human discussion. A finding that leads to none of these is just noise.

Human review then concentrates on what tools cannot see. Reviewers ask whether the change fits the existing design, whether naming communicates intent, whether the abstraction will hold as requirements shift, and whether tests cover the behavior that matters. They also decide when a smell is acceptable technical debt and when it is a warning sign worth addressing before the change grows. This division keeps automated checks fast and human attention scarce and valuable.

4 A repeatable review process

A workable process starts before the pull request is opened. The author runs the agreed analyzers locally and addresses findings that are clearly mechanical, such as unused imports, inconsistent formatting, or obvious duplication. This removes low-value discussion from the review and lets the author see the same signals the reviewer will see. The author should also note any findings they deliberately ignored and why, so the reviewer does not have to rediscover the reasoning.

During review, the human reviewer reads the change for intent first, then consults the analyzer output as a secondary checklist. If a tool flags something the reviewer would not have raised, the reviewer decides whether it is worth a comment. If the reviewer notices a smell the tool missed, that is a signal the rule set may need attention. Over time, recurring human observations can be turned into new automated checks, which moves mechanical work off the reviewer's plate.

After the change merges, the team should periodically review which rules are producing useful findings and which are being ignored. Rules that consistently generate dismissals should be removed or relaxed. Rules that catch real problems should be kept and possibly strengthened. This feedback loop keeps the process from ossifying. The point is not to build a perfect gate but to maintain a living agreement about what the team considers worth flagging and what it considers acceptable.

5 Common mistakes reviewers make

The first mistake is treating every analyzer finding as mandatory. When a tool reports a smell, reviewers sometimes insist on a fix regardless of context, which turns review into compliance theater and pushes authors toward superficial changes. A better habit is to ask what the finding is trying to protect against and whether that protection matters for this change. Some findings deserve a fix; others deserve a one-line justification and a merge.

The second mistake is using automated output as a substitute for reading the code. Reviewers who scan the warning list and approve when it is empty may miss design problems that no rule captures, such as a confusing abstraction or a boundary placed in the wrong layer. Tools are good at patterns and poor at intent, so an empty warning list is not evidence that the change is well designed.

The third mistake is letting smell discussions become personal or absolute. Comments like this is bad code or always extract duplicated logic ignore trade-offs and shut down useful conversation. Smells are heuristics, not laws. Reviewers get better results by describing the concrete risk, such as this duplication will be painful if the validation rules change, and letting the author weigh the cost of fixing it now against the cost of carrying it forward.

6 Tooling that helps (and where it fails)

Pattern-based and rule-based analyzers are the workhorses here. They excel at detecting constructs that can be described as rules: overly long functions, deep nesting, duplicated blocks, unused variables, and inconsistent naming. Their strength is consistency and speed. They apply the same standard to every change, they never get tired, and they can run on every commit without human cost. For mechanical smells, this is close to ideal.

Their limits are equally clear. Analyzers do not know the domain, the roadmap, or the reason a particular structure exists. They cannot tell whether a long function is a stable, well-tested routine or a tangle of unrelated responsibilities. They cannot judge whether duplication is accidental or a deliberate trade-off to keep two modules independent. They also produce false positives, and a rule set that is too aggressive can train the team to ignore all findings, including the useful ones.

Human review covers the gap but has its own failure modes. Reviewers are inconsistent, they get fatigued, and they are biased by familiarity with the author or the code. The practical answer is not to pick a winner but to route work: let analyzers handle what rules can express, let humans handle what judgment requires, and let the team's experience decide where the boundary sits. That boundary will move as the codebase and the rule set mature.

7 Frequently asked questions

Should automated findings block a merge? Usually not by default. Blocking on every finding creates pressure to silence rules rather than improve code. A better approach is to block only on a small set of high-confidence issues, such as security-relevant patterns or clear correctness problems, and treat design smells as discussion prompts. Teams can tighten the gate later once they trust the rule set.

How many rules should a team enable? Start small and grow deliberately. A focused set that the team actually acts on is more valuable than a large set that everyone ignores. Review the rule set periodically and remove rules that consistently produce dismissed findings. The goal is signal, not coverage.

What if a reviewer and an analyzer disagree? Treat the disagreement as useful information. The reviewer may know context the rule cannot encode, which suggests the rule needs an exception or a narrower scope. Or the analyzer may be catching a pattern the reviewer has stopped noticing, which suggests the team should discuss whether that pattern is acceptable. Either way, the resolution should be recorded so the same debate does not recur on every pull request.

Can human review replace automated analysis entirely? It can, but it is expensive and inconsistent. Humans are better used on problems that require context and judgment. Letting machines handle the mechanical layer frees reviewer attention for the design questions that actually benefit from human experience.