Skip to content

PMD vs SonarQube

Suphi Cankurt

Written by Suphi Cankurt

PMD vs SonarQube
Key Takeaways
  • PMD is an open-source code analyzer rooted in Java and Apex with support for around 18 languages in total. SonarQube is an all-in-one code quality and security platform covering 40+ languages with static analysis plus reliability and maintainability metrics.
  • PMD is fully free under BSD-style licensing with no paid tier. SonarQube has a free Community Build under LGPL-3.0 plus commercial Developer, Enterprise, and Data Center editions priced per instance per year by lines of code.
  • PMD ships 400+ built-in rules and lets teams write XPath-based custom rules without recompiling the distribution. SonarQube uses its Sonar Way ruleset and adds taint analysis, security hotspots, and branch analysis in commercial editions.
  • SonarQube provides a centralised dashboard, quality gate enforcement, PR decoration, and IDE integration via SonarQube for IDE (formerly SonarLint). PMD ships as a CLI and Maven / Gradle plugin without a hosted dashboard.
  • Most teams that grow past basic linting move from PMD to SonarQube for the dashboard, multi-language coverage, and security-focused rules. PMD remains useful as a Java-and-Apex specialised second opinion or in lightweight Maven-only stacks.

Which Is Better: PMD or SonarQube?

SonarQube wins for breadth, dashboard, and security depth. PMD wins for zero-config Java linting and lightweight stacks.

PMD is an open-source static code analyzer first released in 2002, primarily focused on Java and Salesforce Apex with rules across roughly 18 languages.

It runs as a CLI or Maven / Gradle plugin, catches bug patterns, design smells, and a curated set of security risks, and works well in Java-only projects without a central dashboard.

SonarQube is a code quality and security platform built by SonarSource. It covers 40+ languages, surfaces findings in a hosted dashboard, integrates with SonarQube for IDE inside the editor, gates PRs, and adds taint analysis plus security hotspots in commercial editions.

For a single-language Java project that just wants linting in CI, PMD does the job. For everything else, SonarQube is the more complete answer.

Key Differences

DimensionPMDSonarQube
LicenseBSD-style (fully free)LGPL-3.0 Community Build + paid editions
LanguagesJava, Apex, JavaScript, Kotlin, Swift, PL/SQL +more40+ languages
Analysis depthLinter / pattern matchingCode quality + reliability + SAST + taint analysis (commercial)
IDE integrationEclipse, IntelliJ via third-party pluginsFirst-party SonarQube for IDE (VS Code, IntelliJ, Eclipse, VS)
DashboardNone first-party (CI-only output)Hosted SonarQube Server or SonarQube Cloud SaaS
Quality gateCLI exit codes onlyServer-enforced gate with PR decoration
Custom rulesXPath rules without recompilingCustom rules via plugins (Java)
Best forJava-only Maven projectsPolyglot stacks with central dashboard requirement

Head-to-Head

License and pricing

PMD is open source under a BSD-style license. There are no paid tiers. Install the CLI, the Maven plugin, or the Gradle plugin and run.

SonarQube’s Community Build is open source under the LGPL-3.0 license. The Developer, Enterprise, and Data Center editions add commercial features.

Branch analysis, taint analysis, security hotspots in PR decoration, project portfolios, and enterprise reporting are all behind the paid tiers. Sonar prices Developer Edition per instance per year, scaled by lines of code; tier figures are quoted on Sonar’s plans page rather than displayed on the public catalogue.

For teams that need only the basics, both tools have a free path. SonarQube’s commercial upgrade triggers when teams need PR-level branch analysis or deeper security findings.

Language coverage

PMD’s primary language is Java. The Java ruleset is the most mature, with rules dating back to PMD’s 2002 launch.

PMD also supports Salesforce Apex and Visualforce, JavaScript, Kotlin, Swift, PL/SQL, Velocity, JSP, WSDL, Maven POM, HTML, XML, XSL, and Modelica. Scala can be parsed but ships without built-in rules. Java is the gold standard for rule depth, and the others trail.

SonarQube supports 40+ languages out of the box. The Sonar Way ruleset covers each language with quality and security rules curated by Sonar’s research team.

Rule curation and custom rules

PMD ships 400+ built-in rules across categories: Best Practices, Code Style, Design, Documentation, Error Prone, Multithreading, Performance, and Security. Custom rules can be written in XPath without needing to recompile the PMD distribution, which makes rule authoring relatively low-friction for Java codebases.

SonarQube’s Sonar Way ruleset is curated by SonarSource. Each language has its own rule set, with around 600 Java rules in recent versions.

Custom rules require writing a Java plugin against SonarQube’s plugin API. That is significantly heavier than PMD’s XPath approach.

For teams that write custom Java rules regularly, PMD is the lighter touch. For teams that consume rules without writing many custom ones, SonarQube’s curated set is the easier path.

Analysis depth

PMD performs pattern matching on the AST. It catches design smells, code-style violations, common bug patterns, and a curated set of security-relevant patterns.

SonarQube’s open-source build does similar pattern matching plus reliability and maintainability metrics. The commercial editions add taint analysis through the Sonar Security Engine.

Taint analysis traces data flows from sources to sinks. That is the kind of analysis required for SQLi, XSS, command injection, and path traversal findings.

For deep security analysis, the commercial SonarQube editions outclass PMD. For surface-level linting, PMD competes well.

Developer experience

PMD runs as a CLI, a Maven plugin, a Gradle plugin, or via third-party IDE wrappers like the Eclipse PMD plugin and the JetBrains plugin. There is no first-party hosted dashboard. Output is XML, JSON, HTML, or SARIF.

SonarQube ships a server you host yourself, or you can use SonarQube Cloud as the SaaS option. The server is the dashboard. Issue triage, quality-gate enforcement, PR decoration, and historical trending all live there.

SonarQube for IDE (formerly SonarLint) is the first-party IDE plugin for VS Code, IntelliJ, Eclipse, and Visual Studio, with a connected mode that pulls server rules into the IDE.

For teams that want a central dashboard plus IDE-time feedback, SonarQube’s developer experience is significantly more complete.

When to Choose Each

Choose PMD when

  • The project is Java-only or Java-and-Apex.
  • You want a free, drop-in linter for Maven or Gradle without operating a server.
  • You expect to write XPath-based custom rules regularly.
  • You only need linting and basic security findings, not dashboard or PR decoration.

Choose SonarQube when

  • The codebase is polyglot, mixing Java with JS/TS, Python, C#, or Go.
  • You want a central dashboard with quality-gate enforcement and PR decoration.
  • IDE-time feedback through SonarQube for IDE is part of the requirement.
  • You need taint analysis and deeper security findings (commercial editions).

Choose both when

  • Java-heavy stack where you want PMD’s specialised Java rules and SonarQube’s central dashboard. SonarQube can ingest PMD’s XML output as an external analyzer report.

Frequently Asked Questions

What is the difference between PMD and SonarQube?
PMD is an open-source static code analyzer first released in 2002, focused on Java and Salesforce Apex with built-in rules for roughly 18 languages and BSD-style licensing. SonarQube is a code quality and security platform from SonarSource that covers 40+ languages, ships a hosted dashboard, and offers a free Community Build under LGPL-3.0 plus paid Developer, Enterprise, and Data Center editions. PMD runs as a CLI or build-tool plugin and outputs reports. SonarQube provides a centralised server with quality gates, PR decoration, and IDE feedback through SonarQube for IDE.
Is PMD a SAST tool or a linter?
PMD straddles the line. It runs static analysis on the source code and detects bug patterns, code smells, design issues, and a smaller set of security-relevant patterns. PMD does not have full taint analysis or dataflow tracking like commercial SAST engines, so it sits closer to a linter on the analysis-depth axis. For security-focused work, teams typically pair PMD with a dedicated SAST tool like SonarQube, Semgrep, or commercial scanners.
Is SonarQube free?
SonarQube has a free Community Build under the LGPL-3.0 license that handles the basics: Sonar Way ruleset, code-quality findings, and basic security analysis. The Developer, Enterprise, and Data Center editions are paid and add branch analysis, taint analysis, security hotspots in PR decoration, project portfolios, and enterprise reporting. Sonar prices Developer Edition per instance per year, scaled by lines of code; tier figures are quoted on the Sonar plans page rather than displayed publicly. PMD is fully free under a BSD-style license with no paid tier.
Can I use PMD and SonarQube together?
Yes. SonarQube can ingest PMD’s XML output as an external analyzer report so PMD findings appear inside the SonarQube dashboard alongside Sonar’s own findings. This is a common pattern in Java shops that want SonarQube as the central quality dashboard but still want PMD’s Java-specific rules to keep flowing. The trade-off is duplicate findings on areas where both tools have rules.
Which has better Java support?
PMD is Java-first. It has been a Java code analyzer since 2002 and the Java ruleset is its most mature. PMD also supports Salesforce Apex and Visualforce, JavaScript, Kotlin, Swift, Modelica, PL/SQL, Apache Velocity, JSP, WSDL, Maven POM, HTML, XML, and XSL — about 18 languages with active rules — plus parse-only support for Scala (no built-in rules yet). SonarQube covers Java with the SonarJava analyzer plus taint analysis in commercial editions, and adds first-class support for 40+ languages overall. For Java-only Maven shops, PMD’s depth is competitive. For polyglot stacks, SonarQube wins on coverage.
Does PMD do security scanning?
PMD includes a security ruleset that catches common Java security patterns: hardcoded crypto keys, weak SSL configuration, XML external entity (XXE) risks, and so on. The depth is limited compared to dedicated SAST engines that perform taint analysis or interprocedural dataflow. For lightweight security gating in a Java-only project, PMD’s security rules are useful. For deeper analysis, pair PMD with SonarQube’s commercial editions, Semgrep, or a commercial SAST tool.
Suphi Cankurt

9+ years in application security. Reviews and compares 201 AppSec tools across 12 categories to help teams pick the right solution. More about me →