Ruby coverage reporter for Codacy https://www.codacy.com
Parses SimpleCov output and submits the result to Codacy
Include the gem in your project
gem 'codacy-coverage', :require => false
In the first line of your spec_helper initialize the reporter:
require 'codacy-coverage' Codacy::Reporter.start
To update Codacy, you will need your project API token. You can find the token in Project -> Settings -> Integrations -> Project API.
Then set it in your terminal, replacing %Project_Token% with your own token:
To send coverage in the enterprise version you should:
By default this plugin will not submit results if you run your tests in localhost. If you want to force the submission you can setup the following environment variable:
Note: You should keep your API token well protected, as it grants owner permissions to your projects.
When you run your tests, the plugin will send the coverage info to Codacy.
For example, run the following commands:
gem install bundler bundle install
This will install the required dependencies. Then just run the tests:
bundle exec rspec
By default, the debug info will be logged into a file. If you want the debug info to be printed to stdout you can:
You can now check your coverage results in the Codacy dashboard of your project.
Cannot send coverage when using VCR
require 'vcr' VCR.configure do |config| # other config options config.allow_http_connections_when_no_cassette = false config.ignore_hosts 'api.codacy.com' end
Cannot generate local simplecov report
SimpleCov.formatter by adding both your prefered simplecov formatter and Codacy's formatter.
You can also add more options to
require 'simplecov' require 'codacy-coverage' SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([ SimpleCov::Formatter::HTMLFormatter, Codacy::Formatter ]) SimpleCov.start do add_filter '.gems' add_filter 'pkg' add_filter 'spec' add_filter 'vendor' end
What is Codacy?
Codacy is an Automated Code Review Tool that monitors your technical debt, helps you improve your code quality, teaches best practices to your developers, and helps you save time in Code Reviews.
Among Codacy’s features:
- Identify new Static Analysis issues
- Commit and Pull Request Analysis with GitHub, BitBucket/Stash, GitLab (and also direct git repositories)
- Auto-comments on Commits and Pull Requests
- Integrations with Slack, HipChat, Jira, YouTrack
- Track issues in Code Style, Security, Error Proneness, Performance, Unused Code and other categories
Codacy also helps keep track of Code Coverage, Code Duplication, and Code Complexity.
Free for Open Source
Codacy is free for Open Source projects.