ADR-0236: Sonar reports defects, not style
- Status: accepted
- Date: 2026-12-02
- Deciders: Mahdi Amirabdollahi
- Amends: ADR-0140 (what a pull request must resolve)
Context
ADR-0140 made every pull request resolve every SonarQube Cloud issue. The findings that came were almost all code smells that measure size or taste: cognitive complexity (S3776), nested ternaries (S3358), duplicated string literals (S1192), "use a record" (S6878), a long parameter list (S107), and, on the web code, the same complexity and ternary rules. One pull request spent several rounds on seven of them in code written minutes before, each a refactor that changed no behaviour, while the findings that would matter, a bug or a vulnerability, were the same size of line in the same list. The only dead-store findings on main were the statement.setX(++i, …) idiom, whose last increment is dead on purpose.
The quality gate ("Sonar way", with new-code coverage) already fails on a new bug, a new vulnerability, an unreviewed security hotspot, duplication above 3%, a debt rating worse than A and new code under the coverage bar. It gates ci-ok (ADR-0140).
Decision
We will scope out the code-smell rules that measure size, style or modern-Java taste, and keep every rule that can point at a defect.
pom.xmlignores, for the whole repository (sonar.issue.ignore.multicriteria, one entry per rule, each namedsmell<number>; the TypeScript onessmellts<number>), these Java rules: S3776, S107, S135, S1141, S1186, S112, S1130, S3398 (size and shape); S1192, S1845, S1481, S7467, S1700, S1488, S1940, S3626, S1905, S3358 (style and naming); S6878, S6206, S6885, S4349, S6539 (modern-Java suggestions); S5778, S5838, S2925, S6068 (test style). On the web code: S3776, S3358 and S6606.- Everything else stays on: all bug and vulnerability rules, hotspots, and the smells that can hide a defect (S1854 dead stores, S108 empty blocks, S1871 identical branches, S1172 unused parameters, S4144 identical methods, S1948 serialisation, S2386 mutable statics, S106 standard output, S1181, S2699).
- A pull request is done when its quality gate is green and it adds no issue Sonar types as a bug or a vulnerability. Read the PR's issues filtered to RELIABILITY and SECURITY (
impactSoftwareQualities), not the whole list. A smell that points at a real defect is fixed like any bug; the rest are not chased. A false positive among the rules that stay is marked false positive in SonarQube Cloud with the reason. - The file-level scoping in ADR-0140 for the data grid and the scroll region stays.
Consequences
- The issue list is short enough to read, and an entry in it is worth a look.
- A style regression no longer shows up. The formatter, ESLint, ArchUnit and review catch most of what the scoped rules did; a rule can be switched back on by deleting its
smellentry. - ADR-0140's rule that every issue on a pull request is resolved before it merges is replaced by the one above.
- Existing open issues of the scoped rules are closed in SonarQube Cloud;
main's next analysis drops them.
Alternatives considered
- Deactivate the rules in the quality profile. The same effect, but it lives in the hosted service, off the repository, and applies to every project of the organisation.
- Keep fixing every finding. Rejected: the cost is a refactor per finding, and the gate was never failing on them.
- Raise the thresholds (complexity, parameters) instead. A rule's parameters can only be changed in a quality profile, not per repository.