Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
{iframe:src=http://updateredirect.sonarsource.orgcom/plugins/groovy.html|width=700|height=220300|frameborder=0}
YourDocumentation browserhas doesbeen notmoved support iframes.
{iframe}
Tip
titleLive example

If you want to see a live example of the capabilities of the Groovy plugin, you can have a look at the analysis of the CodeNarc project on Nemo.

Description / Features

The plugin enables analysis of Groovy projects within SonarQube.

It leverages CodeNarc to raise issues against coding rules, Gmetrics for cyclomatic complexity and Cobertura for code coverage.

Plugin

0.1

0.2

0.3

0.4

0.50.61.0

CodeNarc

0.9

0.9

0.13

0.15

0.16.10.170.20

GMetrics

0.2

0.2

0.3

0.3

0.40.50.6

...

Usage

Run an Analysis with the SonarQube Runner (Recommended method)

To run an analysis of your Groovy project, use the SonarQube Runner.

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

Run an Analysis with the other Analyzers

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

A Maven sample project is available on github that can be browsed or downloaded/projects/languages/groovy/groovy-maven.

Code Coverage

To display code coverage data:

  1. Prior to the SonarQube analysis, execute your unit tests and generate the Cobertura XML report.
  2. Import this report while running the SonarQube analysis by setting the sonar.groovy.cobertura.reportPath property to the path to the Cobertura XML report. The path may be absolute or relative to the project base directory.

A sample project can be browsed or downloaded: TODO

CodeNarc

It is possible to reuse a previously generated report from CodeNarc by setting the sonar.groovy.codenarc.reportPath property.

Metrics

See Metrics documentation page.

Known Limitations

  • The following piece of code won't be properly parsed because command expression is not currently supported.

    Code Block
    languagegroovy
    a = Arrays.asList 1,2,3,4,5
  • If you're analyzing with Maven, the Groovy source directory must be added to the pom.xml explicitly, because SonarQube does not call the gmaven plugin.

Release Notes

Version 1.0

It is no longer possible to:

  • let SonarQube drive the execution of unit tests
  • import unit test execution reports
  • let SonarQube drive the execution of Cobertura; it is now only possible to import previously generated Cobertura report

 

to [http://redirect.sonarsource.com/plugins/groovy.html].
{iframe}