Use SonarQube for Code Quality Gates
Design a focused SonarQube quality gate, verify new-code and coverage attribution, and distinguish completed analysis from a passing CI gate.
Identify the server product, edition and version, scanner and language integration, project key, normal CI branch, and available pull-request analysis features. Check which permissions are needed to submit analysis and which are needed to change the gate. Use the existing CI secret store for scanner credentials and keep those credentials out of command output and report artifacts. ## Key Points - [SonarQube quality gates](https://docs.sonarsource.com/sonarqube-server/quality-standards-administration/managing-quality-gates/introduction-to-quality-gates) - [SonarQube new-code definition](https://docs.sonarsource.com/sonarqube-server/user-guide/about-new-code)
skilldb get testing-services-skills/sonarqube-quality-gatesFull skill: 32 linesUse SonarQube for Code Quality Gates
Set the baseline and scope
Identify the server product, edition and version, scanner and language integration, project key, normal CI branch, and available pull-request analysis features. Check which permissions are needed to submit analysis and which are needed to change the gate. Use the existing CI secret store for scanner credentials and keep those credentials out of command output and report artifacts.
Agree on a new-code definition and list the changed files it should include in a fixture branch. A reference branch, version transition, or other available definition can produce different results. Use the choice the team can explain and reproduce. Check that the scanner and CI have enough repository history to compute the intended scope. Keep an explicit list of generated files and other appropriate exclusions. A broader exclusion should be reviewed against the reason the gate exists.
Run an initial analysis and inspect how the project reports uncovered lines, duplication, and issues. Choose conditions that address observable risks in the current project. An established backlog can be measured separately while a new-code gate prevents worsening it. Record the rule set, gate configuration, project version or reference baseline, and any reviewed exception.
Verify data and gate evaluation in CI
Generate tests and the coverage report before running the scanner. Configure the project to import the language's supported report format. Confirm that file paths and exclusions align with the scanner's source paths. Inspect logs for importer warnings and check a known file whose covered and uncovered lines can be verified independently. An uploaded report with no matching paths cannot support a meaningful coverage claim.
Track the analysis task submitted by the scanner and wait for the resulting gate status through the documented integration. A successful scanner process can mean that it submitted the report while server processing is still pending. Use a bounded timeout and surface server errors, failed gates, and unavailable analysis as distinct outcomes. Make the required CI check depend on the correct analyzed commit or pull request.
Test enforcement before relying on it
In an isolated branch, add a known violation or an uncovered change covered by the configured metric. Verify which files the server considers new code, which condition failed, and how CI reports it. Fix the fixture and verify the same integration passes. Check a second failure mode by temporarily omitting the fixture report or simulating delayed processing in the CI integration.
Record the exact commit, scanner task reference, project gate and baseline, and the observed condition outcomes. Document who can accept an exception and what evidence they need. Recheck the fixture after upgrading the scanner, changing branch policies, or changing the gate definition.
References
Install this skill directly: skilldb add testing-services-skills
Related Skills
Storybook Test
Storybook Test: component testing via play functions, interaction testing, accessibility checks, visual regression, test-runner, portable stories
Testing Library
Testing Library: React/DOM testing, queries (getBy/findBy/queryBy), user events, screen, waitFor, render, accessibility-first
Vitest
Vitest: unit/integration testing, Vite-native, mocking (vi.mock/vi.fn), snapshots, coverage, workspace, in-source testing, benchmark
Cypress
Cypress: end-to-end/component testing, commands, intercept (network mocking), fixtures, custom commands, CI, retries
K6
k6: load testing, performance testing, stress testing, soak testing, thresholds, checks, scenarios, browser testing, CI integration
MSW
MSW (Mock Service Worker): API mocking, request handlers, rest/graphql, browser/node, setupServer, network-level interception