What are code quality gates (SonarQube, coverage thresholds) in CI/CD?

Answer

Code quality gates are automated checks in the CI pipeline that enforce minimum quality standards before code can be merged or deployed. Common gates include: Code coverage thresholds — fail the build if test coverage drops below a defined percentage (e.g., 80% line coverage), enforced via tools like Istanbul (JavaScript), Coverage.py (Python), or JaCoCo (Java). SonarQube performs static analysis detecting code smells, duplicated code, cyclomatic complexity, and technical debt — the pipeline fails if the "Quality Gate" (configurable thresholds) is not met. CodeClimate provides similar analysis as a cloud service integrated with GitHub. Linting (ESLint, Pylint, PHP-CS-Fixer) enforces code style and catches common bugs. Quality gates prevent technical debt accumulation by making standards mandatory rather than aspirational, and they block merges that introduce regressions in quality metrics.