Git Product home page Git Product logo

sonar-groovy's Introduction

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.

sonar-groovy's People

Contributors

wohops avatar godin avatar benzonico avatar gaudol avatar ehartmann avatar simonbrandhof avatar tomverin avatar mpaladin avatar henryju avatar ganncamp avatar dgageot avatar drautureau-sonarsource avatar rdmueller avatar itbalaji avatar dbolkensteyn avatar iwarapter avatar musketyr avatar appienvanveen avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.