Skip to content
Latchkey

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

ConditionOperatorValue
Maintainability issues (new code)is greater than0
Maintainability rating (new code)is worse thanA
Technical debt ratio (new code)is greater than5.0

sonar-project.properties

sonar-project.properties
sonar.projectKey=my-org_my-repo
sonar.sources=src
sonar.exclusions=**/*.spec.ts,**/vendor/**
sonar.qualitygate.wait=true

Gotchas

  • 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

Run this faster and cheaper on Latchkey managed runners. Start free →