Mix utilities for the sonar-elixir SonarQube plugin.
Note
Mix tasks in this package are meant to be run before sonar-scanner to support features like test
coverage reporting. You also need the sonar-elixir plugin installed
in your SonarQube instance for Elixir language support.
Add sonarqube to your list of dependencies and configure it as the cover tool in mix.exs:
def project do
[
app: :your_app,
deps: deps(),
version: "0.1.0",
# Add this.
test_coverage: [tool: SonarQube.Coverage]
]
end
# Add this so `mix sonarqube.coverage` runs in the test environment.
def cli do
[preferred_envs: ["sonarqube.coverage": :test]]
end
def deps do
[
{:sonarqube, "~> 0.1.0", only: [:dev, :test], runtime: false}
]
endRun tests with coverage and generate a SonarQube-compatible XML report:
mix sonarqube.coverageThis produces cover/sonar-coverage.xml alongside the standard Elixir coverage output.
All arguments are passed through to mix test:
mix sonarqube.coverage test/my_module_test.exsOptions are configured via test_coverage in mix.exs:
| Option | Default | Description |
|---|---|---|
:sonar_xml |
cover/sonar-coverage.xml |
Output path for the XML report |
test_coverage: [tool: SonarQube.Coverage, sonar_xml: "reports/sonar-coverage.xml"]Add the coverage report path to your sonar-project.properties:
sonar.coverageReportPaths=cover/sonar-coverage.xmlThen run sonar-scanner to upload the results to your SonarQube instance.
Copyright (c) 2026 Henry Popp
This project is MIT licensed. See the LICENSE for details.