Sonar Groovy Plugin

Enables analysis of Groovy projects.

License

License

Categories

Categories

Groovy Languages
GroupId

GroupId

org.sonarsource.sonar-groovy-plugin
ArtifactId

ArtifactId

sonar-groovy-plugin
Last Version

Last Version

1.2
Release Date

Release Date

Type

Type

sonar-plugin
Description

Description

Sonar Groovy Plugin
Enables analysis of Groovy projects.
Project URL

Project URL

http://redirect.sonarsource.com/plugins/groovy.html
Project Organization

Project Organization

SonarSource
Source Code Management

Source Code Management

https://github.com/SonarCommunity/sonar-groovy

Download sonar-groovy-plugin

Dependencies

compile (4)

Group / Artifact Type Version
org.codehaus.sonar : sonar-deprecated jar 4.5.4
org.codenarc : CodeNarc jar 0.24
org.jacoco : org.jacoco.core jar 0.7.4.201502262128
org.codehaus.sonar.sslr-squid-bridge : sslr-squid-bridge jar 2.6

provided (1)

Group / Artifact Type Version
org.codehaus.sonar : sonar-plugin-api jar 4.5.4

test (5)

Group / Artifact Type Version
org.codehaus.sonar : sonar-testing-harness jar 4.5.4
org.codehaus.sonar : sonar-plugin-api test-jar 4.5.4
xmlunit : xmlunit jar 1.6
org.apache.maven : maven-project jar 2.0.7
org.easytesting : fest-assert jar 1.4

Project Modules

There are no modules declared in this project.

SonarQube plugin for Groovy

Build status

Build Status

Description

The plugin enables analysis of Groovy within SonarQube.

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

Plugin 0.1 0.2 0.3 0.4 0.5 0.6 1.0 1.1 1.1.1 1.2 1.3 1.3.1 1.4
CodeNarc 0.9 0.9 0.13 0.15 0.16.1 0.17 0.20 0.23 0.23 0.24 0.24.1 0.24.1 0.25.2
GMetrics 0.2 0.2 0.3 0.3 0.4 0.5 0.6 0.6 0.7 0.7 0.7 0.7 0.7

Steps to Analyze a Groovy Project

  1. Install SonarQube Server
  2. Install SonarQube Scanner and be sure you can call sonar-scanner from the directory where you have your source code
  3. Install the Groovy Plugin.
  4. Create a sonar-project.properties file at the root of your project
  5. Run sonar-scanner command from the project root dir
  6. Follow the link provided at the end of the analysis to browse your project's quality in SonarQube UI

Notes

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

Groovy File Suffixes It is possible to define multiple groovy file suffixes to be recognized by setting the sonar.groovy.file.suffixes property. Note that by default, only files having .groovy as extension will be analyzed.

Unit Tests Execution Reports Import unit tests execution reports (JUnit XML format) by setting the sonar.junit.reportsPath property. Default location is target/surefire-reports.

JaCoCo and Binaries The groovy plugin requires access to source binaries when analyzing JaCoCo reports. Consequently, property sonar.groovy.binaries has to be configured for the analysis (comma-separated paths to binary folders). For Maven and gradle projects, the property is automatically set.

Coverage Results Import

The Groovy Plugin does not generate its own test coverage report, but re-uses the ones generated by Cobertura or JaCoCo.

Code Coverage with Cobertura

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.

Code Coverage with JaCoCo

To display code coverage data:

  1. Prior to the SonarQube analysis, execute your tests and generate the JaCoCo exec file(s).
  2. In order to be able to read the exec report file, and as JaCoCo bases its analysis on binaries, set the sonar.binaries property.
  3. Set the sonar.groovy.jacoco.reportPath property to the path to the JaCoCo exec file related to your unit tests.
  4. (Optional) If you are running integration tests on top of your unit tests, you may want to set the sonar.groovy.jacoco.itReportPath to the path to JaCoCo exec file related to the integration tests.
  5. Run the SonarQube analysis.

Versions

Version
1.2