sonarqube-rules
БесплатноБез исполняемых скриптовНе проверенUse when a team runs SonarQube or SonarCloud for multi-language static analysis and code quality: sonar-scanner and sonar-project.properties, Sonar Way…
от testland★ 18 звёзд на GitHubОб этом скилле
sonarqube-rules
Overview
Per github.com/SonarSource/sonarqube:
"SonarQube provides the capability to not only show the health of an application but also to highlight issues newly introduced."
The platform's distinguishing features vs Semgrep / CodeQL:
- Quality Gate - pass/fail decision based on configurable threshold conditions (coverage on new code, duplication, security hotspots reviewed, maintainability rating, etc.).
- New-code-period - issues are categorized as "new code" vs "overall code"; gates focus on new-code metrics so legacy debt doesn't block deploys.
- Persistent issue tracking - server-side storage of issues across scans; status workflow (open / confirmed / resolved / false positive / won't fix).
- Cross-language coverage - 30+ languages with one tool + unified UI.
When to use
- Existing SonarQube deployment (Community / Developer / Enterprise / SonarCloud).
- The team needs persistent issue tracking + Quality Gate workflow.
- Multi-language coverage in one platform is a requirement.
- New-code-period gating fits the team's deploy cadence.
For new projects without a SonarQube investment, evaluate
semgrep-rules (lower friction; no
server) first.
Step 1 - Install (server side)
Per docs.sonarsource.com/sonarqube-server:
Docker (most common for evaluation):
docker run -d --name sonarqube \
-p 9000:9000 \
sonarqube:lts-community
For production, consult sq-docs for Postgres + JVM
sizing + reverse-proxy configuration. Default admin: admin /
admin (change immediately).
Step 2 - sonar-scanner CLI
Download from docs.sonarsource.com/sonarqube-server → "Analysis scanners". Place on PATH.
sonar-scanner \
-Dsonar.projectKey=my-project \
-Dsonar.sources=. \
-Dsonar.host.url=http://localhost:9000 \
-Dsonar.token=$SONAR_TOKEN
For Maven / Gradle / .NET, use the language-native scanner plugin
(mvn sonar:sonar / ./gradlew sonar / dotnet sonarscanner).
Step 3 - sonar-project.properties config
Project-root file replaces -D flags:
# sonar-project.properties
sonar.projectKey=my-project
sonar.projectName=My Project
sonar.sources=src
sonar.tests=tests
sonar.exclusions=**/*.spec.ts,**/generated/**
sonar.sourceEncoding=UTF-8
# Coverage from external tool (Jest, JaCoCo, etc.)
sonar.javascript.lcov.reportPaths=coverage/lcov.info
# New-code-period (analysis scope)
sonar.newCode.referenceBranch=main
# Quality Gate (referenced by ID; created via UI/API)
sonar.qualitygate.wait=true
sonar.qualitygate.wait=true makes the scanner block until the
gate decision is computed - critical for CI gating.
Step 4 - Quality Gate concept
The default "Sonar Way" gate enforces (consult your SonarQube UI
at Quality Gates → Sonar Way for current conditions):
- Coverage on New Code ≥ X%
- Duplicated Lines on New Code ≤ Y%
- Maintainability Rating on New Code = A
- Reliability Rating on New Code = A
- Security Rating on New Code = A
- Security Hotspots on New Code reviewed = 100%
Custom gates can be defined via UI or REST API
(/api/qualitygates/create).
Step 5 - Branch + PR analysis
For PR analysis (Developer edition+):
sonar-scanner \
-Dsonar.pullrequest.key=$PR_NUMBER \
-Dsonar.pullrequest.branch=$PR_BRANCH \
-Dsonar.pullrequest.base=main
PR results post as comments to GitHub / GitLab / Bitbucket per the integration setup in SonarQube admin.
Step 6 - False-positive triage (MANDATORY)
Three suppression layers in priority order:
| Mechanism | Example | When to use |
|---|---|---|
Per-line NOSONAR |
int x = 0; // NOSONAR justification text |
Single-line exception with inline reason |
| Annotation | @SuppressWarnings("squid:S106") |
Java/Kotlin per-block exception |
| Server-side mark-as-FP | UI: Issues → Resolve as False Positive | Persistent across scans; auditable |
| Server-side mark-as-Won't Fix | UI: Issues → Resolve as Won't Fix | Acknowledged risk; not a defect |
Justification template (mandatory in code):
// NOSONAR squid:S106 - Reason: required for CLI tool stdout output
// Reviewer: [email protected] (2026-05-15)
// Expires: 2026-12-15
System.out.println(message);
Server-side resolution requires a comment per SonarQube workflow
config - make it mandatory in admin settings (Administration → Configuration → Issues → Comment required to set status).
Cadence: Issues → False Positive filter periodically; review for
expiration. Server-side resolutions are persistent and auditable -
the audit trail is the value over Semgrep's per-comment approach.
Step 7 - CI integration
jobs:
sonarqube:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with: { fetch-depth: 0 } # full history needed for new-code-period
- uses: Sonar
Установить sonarqube-rules в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл sonarqube-rules?
Use when a team runs SonarQube or SonarCloud for multi-language static analysis and code quality: sonar-scanner and sonar-project.properties, Sonar Way profiles and custom rules, quality gates on new code, branch and PR analysis, and NOSONAR or SuppressWarnings suppressions.
Как установить скилл sonarqube-rules?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл sonarqube-rules запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic