Ruby Language Support

Summary

FeatureStatusNotes
MaintainabilityComplexity, duplication, code smells
Linting
Auto-formatting
Custom checks
Security scanningAppSec, dependencies, and secrets
Code metrics
Code coverage

Details

Maintainability
ComplexityAka cognitive complexity
Cyclomatic complexity
Identical code duplication
Similar code duplication
Code smells
Linters
RuboCopRuby static code analyzer and formatter
ReekCode smell detector for Ruby
StandardRBRuby style guide, linter, and formatter
BrakemanStatic analysis security vulnerability scanner
Auto-formatters
RuboCopIncludes formatting capabilities
StandardRBZero-config Ruby formatter
Custom checks
ast-grep
Semgrep
ripgrep
Security scanning
BrakemanAppSec (SAST) for Ruby on Rails applications
GitleaksSecrets scanning
OSV-ScannerDependency scanning (SCA)
SemgrepAppSec (SAST)
TrivyDependency scanning (SCA)
TruffleHogSecrets 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.