Ruby Language Support

Summary

FeatureStatusNotes
Maintainability✔Complexity, duplication, code smells
Linting✔
Auto-formatting✔
Custom checks✔
Security scanning✔AppSec, dependencies, and secrets
Code metrics✔
Code coverage✔

Details

Maintainability
Complexity✔Aka cognitive complexity
Cyclomatic complexity✔
Identical code duplication✔
Similar code duplication✔
Code smells✔
Linters
RuboCop✔Ruby static code analyzer and formatter
Reek✔Code smell detector for Ruby
StandardRB✔Ruby style guide, linter, and formatter
Brakeman✔Static analysis security vulnerability scanner
Auto-formatters
RuboCop✔Includes formatting capabilities
StandardRB✔Zero-config Ruby formatter
Custom checks
ast-grep✔
Semgrep✔
ripgrep✔
Security scanning
Brakeman✔AppSec (SAST) for Ruby on Rails applications
Gitleaks✔Secrets scanning
OSV-Scanner✔Dependency scanning (SCA)
Semgrep✔AppSec (SAST)
Trivy✔Dependency scanning (SCA)
TruffleHog✔Secrets scanning
Code coverage
SimpleCov✔
Cobertura coverage format✔
JSON coverage format✔

File extensions

By default, Ruby files are defined as:

[file_types.ruby]
globs = [
"*.rb",
"*.rake",
"**/.irbrc",
"**/.pryrc",
"**/Appraisals",
"**/Berksfile",
"**/Brewfile",
"**/buildfile",
"**/Buildfile",
"**/Capfile",
"**/Dangerfile",
"**/Deliverfile",
"**/Fastfile",
"**/Gemfile",
"**/Guardfile",
"**/Jarfile",
"**/Mavenfile",
"**/Podfile",
"**/Puppetfile",
"**/Rakefile",
"**/Snapfile",
"**/Thorfile",
"**/Vagrantfile",
]
interpreters = ["jruby", "rbx", "rake", "macruby", "ruby"]

These patterns can be overridden from qlty.toml.

Code coverage setup

QLTY supports code coverage for Ruby through SimpleCov. For a full working example, see our example Ruby repository.

SimpleCov configuration

To instrument test coverage with SimpleCov:

  1. Install SimpleCov:
1gem install simplecov
  1. Configure SimpleCov to generate JSON reports:
1require 'simplecov'
2require 'simplecov_json_formatter'
3SimpleCov.start do
4 formatter SimpleCov::Formatter::JSONFormatter
5 add_filter '/spec/'
6end

If you want to combine the JSON format with other formats, use SimpleCov’s MultiFormatter:

1SimpleCov.start do
2 formatter SimpleCov::Formatter::MultiFormatter.new([
3 SimpleCov::Formatter::JSONFormatter,
4 SimpleCov::Formatter::HTMLFormatter
5 ])
6 add_filter '/spec/'
7end
  1. Publish SimpleCov’s JSON coverage reports using qlty coverage publish:
1qlty coverage publish coverage/coverage.json

For GitHub Actions users, you can use our example workflow.

Supported Ruby versions

We officially support Ruby 2.5 and later for maintainability checks and code coverage. SimpleCov version 0.22.0+ is recommended for code coverage. Each plugin may have its own version requirements.