Directory Compare FCRS-1.0 /llms.txt
← Back to Directory

SonarScanner

$ sonar-scanner Official Med Risk
SonarSource · Code & DevOps · LGPL-3.0 · macos / linux / windows

Official SonarSource scanner CLI that bundles project metadata, runs language analyzers locally, and uploads analysis reports to a SonarQube Server or SonarCloud instance. Designed for CI pipelines rather than headless agent local loops: emits verbose JVM logs without stdout JSON findings and requires SONAR_TOKEN plus a live server.

FCRS-1.0 Score
68 /100
Usable w/ Caveats
Medium Confidence
Zero-Friction Install
brew install sonar-scanner
CLI vs MCP Decision Hybrid (CLI + MCP)

sonar-scanner uploads analysis snapshots to SonarQube/SonarCloud, whereas querying issues and quality-gate status afterward is cleaner via SonarQube REST API or MCP.

Agent-Readiness Checklist

— JSON Output
— Field Filtering
✓ Non-Interactive
— Dry-Run
— Read-Only Mode
— NO_COLOR Clean
✓ Self-Describing
— Official SKILL.md

Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 13 / 25

Emits noisy multi-line INFO logs and uploads results asynchronously to a server rather than returning --json findings to stdout.

  • No --json stdout report for code findings
  • Requires polling the SonarQube Web API for Quality Gate results unless -Dsonar.qualitygate.wait=true is configured
Trust & Safety 18 / 25

Uploads source analysis payloads to a remote server using SONAR_TOKEN and leaves .scannerwork/ caches locally.

  • Remote upload side effect on every scan run
  • Supports SONAR_TOKEN env var isolation
Setup & Portability 10 / 15

Heavy distribution with JVM/JRE dependency plus mandatory reachable SonarQube or SonarCloud backend.

  • Cannot produce standalone offline lint results without a Sonar server
Utility & Efficiency 11 / 15

Valuable for organizations standardized on SonarQube Quality Gates, but overkill compared to ruff, eslint, or semgrep in agent edit loops.

  • Heavy CI-oriented batch workflow
Maintenance & Lineage 9 / 10

Official SonarSource CLI (SonarSource/sonar-scanner-cli) under LGPL-3.0.

  • Official SonarSource/sonar-scanner-cli repository
Docs & Verifiability 7 / 10

Extensive official docs across SonarQube Server and SonarCloud, though -Dsonar.* properties vary by language plugin.

  • Official docs at docs.sonarsource.com

Security, Auth & Guardrails

Auth Modes
Env API Key Config File
Credential Storage

Authenticates via SONAR_TOKEN env var (preferred) or sonar.token in sonar-project.properties.

Side Effects
Read-Only Local Write Remote Write
Cost & Quotas

Scanner CLI is LGPL-3.0 free; SonarQube Community is free while Enterprise/SonarCloud plans are commercial.

Copyable Guardrail for CLAUDE.md / AGENTS.md
# SonarScanner Agent Rules
- Never run `sonar-scanner` blindly as a local linter; it uploads reports to a remote SonarQube/SonarCloud server and writes `.scannerwork/`.
- Supply `SONAR_TOKEN` via environment variable rather than hardcoding tokens in `sonar-project.properties`.

Agent-Ready Command Recipes

Safe Read-Only Queries

Verify SonarScanner version and environment
sonar-scanner --version

Prints the installed scanner and embedded JRE versions without uploading any scan.

Controlled Writes & Previews

Submit project scan to SonarQube server
sonar-scanner -Dsonar.projectKey=my-app -Dsonar.host.url=https://sonar.example.com

Analyzes local sources and uploads the report to SonarQube using SONAR_TOKEN; writes .scannerwork/ locally.

Strengths for Agents

  • + Official launcher supporting SonarQube and SonarCloud Quality Gates across 30+ languages.
  • + Honors SONAR_TOKEN environment variable for clean CI/CD authentication.

Caveats & Pitfalls

  • ! Cannot run as an offline local linter; every scan requires a SonarQube/SonarCloud server and uploads project data.
  • ! Outputs verbose JVM logs with no local JSON findings format; agents must query the server API for issues.

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI