How to Scan Your First Project with SonarQube Server

October 30, 2026

SonarQube is a static code analysis server: it reads your source code — no execution, no test runner — and reports bugs, security vulnerabilities, code smells and duplicated blocks. One sonar-scanner run on a mid-size Java service produces hundreds of findings in about two minutes.

It is not a linter. Linters check style rules per file. SonarQube tracks issues across the whole codebase over time, so you see new bugs per commit rather than a static warning list.

What do you need to run it locally?

Docker, 4 GB of RAM, and a sysctl bump. That is the whole requirement for a local test server.

docker run -d --name sonarqube -p 9000:9000 \\
  -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true sonarqube:lts-community

The SONAR_ES_BOOTSTRAP_CHECKS_DISABLE flag exists because SonarQube’s bundled Elasticsearch rejects the default Linux vm.max_map_count of 65530. Without it the container exits after 20 seconds with a confusing error. On a permanent install, set vm.max_map_count=262144 instead.

Open localhost:9000, log in as admin/admin, and change the password when prompted. It is not optional.

How do you set up a project and token?

  1. Click Create Project → Manually.
  2. Set a project key — match your repo name, e.g. myorg:api-service.
  3. Generate a user token under My Account → Security. Copy it once; you cannot view it again.
  4. Pick your build system to get generated instructions.

For Maven, the token goes in ~/.m2/settings.xml or as -Dsonar.token=.... For the generic scanner, sonar-scanner -Dsonar.token=....

The token is a credential. Put it in CI secrets, not in sonar-project.properties. Teams leak this constantly because the file is committed by habit.

How long does the first scan take?

On a typical Spring Boot service of about 45k lines: roughly 90-150 seconds, most of it the first-time quality profile download.

With a Maven project, running mvn verify sonar:sonar compiles first, then analyses. That matters — SonarQube analyses bytecode for Java to catch issues source alone cannot show, like null dereferences across method boundaries.

A JavaScript or TypeScript project analyses source directly and is faster, but you must generate coverage separately. SonarQube does not run tests; it imports coverage reports from Jest, Vitest, or JaCoCo.

What are quality gates and why do they block builds?

A quality gate is a pass/fail condition on the project’s metrics. The default Sonar way gate fails if new code has any bug, any vulnerability, or coverage under 80%.

That 80% number is the first thing teams argue about. It applies only to new code, not the whole repo — a legacy codebase still passes while you improve incrementally. Sensible. Still, a two-week-old startup forcing 80% on itself will stall PRs.

You can define your own gate: e.g. zero new bugs, coverage above 60%, duplication under 5%. Copy the Sonar way gate and edit it rather than building from scratch.

Community vs paid: what is missing

The Community Build is free and covers the core analysis for 15+ languages. What it lacks is the part enterprises buy:

  • Branch and PR analysis — the single biggest gap. Community only analyses the main branch.
  • Taint analysis for injection flaws.
  • The 27 additional languages, plus C/C++ support beyond the basics.
  • SSO and project permissions by group.

Developer Edition starts around $150/month for 100k lines of code and adds PR decoration. For a 10-person team on a 300k-line monorepo, daily scanning without PR checks is close to useless — the findings pile up unseen.

Honest take

SonarQube pays off once you have more than a handful of developers and a codebase older than a year. Below that, ESLint with security plugins plus Dependabot covers most of the value for zero infrastructure.

And it will flag false positives. Every Java codebase gets the same “rename this constant” smells. Budget an hour a week to triage, or mark issues as won’t-fix in bulk, and the dashboard stays useful.

Key Takeaways

  • Run locally with docker run ... sonarqube:lts-community plus the Elasticsearch bootstrap flag.
  • Tokens belong in CI secrets, never in sonar-project.properties.
  • First scan of a 45k-line service takes about 90-150 seconds.
  • Quality gates apply to new code, so legacy codebases still pass while improving.
  • Community Build has no PR/branch analysis — that needs Developer Edition, ~$150/month.