SonarQube plugin for analyzing Ruby files
- Rubocop (https://github.com/bbatsov/rubocop)
- Simplecov (https://github.com/colszowka/simplecov)
- Tested with v6.5, v6.6, v7.1
This is plugin for SonarQube 5.6+ for analysing projects with Ruby content that supports:
- Rubocop for code quality information
- Simplecov for unit test coverage information
- NCLOC metric generation
This is an example of what a project configuration file (sonar-project.properties
) could look like:
sonar.projectKey=company:my-application
sonar.projectName=My Application
sonar.projectVersion=1.0
sonar.sourceEncoding=UTF-8
sonar.sources=src/app
sonar.exclusions=**/node_modules/**,**/*.spec.ts
sonar.tests=src/app
sonar.test.inclusions=**/*.spec.ts
sonar.ruby.file.suffixes=rb,ruby
sonar.ruby.coverage.reportPath=coverage/.resultset.json
sonar.ruby.coverage.framework=RSpec
sonar.ruby.rubocopConfig=.rubocop.yml
sonar.ruby.rubocop=/usr/bin/rubocop
sonar.ruby.rubocop.reportPath=rubocop-result.json
sonar.ruby.rubocop.filePath=.
Here are the steps to manually install this plugin for use in SonarQube:
- Download the plugin jar
- Copy the jar into the SonarQube plugin directory (e.g. /opt/sonarqube/extensions/plugins)
- Restart SonarQube
TODO: Need to get this plugin added to SonarQube's update center
In order to run the analysis for Ruby you will need to utilize the sonar-scanner application.
-
Run rubocop making sure that the json results file is created
e.g.rubocop --format=json --out=rubocop-result.json
-
Run your specs (make sure that your sonarqube config points to the right coverage directory )
e.g.bundle exec rspec spec
Make sure that your sonarqube config points to the right coverage directory e.g.spec/coverage/.resultset.json
-
Make sure you have a sonar-project.properties file in the root of your project directory
-
run
sonar-scanner
To request a new feature, create a GitHub issue. Even if you plan to implement it yourself and submit it back to the community, please create an issue to be sure that we can follow up on it.
To submit a contribution, create a pull request for this repository.
Copyright 2017-2018 Fortitude Technologies.
Licensed under the MIT License