SonarQube server Erlang language plugin.
The plugin enables analysis of Erlang within SonarQube.
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
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
.
All available keys are available in SonarQube dashboard administration or in ErlangPlugin.java
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.
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.
sonar.erlang.dialyzer.filename
- sets Dialyzer report file name.
sonar.erlang.xref.filename
- sets Xref report file name, located in Eunit report folder. xref.log
by default.
sonar.erlang.elvis.filename
- sets Elvis report file name.
The project uses Maven 3
and JDK 11
and above.
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
Run all unit tests with
mvn test
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.
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
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.