sonarqube-quality-gates
Skill2 starsChanged 3 months agoMITView on GitHub
SonarQube quality gate configuration, coverage rules, custom profiles, and CI/CD integration for maintaining code quality across projects.
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 26
Default conditions for overall code and new code:
- Distinctive: line 41
Create a stricter gate for critical projects:
- Distinctive: line 177
Use new code conditions to prevent technical debt growth.
- Distinctive: line 181
Run analysis on every commit, not just nightly.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SonarQube Quality Gates
1. Core Concepts
| Term | Definition |
| Quality Gate | Pass/fail conditions a project must meet (e.g., coverage ≥ 80%). |
| Quality Profile | Set of active rules for a language (e.g., Sonar way for Python). |
| Issue | Code smell, bug, or vulnerability detected by a rule. |
| Measure | Metric value (coverage, duplication, complexity). |
| New Code | Code added/changed since previous analysis (Leak Period). |
2. Built-in Quality Gate: Sonar way
Default conditions for overall code and new code:
| Metric | Threshold |
| Coverage | ≥ 80% |
| Duplicated Lines | ≤ 3% |
| Maintainability Rating | A |
| Reliability Rating | A |
| Security Rating | A |
| Security Hotspots Reviewed | 100% |
| Critical Issues | 0 |
| Blocker Issues | 0 |
3. Custom Quality Gate
Create a stricter gate for critical projects:
# API: POST /api/qualitygates/create
name: "Strict Enterprise Gate"
conditions:
- metric: coverage
threshold: "85"
operator: LT # fail if less than 85%
- metric: duplicated_lines_density
threshold: "2"
operator: GT
- metric: critical_violations
threshold: "0"
operator: GT
- metric: security_rating
threshold: "1" # A
operator: GT
- metric: new_coverage
threshold: "80"
operator: LT
- metric: new_duplicated_lines_density
threshold: "1"
operator: GT4. SonarScanner Configuration
sonar-project.properties
# Project identity
sonar.projectKey=my-org:my-service
sonar.projectName=My Service
sonar.projectVersion=1.0.0
# Sources and tests
sonar.sources=src
sonar.tests=tests
sonar.test.inclusions=tests/**/*.py
# Coverage report (pytest-cov)
sonar.python.coverage.reportPaths=coverage.xml
# Exclusions
sonar.exclusions=**/migrations/**,**/vendor/**
sonar.coverage.exclusions=**/config/**,**/tests/**
# Encoding
sonar.sourceEncoding=UTF-8CI/CD (GitHub Actions)
- name: SonarQube Scan
uses: sonarqube-scan-action@v2
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}CI/CD (GitLab CI)
sonarqube:
image: sonarsource/sonar-scanner-cli:latest
script:
- sonar-scanner
-Dsonar.projectKey=$CI_PROJECT_PATH
-Dsonar.sources=src
-Dsonar.python.coverage.reportPaths=coverage.xml5. Coverage Integration
Python (pytest + coverage)
pytest --cov=src --cov-report=xml --cov-fail-under=80
cat coverage.xml # verify path matches sonar configJava (JaCoCo)
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<executions>
<execution>
<goals><goal>prepare-agent</goal></goals>
</execution>
<execution>
<id>report</id><phase>test</phase>
<goals><goal>report</goal></goals>
</execution>
</executions>
</plugin>6. Custom Rules (Python Plugin API)
from python_checkers import Issue, Rule
class NoHardcodedSecretsRule(Rule):
key = "no-hardcoded-secrets"
name = "No hardcoded secrets"
description = "Detects hardcoded API keys and passwords"
def visit_assign(self, node):
sensitive_names = {"password", "secret", "token", "api_key"}
if node.target.id.lower() in sensitive_names:
if isinstance(node.value, ast.Constant) and isinstance(node.value.value, str):
yield Issue(
message=f"Hardcoded secret detected: {node.target.id}",
line=node.lineno,
severity="BLOCKER",
)7. PR Decoration
Enable pull request analysis to block merges:
sonar.pullrequest.key=${GITHUB_PR_NUMBER}
sonar.pullrequest.branch=${GITHUB_HEAD_REF}
sonar.pullrequest.base=${GITHUB_BASE_REF}8. Best Practices
- Set quality gate as required check in GitHub/GitLab.
- Use new code conditions to prevent technical debt growth.
- Review security hotspots promptly (manual step).
- Track coverage on new code, not just overall.
- Exclude generated code (migrations, protobuf, API clients).
- Run analysis on every commit, not just nightly.
In this repository45 other files it gives its agents.
- AGENTS.mdAGENTS.md
- allure-reportsSkill
- android-nativeSkill
- appian-lowcodeSkill
- appium-mobileSkill
- behave-bddSkill
- BiDiWave Cross-BrowserSkill
- BiDiWave Network InterceptionSkill
- CDPWave DebuggingSkill
- CDPWave TestingSkill
- db2-oracleSkill
- ebook-writerSkill
- flask-apiSkill
- flet-desktopSkill
- google-crawling-indexingSkill
- google-ranking-appearanceSkill
- google-seo-fundamentalsSkill
- google-seo-monitoringSkill
- jinja2-templatesSkill
- jmeter-load-testingSkill
- k6-load-testingSkill
- karate-api-testingSkill
- octane-almSkill
- paramiko-sshSkill
- postman-api-automationSkill
- prestashop-moduleSkill
- prompt-engineering-best-practicesSkill
- pytest-advancedSkill
- robot-frameworkSkill
- salesforce-devSkill
- sql-serverSkill
- Skill NameSkill
- testcontainersSkill
- wave-ecosystem-guideSkill
- WaveXis AccessibilitySkill
- WaveXis CI/CD IntegrationSkill
- wavexis-cli-automationSkill
- wavexis-mcp-agent-integrationSkill
- WaveXis Network TestingSkill
- WaveXis Performance AuditSkill
- WaveXis Session RecordingSkill
- WaveXis Web ScrapingSkill
- webdriverioSkill
- wordpress-themesSkill
- xctest-iosSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

