Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
{iframe:src=http://update.sonarsource.org/plugins/delphi.html|width=700|height=250|frameborder=0}
Your browser does not support iframes.
{iframe}
Warning
titleDeprecated

This plugins is deprecated because it is no longer maintained by its contributors.

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 http://www.dragonkiller.nl/Delphi/delphi2009.txt

Installation

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

Usage

Run a Sonar Analysis with the Sonar Runner (Recommended Way)

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

Include Page
Include - Plugin Installation
Include - Plugin Installation

Usage

Run an Analysis with the SonarQube Runner (Recommended method)

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

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

Run a

Sonar Analysis

SonarQube Analysis with

the

other Analyzers

Maven and Ant can also be used to launch analysis on Web 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.

Metrics

See Metrics documentation page.

IMPLEMENTED FEATURES

  1. Counting lines of code, statements, number of files
  2. Counting number of classes, number of packages, methods, accessors
  3. Counting number of public API (methods, classes and fields)
  4. Counting comments ratio, comment lines (including blank lines)
  5. CPD (code duplication, how many lines, block and in how many files)
  6. Code Complexity (per method, class, file; complexity distribution over methods, classes and files)
  7. LCOM4 and RFC
  8. Code colorization
  9. Unit tests reports
  10. Assembler syntax in grammar
  11. Include statement
  12. Parsing preprocessor statements
  13. Rules
  14. Code coverage reports
  15. Source code highlight for unit tests
  16. “Dead” code recognition
  17. Unused files recognition

...

  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 are SonarQube 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!

IMPLEMENTED RULES

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:

...