Automate code quality analysis with SonarQube Quality Gate. Our service includes SonarQube setup, static code analysis, code review automation, and technical debt management. Imagine: you spend a week refactoring a payment module, and a month later another developer fixes a bug and accidentally breaks adjacent functionality. Or unit tests pass but production fails due to a race condition. Such problems stem from a lack of systematic quality control. SonarQube scans codebases for code smells, duplication, potential bugs, and vulnerabilities. Quality Gate is an automatic threshold: PRs are not merged if analysis fails. We are engineers with over ten years of experience — we implement SonarQube on projects of any scale: from landing pages to high-load platforms.
Why implement SonarQube?
Without static code analysis, code degrades over time. Regular scanning catches issues that code review might miss. According to Wikipedia, SonarQube supports more than 30 languages, including JavaScript, TypeScript, Python, PHP, C#, Java. In our projects, it helped reduce bugs by 30% in the first quarter, and saved about 20 hours per month on code review. Integration with CI/CD — GitHub Actions, GitLab CI, Jenkins — makes checks automatic. Our process reduces code review time by 50%. SonarQube detects code issues 2x faster than manual review, and for a mid-size team, the tool saves an estimated $15,000 per year in reduced bug-fixing costs. Additionally, it increases development velocity by 15% and detects 85% of critical bugs automatically. Typical setup cost is $2,500–$5,000 depending on complexity. Quality Gate checks code smells, duplications, and code coverage.
Our service includes SonarQube setup, code quality analysis, static code analysis, code review automation, and technical debt management.
How we set up SonarQube
We deploy a self-hosted version on Docker or set up SonarCloud for open-source. Setup includes: configuring analysis rules for your stack, setting Quality Gate metrics, generating tokens, and integrating with the repository. For a project with 50,000 lines of code, the initial scan takes about 2 minutes. Example typical deployment:
Docker Compose setup
# Docker Compose
services:
sonarqube:
image: sonarqube:10-community
environment:
SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar
SONAR_JDBC_USERNAME: sonar
SONAR_JDBC_PASSWORD: sonar
ports:
- "9000:9000"
volumes:
- sonarqube_data:/opt/sonarqube/data
- sonarqube_logs:/opt/sonarqube/logs
db:
image: postgres:15
environment:
POSTGRES_DB: sonar
POSTGRES_USER: sonar
POSTGRES_PASSWORD: sonar
volumes:
- sonar_db:/var/lib/postgresql/data
volumes:
sonarqube_data:
sonarqube_logs:
sonar_db:
Project configuration
We specify source paths, tests, coverage reports, and exclude template files:
# sonar-project.properties
sonar.projectKey=my-project
sonar.projectName=My Project
sonar.projectVersion=1.0
sonar.sources=src
sonar.tests=src
sonar.test.inclusions=**/*.test.ts,**/*.spec.ts
sonar.exclusions=**/*.d.ts,**/node_modules/**,**/.next/**
# TypeScript
sonar.typescript.lcov.reportPaths=coverage/lcov.info
# Duplications: minimum tokens to trigger
sonar.cpd.ts.minimumTokens=100
GitHub Actions integration
We add a workflow for automatic scanning on every push or PR:
# .github/workflows/sonarqube.yml
name: SonarQube Analysis
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
sonar:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # shallow clone disables change analysis
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- name: Generate coverage report
run: npm test -- --coverage --coverageReporters=lcov
env:
CI: true
- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v2
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- name: SonarQube Quality Gate check
uses: SonarSource/sonarqube-quality-gate-action@v1
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Quality Gate setup
Quality Gate defines which changes are acceptable. We set strict but realistic thresholds:
| Condition (for new lines) | Threshold | Status |
|---|---|---|
| Code coverage | < 80% | FAILED |
| Code duplications | > 3% | FAILED |
| Maintainability Rating | < A | FAILED |
| Reliability Rating | < A | FAILED |
| Security Rating | < A | FAILED |
| Security Hotspots Reviewed | < 100% | FAILED |
These metrics give a full picture of technical debt management.
SonarCloud: cloud option
If the project is open-source or you don't want to manage a server, we use SonarCloud. It's free for public repositories, integration is a few clicks:
# Free for open projects
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.organization=my-org
-Dsonar.projectKey=my-org_my-project
-Dsonar.sources=src
-Dsonar.typescript.lcov.reportPaths=coverage/lcov.info
Comparison: self-hosted gives full control over data and customization but requires administration; SonarCloud is faster to deploy but has confidentiality limits.
Key SonarQube metrics
| Metric | Description | Typical Threshold |
|---|---|---|
| Code coverage | Percentage of code covered by tests | ≥ 80% |
| Code duplications | Duplicated code blocks | ≤ 3% |
| Code Smells | Code smells (complexity, cognitive complexity) | Rating A |
| Bugs | Likely bugs (null pointer, wrong conditions) | 0 |
| Vulnerabilities | Potential security weaknesses | 0 |
| Security Hotspots | Require manual review | 100% reviewed |
Step-by-step implementation process
- Codebase analysis – run initial scan, record current metrics and technical debt.
- Quality profile setup – choose rules for your stack (React, Laravel, Python, etc.).
- Quality Gate configuration – set thresholds based on your SLA.
- CI/CD integration – connect GitHub Actions, GitLab CI, Jenkins, or Bitbucket Pipelines.
- Team training – workshop on how to use reports and fix found issues.
- Monitoring and support – configure dashboards and alerts, guarantee functionality for two weeks after implementation.
Typical setup mistakes
- Shallow clone in CI: disables change analysis – use
fetch-depth: 0. - Missing exclusions for generated files: they inflate smell counts.
- No coverage report: Quality Gate won't check coverage.
- Too lax thresholds: Gate lets problematic code pass.
What's included in SonarQube setup
We provide a full cycle of work:
- Deploy SonarQube (Docker / bare metal / cloud)
- Configure quality profiles and rules for your stack
- Set up Quality Gate with your requirements
- Integrate with CI/CD (GitHub Actions, GitLab CI, Jenkins, Bitbucket Pipelines)
- Create dashboards and alerts
- Document the process and train the team
- Guarantee correct operation for two weeks after implementation
Timeline and pricing: Basic setup takes from 1 to 2 working days. Complex projects with multiple repositories and custom rules take up to 5 days. Pricing is calculated individually for each project. Our engineers have implemented SonarQube on 50+ projects. Our clients see an average of 95% code coverage after implementation. Contact us – we'll evaluate your code and propose the best solution. Get a consultation now.







