SonarQube plugin for Groovy
Get test builds from AppVeyor.
This plugin enables analysis of Groovy within SonarQube.
Steps to Analyze a Groovy Project
- Install SonarQube Server
- Install SonarQube Scanner and be sure you can call
sonar-scannerfrom the directory where you have your source code
- Install the Groovy Plugin.
- Create a sonar-project.properties file at the root of your project
sonar-scannercommand from the project root dir
- Follow the link provided at the end of the analysis to browse your project's quality in SonarQube UI
CodeNarc: It is possible to reuse a previously generated report from CodeNarc
by setting the
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
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
For coverage, it is recommended to use the generic SonarQube JaCoCo plugin instead of relying on this plugin to import coverage into SonarQube. Nevertheless, we support importing coverage from Cobertura (but this code path isn't used by the author of the plugin).
Code Coverage with Cobertura
To display code coverage data:
- Prior to the SonarQube analysis, execute your unit tests and generate the Cobertura XML report.
- Import this report while running the SonarQube analysis by setting the
sonar.groovy.cobertura.reportPathproperty to the path to the Cobertura XML report. The path may be absolute or relative to the project base directory.
Contributions via GitHub issues and pull requests are very welcome. This project tries to adhere to the Google Java Style, but we don't want a global reformat to keep the Git history readable. To help with this, you can use the fmt-maven-plugin to format your changes:
mvn fmt:format -DfilesNamePattern=TestUtils\.java
You can use the
fileNamePattern option to restrict the formatter to the files
In the directory
codenarc-converter there is a little helper tool to convert
CodeNarc rules to SonarQube rules. To do its job it needs a source copy of
CodeNarc - this is currently achieved by including the used CodeNarc version as
a git subbmodule. If you need to update CodeNarc, you need to update that
git submodule init cd codenarc-converter/CodeNarc git checkout vX.Y.Z cd .. git add CodeNarc
You should then run the
mvn verify should be
enough if the project is set up correctly) and merge descriptions from
The converter does a pretty crude job converting CodeNarc's APT documentation
into SonarQube rule descriptions.