Skip to main content

drep/languages/definitions/
ruby.rs

1//! Ruby: RuboCop over `.rb` and the extensionless `Gemfile`/`Rakefile`.
2
3use crate::languages::spec::{
4    DEFAULT_TOOL_TIMEOUT_SECS, DiagnosticsStream, LanguageSupport, OutputFormat, ToolSpec,
5};
6
7/// Ruby deterministic checker.
8///
9/// `--force-exclusion` makes RuboCop honor a repo's `Exclude` lists for
10/// explicitly-named files; without it, being handed a path on the command
11/// line overrides the config's own exclusions and reports files the project
12/// deliberately does not lint.
13pub static RUBOCOP: ToolSpec = ToolSpec {
14    name: "rubocop",
15    command: &["rubocop", "--format", "json", "--force-exclusion"],
16    local_paths: &["bin/rubocop"],
17    config_files: &[".rubocop.yml"],
18    config_flag: None,
19    output_format: OutputFormat::Rubocop,
20    diagnostics_stream: DiagnosticsStream::Stdout,
21    timeout_secs: DEFAULT_TOOL_TIMEOUT_SECS,
22    timeout_context: None,
23    establishes_compilation: false,
24    serial_in_repository: false,
25    accepts_files: true,
26};
27
28/// Ruby language entry.
29///
30/// `Gemfile` and `Rakefile` carry no extension, so `filenames` claims them:
31/// a dependency change in a Gemfile is exactly the kind of change worth a
32/// deterministic read, and an extension-only registry drops them.
33pub static RUBY: LanguageSupport = LanguageSupport {
34    name: "ruby",
35    display_name: "Ruby",
36    extensions: &[".rb", ".rake", ".gemspec"],
37    filenames: &["Gemfile", "Rakefile"],
38    filename_prefixes: &[],
39    tools: &[&RUBOCOP],
40    conventions: &[
41        "Monkey patches and reopenings of core classes",
42        "nil flowing where the code assumes a value",
43        "Mutable defaults shared across calls",
44        "Exceptions swallowed by a rescue that only logs",
45        "Blocks whose break/next semantics skip cleanup",
46    ],
47    vendored_dirs: &[".bundle"],
48};
49
50/// The family's entries in registration order. See `ALL_LANGUAGES`.
51pub(crate) static FAMILY: &[&LanguageSupport] = &[&RUBY];