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 |
sonar-scanner
from the directory where you have your source codesonar-scanner
command from the project root dirCodeNarc
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.
The Groovy Plugin does not generate its own test coverage report, but re-uses the ones generated by Cobertura or JaCoCo.
To display code coverage data:
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.To display code coverage data:
sonar.groovy.jacoco.reportPath
property to the path to the JaCoCo exec file related to your unit tests.sonar.groovy.jacoco.itReportPath
to the path to JaCoCo exec file related to the integration tests.