DEV Community

Alex Spinov
Alex Spinov

Posted on

SonarQube Has a Free Code Quality Platform — Catch Bugs, Vulnerabilities, and Code Smells Automatically

SonarQube Has a Free Code Quality Platform — Catch Bugs, Vulnerabilities, and Code Smells Automatically

Code reviews catch some issues. Linters catch others. SonarQube catches what both miss — deep static analysis that finds bugs, security vulnerabilities, and maintainability issues across your entire codebase.

Free Tier (Community Edition)

  • Unlimited projects (self-hosted)
  • 30+ languages supported
  • Thousands of rules for bugs, vulnerabilities, code smells
  • Quality Gates — block merges if quality drops
  • CI/CD integration — GitHub Actions, GitLab CI, Jenkins
  • SonarCloud — free for open source projects (hosted version)

What SonarQube Catches

// BUG: Comparing with = instead of ==
if (user.role = 'admin') { // SonarQube flags this
  grantAccess();
}

// VULNERABILITY: SQL Injection
const query = `SELECT * FROM users WHERE id = ${req.params.id}`;
// Fix: Use parameterized queries

// CODE SMELL: Cognitive complexity too high
function processOrder(order) {
  if (order.items) {
    for (const item of order.items) {
      if (item.quantity > 0) {
        if (item.price > 0) {
          if (item.inStock) {
            // Too many nested conditions
          }
        }
      }
    }
  }
}

// SECURITY HOTSPOT: Hardcoded credentials
const DB_PASSWORD = 'mysecretpassword123'; // SonarQube flags this
Enter fullscreen mode Exit fullscreen mode

CI/CD Integration (GitHub Actions)

name: Code Quality
on: [push, pull_request]

jobs:
  sonarqube:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: SonarSource/sonarqube-scan-action@v5
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
          SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
Enter fullscreen mode Exit fullscreen mode

Quality Gates

Set rules that block merges if code quality drops:

Quality Gate "Strict":
- New Code Coverage: >= 80%
- New Bugs: 0
- New Vulnerabilities: 0
- New Code Smells: <= 5
- New Duplications: <= 3%
Enter fullscreen mode Exit fullscreen mode

SonarCloud (Free for Open Source)

# sonar-project.properties
sonar.projectKey=my-project
sonar.organization=my-org
sonar.sources=src
sonar.tests=tests
sonar.javascript.lcov.reportPaths=coverage/lcov.info
Enter fullscreen mode Exit fullscreen mode

The Bottom Line

SonarQube is your automated code reviewer that never gets tired, never misses a PR, and checks every single line. Free for self-hosted or open source via SonarCloud.


Need to audit code repositories, monitor open-source dependencies, or build automated security pipelines? I create custom solutions.

📧 Email me: spinov001@gmail.com
🔧 My tools: Apify Store

Top comments (0)