Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
Your browser does not support iframes.

Description / Features

This plugin is donation of Sabre Airline Solutions

Delphi Sonar plugin It enables analysis of projects written using Delphi or Pascal. It was tested with projects written in Delphi 6, 7, 2006 and XE.

It is using grammar in ANTLR v3 format. It is extended on grammar found at

It is compatible with the Issues Report plugin to run pre-commit local analysis.


  1. Install the Delphi plugin through the Update Center or download it into the SONAR SONARQUBE_HOME/extensions/plugins directory
  2. Restart the Sonar SonarQubeTM server


Run a


SonarQubeTM Analysis with the Sonar Runner (Recommended Way)

To launch a Sonar an analysis of your Delphi project, use the Sonar Runner.

A sample project is available on github that can be browsed or downloaded/projects/languages/delphi/delphi-sonar-runner.

Run a


SonarQubeTM Analysis with


other Analyzers

Maven and Ant can also be used to launch analysis on Delphi projects.

You can find a sample project in "src/Sample/SampleProject". It contains an Ant script, which you can use to do the analysis. You must have ANT installed.

Install the Delphi plugin on your Sonar instance, and type "Run ant sonar" from the sample project directory in order to try the plugin.


See Metrics documentation page.


  1. Grammar has problems with recognizing certain identifiers. When we add whitespace (“ “) at several places, everything works fine. It was difficult to solve this problem from the grammar level, so it is solved in DelphiSourceSanitizer class. It adds whitespaces where there are needed in parsed file, and grammar works fine. It is used for:
    1. Colon, “:” -> “ :”
    2. Array range, “x..y” -> “x .. y”
  2. Grammar is NOT case insensitive, but Delphi code is. Plugin deals with it by DelphiSourceSanitizer class, which feeds ANTLR parser lowercase characters (the “LA” method)
  3. Number of classes includes: classes, records
  4. Directory is count as a package. Number of packages equals number of directories.
  5. Preprocessor definitions between {$if xxx} and {$ifend} are removed (DefineResolver class).
  6. Sources imported to Sonar SonarQubeTM are parsed through IncludeResolver class. It means, that the source will be lowercased and unknown preprocessor definitions will be cut out.


You can write an XPath sentence which will parse the whole file. Open the “rules.xml” file, copy one of the XPath rules already available and change the “xpath” property to your XPath string. Don’t forget to add the rule to “default-delphi-profile.xml”. That’s it!


For full summary (description, examples) of custom PMD rules, do the following: execute Sonar -> Configuration -> Default Delphi Profile and browse the rules under Delphi profileGo to Settings > Quality Profiles > Delphi to browse the available rules.

List of implemented rules, as follows: