---
name: "sonarqube-code-quality-gate"
description: "Inspect code quality, test coverage, code smells, and security hotspots with SonarQube."
metadata:
  author: "SonarSource"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "setup sonarqube scanner"
  - "configure quality gate sonarqube"
  - "sonar-project.properties"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# SonarQube Static Analysis & Quality Gate Enforcement

Integrates SonarQube / SonarCloud: configuring sonar-project.properties, running sonar-scanner in CI, setting Quality Gate standards (0 new bugs, >80% coverage on new code), and failing PRs on quality gate failure.

## When to Invoke
Invoke this skill whenever you need to:
- setup sonarqube scanner
- configure quality gate sonarqube
- sonar-project.properties

## Execution SOP & Rules
1. Create sonar-project.properties defining sonar.projectKey, sonar.sources, and test report paths.
2. Execute sonar-scanner inside CI build step with SONAR_TOKEN authentication.
3. Configure SonarQube Quality Gate to fail the build step if status is ERROR.
4. Review interactive pull request decoration comments showing coverage deltas.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
