> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qlty.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Ruby Language Support

## Summary

<table className="pretty-table">
  <thead>
    <tr>
      <th style={{ width: "35%" }}>Feature</th>
      <th style={{ width: "20%" }}>Status</th>
      <th style={{ width: "45%" }}>Notes</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>[Maintainability](/cloud/maintainability/metrics)</td>
      <td>✔</td>
      <td>Complexity, duplication, code smells</td>
    </tr>

    <tr>
      <td>[Linting](/linting)</td>
      <td>✔</td>

      <td />
    </tr>

    <tr>
      <td>[Auto-formatting](/auto-formatting)</td>
      <td>✔</td>

      <td />
    </tr>

    <tr>
      <td>[Custom checks](/custom-checks)</td>
      <td>✔</td>

      <td />
    </tr>

    <tr>
      <td>[Security scanning](/cloud/security/framework)</td>
      <td>✔</td>
      <td>AppSec, dependencies, and secrets</td>
    </tr>

    <tr>
      <td>[Code metrics](/cloud/maintainability/metrics)</td>
      <td>✔</td>

      <td />
    </tr>

    <tr>
      <td>[Code coverage](/coverage)</td>
      <td>✔</td>

      <td />
    </tr>
  </tbody>
</table>

## Details

<table className="pretty-table">
  <tbody>
    <tr className="divider-row">
      <td style={{ width: "35%" }}>Maintainability</td>

      <td style={{ width: "20%" }} />

      <td style={{ width: "45%" }} />
    </tr>

    <tr>
      <td>[Complexity](/complexity)</td>
      <td>✔</td>
      <td>Aka cognitive complexity</td>
    </tr>

    <tr>
      <td>[Cyclomatic complexity](/complexity#difference-from-cyclomatic-complexity)</td>
      <td>✔</td>

      <td />
    </tr>

    <tr>
      <td>[Identical code duplication](/duplication)</td>
      <td>✔</td>

      <td />
    </tr>

    <tr>
      <td>[Similar code duplication](/duplication)</td>
      <td>✔</td>

      <td />
    </tr>

    <tr>
      <td>[Code smells](/code-smells)</td>
      <td>✔</td>

      <td />
    </tr>

    <tr className="divider-row">
      <td>Linters</td>

      <td />

      <td />
    </tr>

    <tr>
      <td>[RuboCop](https://github.com/rubocop/rubocop)</td>
      <td>✔</td>
      <td>Ruby static code analyzer and formatter</td>
    </tr>

    <tr>
      <td>[Reek](https://github.com/troessner/reek)</td>
      <td>✔</td>
      <td>Code smell detector for Ruby</td>
    </tr>

    <tr>
      <td>[StandardRB](https://github.com/standardrb/standard)</td>
      <td>✔</td>
      <td>Ruby style guide, linter, and formatter</td>
    </tr>

    <tr>
      <td>[Brakeman](https://brakemanscanner.org/)</td>
      <td>✔</td>
      <td>Static analysis security vulnerability scanner</td>
    </tr>

    <tr className="divider-row">
      <td>Auto-formatters</td>

      <td />

      <td />
    </tr>

    <tr>
      <td>[RuboCop](https://github.com/rubocop/rubocop)</td>
      <td>✔</td>
      <td>Includes formatting capabilities</td>
    </tr>

    <tr>
      <td>[StandardRB](https://github.com/standardrb/standard)</td>
      <td>✔</td>
      <td>Zero-config Ruby formatter</td>
    </tr>

    <tr className="divider-row">
      <td>Custom checks</td>

      <td />

      <td />
    </tr>

    <tr>
      <td>[ast-grep](https://github.com/ast-grep/ast-grep)</td>
      <td>✔</td>

      <td />
    </tr>

    <tr>
      <td>[Semgrep](https://semgrep.dev)</td>
      <td>✔</td>

      <td />
    </tr>

    <tr>
      <td>[ripgrep](https://github.com/BurntSushi/ripgrep)</td>
      <td>✔</td>

      <td />
    </tr>

    <tr className="divider-row">
      <td>Security scanning</td>

      <td />

      <td />
    </tr>

    <tr>
      <td>[Brakeman](https://brakemanscanner.org/)</td>
      <td>✔</td>
      <td>AppSec (SAST) for Ruby on Rails applications</td>
    </tr>

    <tr>
      <td>[Gitleaks](https://gitleaks.io/)</td>
      <td>✔</td>
      <td>Secrets scanning</td>
    </tr>

    <tr>
      <td>[OSV-Scanner](https://google.github.io/osv-scanner/)</td>
      <td>✔</td>
      <td>Dependency scanning (SCA)</td>
    </tr>

    <tr>
      <td>[Semgrep](https://semgrep.dev)</td>
      <td>✔</td>
      <td>AppSec (SAST)</td>
    </tr>

    <tr>
      <td>[Trivy](https://trivy.dev)</td>
      <td>✔</td>
      <td>Dependency scanning (SCA)</td>
    </tr>

    <tr>
      <td>[TruffleHog](https://trufflesecurity.com/trufflehog)</td>
      <td>✔</td>
      <td>Secrets scanning</td>
    </tr>

    <tr className="divider-row">
      <td>Code coverage</td>

      <td />

      <td />
    </tr>

    <tr>
      <td>[SimpleCov](https://github.com/simplecov-ruby/simplecov)</td>
      <td>✔</td>

      <td />
    </tr>

    <tr>
      <td>Cobertura coverage format</td>
      <td>✔</td>

      <td />
    </tr>

    <tr>
      <td>JSON coverage format</td>
      <td>✔</td>

      <td />
    </tr>
  </tbody>
</table>

## 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](https://github.com/qltysh/example-ruby).

### SimpleCov configuration

To instrument test coverage with SimpleCov:

1. Install SimpleCov:

```sh lines theme={"system"}
gem install simplecov
```

2. Configure SimpleCov to generate JSON reports:

```ruby lines theme={"system"}
require 'simplecov'
require 'simplecov_json_formatter'
SimpleCov.start do
    formatter SimpleCov::Formatter::JSONFormatter
    add_filter '/spec/'
end
```

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

```ruby lines theme={"system"}
SimpleCov.start do
    formatter SimpleCov::Formatter::MultiFormatter.new([
      SimpleCov::Formatter::JSONFormatter,
      SimpleCov::Formatter::HTMLFormatter
    ])
    add_filter '/spec/'
end
```

3. Publish SimpleCov's JSON coverage reports using `qlty coverage publish`:

```sh lines theme={"system"}
qlty coverage publish coverage/coverage.json
```

For GitHub Actions users, you can use our [example workflow](https://github.com/qltysh/example-ruby/blob/main/.github/workflows/main.yml).

## 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.
