← Projects
CLI

sonarqube-cli

A fast, focused CLI & TUI for SonarQube metrics, quality gates, issues and code snippets — with branch awareness and zero config friction.

New releasev0.3.0today
Started
Last change
Licence
MIT

SonarQube from the terminal: why the quality gate is red, metrics, issues, hotspots and rules, plus an interactive issues dashboard.

Built on @kud/sonarqube, the headless core that holds the client, the layered config and the quality-gate model.

Install

npm install -g @kud/sonarqube-cli

Two binaries, same program: sonarqube and sonarqube-dash (kept for existing scripts). Node 22 or later.

Quick start

export SONARQUBE_DASH_HOST=https://sonarqube.example.com
export SONARQUBE_DASH_TOKEN=<token>
export SONARQUBE_DASH_PROJECT=my-project

sonarqube                         # open the issues dashboard
sonarqube quality-gate            # why is the gate red
sonarqube quality-gate --fail     # same, exit 1 when it is (for CI)
sonarqube issues --new-code -l 25

Running sonarqube with no command opens the dashboard (issues list, detail and a highlighted code snippet; b switches branch and keeps your filters). Outside a terminal it prints help instead. sonarqube issues -i opens it with filters.

Commands

CommandPurpose
(none)Issues dashboard (TUI)
quality-gate, gateGate status, new-code period, failing conditions first
metrics, mGate status and headline metrics
issuesList issues; -i opens the dashboard
issues:summaryIssue counts by severity, type and status
issue <key>One issue (--url, --open)
hotspotsSecurity hotspots
hotspot <key>One hotspot (--url, --open)
rules, rule <key>Search rules, show one
measuresMeasures for a component (-C)
measures:historyMeasure history with sparklines
component-treeFiles under a component
duplicationsDuplicated blocks in a file (-f)
quality-profilesQuality profiles
print-configResolved configuration, token redacted
configset key=value…, get, show, path

Shared flags on every command that talks to SonarQube:

FlagMeaning
-H, --host <url>Server URL (-h is always help)
-t, --token <token>Auth token
-p, --project <key>Project key
-b, --branch <name>Branch
-c, --config <path>Config file to use instead of the default
-j, --jsonJSON output

quality-gate

🚦 Quality gate: FAILED  my-project (main)
   New code: PREVIOUS_VERSION 1.2.0, since 2026-10-01

  ✖ new_coverage                   62.1, needs ≥ 80
  ✖ new_reliability_rating         C, needs A
  ✔ new_duplicated_lines_density   0.5, needs ≤ 3

2 failing conditions

Ratings show as A–E. --fail exits 1 when the gate status is ERROR; --json prints the same explanation as data.

issues

FlagValues
--severitiesBLOCKER,CRITICAL,MAJOR,MINOR,INFO
--typesBUG,VULNERABILITY,CODE_SMELL,SECURITY_HOTSPOT
--statusesOPEN,CONFIRMED,REOPENED,RESOLVED,CLOSED (default: unresolved)
--new-codeOnly issues in the new-code period
-l, --limitMax issues (default 10)

Each issue shows its author (the part before @) and creation date as YYYY-MM-DD.

Configuration

Layers, each overriding the last: config file, environment, flags. Without a project key anywhere, sonar.projectKey is read from sonar-project.properties in the current directory. There is no default host.

SettingEnvironment (first set wins)File key
hostSONARQUBE_DASH_HOST, SONAR_HOST_URLhost
tokenSONARQUBE_DASH_TOKEN, SONARQUBE_TOKEN, SONAR_TOKENtoken
projectSONARQUBE_DASH_PROJECTproject
branchSONARQUBE_DASH_BRANCHbranch

The file lives at $XDG_CONFIG_HOME/sonarqube-dash-cli/config.json (default ~/.config/sonarqube-dash-cli/config.json):

sonarqube config set host=https://sonarqube.example.com token=abc project=my-project
sonarqube config show

Development

npm install
npm run typecheck
npm test
npm run build

Licence

MIT