Skip to content

SonarQube Server plugin for Erlang project analysis.

Notifications You must be signed in to change notification settings

cursorinsight/sonar-erlang

 
 

Repository files navigation

Build Quality Gate Status Maintainability Rating

About

SonarQube server Erlang language plugin.

Description / Features

The plugin enables analysis of Erlang within SonarQube.

Usage

Run an Analysis with the SonarQube Scanner (recommended method)

To run an analysis of your Erlang project, use the SonarQube Scanner. A sample project is available on GitHub: https://github.com/SonarSource/sonar-scanning-examples/tree/master/sonarqube-scanner

Run an Analysis with other Analyzers

Maven and Ant can also be used to launch analysis on Erlang projects.

The plugin has been tested to work with SonarQube Community Version 9.9.1 .

Configuration

All available keys are available in SonarQube dashboard administration or in ErlangPlugin.java

EUnit report import

sonar.erlang.eunit.reportsfolder - sets the Eunit reports folder, .eunit by default.

sonar.erlang.eunit.coverdata.filename - sets the Eunit coverage report file name, eunit.coverdata by default.

Common Test report import

sonar.erlang.ct.coverdata.filename - sets the Common Test coverage file name, all.coverdata by default in project root. The easiest way to export this file is to use a cover spec file.

You can see an example of such a file HERE.

Check out how to configure Common Test for coverage in the sample Makefile.

Dialyzer

sonar.erlang.dialyzer.filename - sets Dialyzer report file name.

See issue about Dialyzer

Xref

sonar.erlang.xref.filename - sets Xref report file name, located in Eunit report folder. xref.log by default.

Elvis

sonar.erlang.elvis.filename - sets Elvis report file name.

Development

The project uses Maven 3 and JDK 11 and above.

Build

Build the release plugin JAR with Maven

mvn clean package

You will find the built JAR in sonar-erlang-plugin/target/sonar-erlang-plugin.jar

Test

Run all unit tests with

mvn test

Integration testing

First, you can bring up a local SonarQube server instance using docker by running

docker compose up -d

This will run a SonarQube instance in Docker and mount necessary volumes.

To install the built plugin jar, you must copy it to the following path like so after mvn package:

cp ./sonar-erlang-plugin/target/sonar-erlang-plugin.jar ./sonar/extensions/plugins/sonar-erlang-plugin.jar

After that, access the server's dashboard (usually localhost:9000) with initial credentials admin:admin Then, restart the server instance and accept the loaded plugin.

Now, create a new project with the project key Erlang::erlcount and save the access token.

Finally, navigate to the sample project in sonar-erlang-plugin/src/test/resources/org/sonar/plugins/erlang/erlcount and run the sonar-scanner CLI:

sonar-scanner -Dsonar.login=<YOUR-TOKEN>

Once the scan is complete, you can view the results of the analysis in the dashboard, or fetch the metrics using the web API.

Docker build

A basic Dockerfile is provided to build the plugin without installing JDK and Maven. To make integration test processes easier it is directly written into ./sonar/extensions/plugins:

docker build --target export -o- . | tar xv -C ./sonar/extensions/plugins/

You can easily debug and inspect the entire build process without using the final export target. This command produces an image containing all the temporary build artifacts and outcomes of the build process:

docker build . -t sonar-erlang-build

Contributing

Simply create a new GitHub Issue in 2 categories: suggestion, or a bug report. If possible, include any useful data like logs, examples, code etc.

About

SonarQube Server plugin for Erlang project analysis.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Erlang 58.0%
  • Java 38.7%
  • HTML 3.1%
  • Python 0.1%
  • Makefile 0.1%
  • Dockerfile 0.0%