How to Gate on Code Smells in a Quality Scan
Code smells are maintainability issues; a gate condition on new maintainability issues fails the build when the diff introduces any.
Sonar classifies issues as bugs, vulnerabilities, or code smells. Add a gate condition such as "Maintainability issues on new code is greater than 0" or require a maintainability rating of A.
Gate conditions for smells
| Condition | Operator | Value |
|---|---|---|
| Maintainability issues (new code) | is greater than | 0 |
| Maintainability rating (new code) | is worse than | A |
| Technical debt ratio (new code) | is greater than | 5.0 |
sonar-project.properties
sonar-project.properties
sonar.projectKey=my-org_my-repo
sonar.sources=src
sonar.exclusions=**/*.spec.ts,**/vendor/**
sonar.qualitygate.wait=trueGotchas
- A "zero new smells" gate is strict; scope excludes carefully or the gate blocks trivial refactors.
- Rules that generate smells are governed by the quality profile; disable noisy rules there, not in the gate.
Related guides
How to Enforce a Cognitive Complexity Limit in CICap function cognitive complexity in CI using the ESLint sonarjs rule or a SonarQube quality profile threshol…
How to Gate on the Technical Debt RatioFail a build when the SonarQube technical debt ratio on new code exceeds a threshold, keeping the maintainabi…