Giter VIP home page Giter VIP logo

sonar-golang's Introduction

SonarQube Plugin for the Go language Build Status

Sonarque for GoLang Logo

It integrates GoMetaLinter reports within SonarQube dashboard.

The user must generate a GoMetaLinter report for his code using the checkstyle format. The report is thus integrated to SonarQube using sonar-scanner.

Release 1.0 only provides golint support. Release 1.1 provides test coverage support. Upcoming releases will bring support for additional linters.

Authors

  • Thibault Falque
  • Daniel Le Berre

Installation

  • Download the latest version of the artifact
  • Stop sonarqube server
  • Put the jar file in $SONAR_PATH/extensions/plugins
  • Start sonarqube server

Enabling all latest rules

If you have already installed the plugin and you want to enable the new rules provided by the new version of the plugin, follow those steps after the installation:

  • Go on the Quality Profiles page
  • Click on the arrow near the "Create" button
  • Click on "Restore Built-In Profiles"
  • Choose the language (Go)
  • Click on "Restore"

Using the plugin

  • create a sonar-project.properties file.
sonar.projectKey=yourprojectid
sonar.projectName=name of project
sonar.projectVersion=1.0
sonar.golint.reportPath=report.xml //default
sonar.coverage.reportPath=coverage.xml // default
sonar.coverage.dtdVerification=false // if you want disabled the DTD verification for a proxy problem for example 
sonar.test.reportPath=test.xml //default
sonar.sources=./
  • start the analysis
sonar-scanner

It is assumed that you have the sonar scanner executable on your path and to run it at the root of your go project.

GoMetaLinter support

go get -u gopkg.in/alecthomas/gometalinter.v1
gometalinter.v1 --install
  • Generate a gometalinter report using the checkstyle format:
gometalinter.v1 --checkstyle > report.xml

Coverage (since release 1.1)

For coverage metrics you must have a coverage.xml (cobertura xml format) file per package.

  • First install the tools for converting a coverprofile in cobertura file:
go get github.com/axw/gocov/...
go get github.com/AlekSi/gocov-xml
  • Then for all packages execute those commands:
go test -coverprofile=cover.out
gocov convert cover.out | gocov-xml > coverage.xml

You must end-up with one coverage file per directory:

pkg1/coverage.xml
pkg2/coverage.xml
pkg3/coverage.xml
...

Tests (since release 1.1)

For test metrics you must generate a junit report file.

  • install the tools:
go get -u github.com/jstemmer/go-junit-report
  • run the tests from the root of your project:
go test -v ./... | go-junit-report > test.xml

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.