All Projects → uartois → Sonar Golang

uartois / Sonar Golang

Licence: lgpl-3.0
Sonarqube plugin for the golang language.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Sonar Golang

gocoverutil
No description or website provided.
Stars: ✭ 25 (-89.08%)
Mutual labels:  coverage, golang-tools
Python Mocket
a socket mock framework - for all kinds of socket animals, web-clients included
Stars: ✭ 209 (-8.73%)
Mutual labels:  coverage
Tinderonline
Find out which of your friends are online on Tinder
Stars: ✭ 155 (-32.31%)
Mutual labels:  golang-tools
Goleft
goleft is a collection of bioinformatics tools distributed under MIT license in a single static binary
Stars: ✭ 175 (-23.58%)
Mutual labels:  coverage
Coveragechecker
Allows old code to use new standards
Stars: ✭ 159 (-30.57%)
Mutual labels:  coverage
Nxplorerjs Microservice Starter
Node JS , Typescript , Express based reactive microservice starter project for REST and GraphQL APIs
Stars: ✭ 193 (-15.72%)
Mutual labels:  coverage
Single cov
Actionable code coverage.
Stars: ✭ 154 (-32.75%)
Mutual labels:  coverage
Codecov Bash
Global coverage report uploader for Codecov
Stars: ✭ 220 (-3.93%)
Mutual labels:  coverage
Cmake Scripts
A selection of useful scripts for use in CMake projects, include code coverage, sanitizers, and dependency graph generation.
Stars: ✭ 202 (-11.79%)
Mutual labels:  coverage
Sonar Stash
Stash (BitBucket) plugin, a pull-request decorator which allows to integrate SonarQube violations directly into your pull-request
Stars: ✭ 174 (-24.02%)
Mutual labels:  coverage
Coverlet
Cross platform code coverage for .NET
Stars: ✭ 2,303 (+905.68%)
Mutual labels:  coverage
Codecov Python
Python report uploader for Codecov
Stars: ✭ 162 (-29.26%)
Mutual labels:  coverage
Deep Cover
The best coverage tool for Ruby code
Stars: ✭ 196 (-14.41%)
Mutual labels:  coverage
Covered
Stars: ✭ 158 (-31%)
Mutual labels:  coverage
Browser Extension
Codecov Browser Extension
Stars: ✭ 212 (-7.42%)
Mutual labels:  coverage
D.s.a Leet
References and summary for leetcode high-frequency algorithm problems
Stars: ✭ 155 (-32.31%)
Mutual labels:  coverage
Fpgo
Monad, Functional Programming features for Golang
Stars: ✭ 165 (-27.95%)
Mutual labels:  golang-tools
Minicover
Cross platform code coverage tool for .NET Core
Stars: ✭ 193 (-15.72%)
Mutual labels:  coverage
Dupl
a tool for code clone detection
Stars: ✭ 228 (-0.44%)
Mutual labels:  golang-tools
Ehtrace
ATrace is a tool for tracing execution of binaries on Windows.
Stars: ✭ 218 (-4.8%)
Mutual labels:  coverage

Community SonarQube Plugin for the Go language

Build Status Quality Gates

Sonarque for GoLang Logo

This is a community plugin for SonarQube to support the Go language started in April 2017 at Artois University. Since May 2018, Go is officially supported by SonarSource with SonarGo.

It integrates GoMetaLinter reports within SonarQube dashboard.

The user must generate a GoMetaLinter report for the 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
# GoLint report path, default value is report.xml 
sonar.golint.reportPath=report.xml 
# Cobertura like coverage report path, default value is coverage.xml 
sonar.coverage.reportPath=coverage.xml 
# if you want disabled the DTD verification for a proxy problem for example, true by default 
sonar.coverage.dtdVerification=false
# JUnit like test report, default value is test.xml
sonar.test.reportPath=test.xml 
sonar.sources=./
sonar.tests=./
sonar.test.inclusions=**/**_test.go
sonar.sources.inclusions=**/**.go
  • 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 one or multiple coverage.xml (cobertura xml format) files.

  • 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 from the root of your project:
gocov test ./... | gocov-xml > coverage.xml

Note that gocov test ./... internally calls go test with the -coverprofile flag for all folders and subfolders, and assembles the coverprofile accordingly by itself (this is necessary, as Golang up to 1.9 does not support the combination go test ./... -coverprofile=...).

If you want to invoke go test manually, you need to do this and the conversion for each package by yourself. For example:

  • For all packages execute those commands:
go test -coverprofile=cover.out
gocov convert cover.out | gocov-xml > coverage.xml

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

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

This is an example of script for create all coverage files for all packages in one time.

for D in `find . -type d`
do
    echo $D
    if [[ $D == ./.git/* ]]; then
        continue
    elif [[ $D == .. ]]; then
        continue
    elif [[ $D == . ]]; then
        continue
    fi

    cd $D
    go test -coverprofile=cover.out
    gocov convert cover.out | gocov-xml > coverage.xml
    cd ..
done

or

go list -f '{{if len .TestGoFiles}}"go test -coverprofile={{.Dir}}/cover.out {{.ImportPath}}"{{end}}' ./... | xargs -L 1 sh -c
go list -f '{{if len .TestGoFiles}}"gocov convert {{.Dir}}/cover.out | gocov-xml > {{.Dir}}/coverage.xml"{{end}}' ./... | xargs -L 1 sh -c

Note for docker users: by default, gocov-xml uses absolute paths which prevents this plugin to use coverage files built on a different file system than the one used to run the plugin. A workaround is to use a patched version of gocov which provides the -pwd option to use relative paths instead of absolute paths. See #35 for details.

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].