rbcop 0.1.4-x86_64-linux-gnu → 0.2.0-x86_64-linux-gnu

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +22 -13
  3. data/libexec/rbcop +0 -0
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a885f2231591d03d281b0b6b2551138bf3dc37cba8628f4177c9ede774116a76
4
- data.tar.gz: 21e97b57a1f6a78c4e200c85f31c1575a1c64367c04b04f263d262399af66b4e
3
+ metadata.gz: 074d8948bbc3642f2c9d993e3bbd1faf4e7f21f8e0f79487f056762d9f5a001b
4
+ data.tar.gz: 5d165c9927808ec9416dae118d49d4e51ee91f2d41d6a343c585f5eda1b0faee
5
5
  SHA512:
6
- metadata.gz: 1102f1b7e5f0748ee676b6758e2802e1b2f7f577e254cd6b09186f9d2b76975d20015c2a6252e7c292197573d3f87e303b7b12a5ca25fe71a9adddaa82b2102f
7
- data.tar.gz: 3b6ab7e08b9695eb0fbe9453bba43a87a18c2706bca65b9b8a1e969f8cc4d25f8d01edff272c06af438a888aee2665f8d4094a8bca48770458df5294d713f5a5
6
+ metadata.gz: c1cbb80a79aed8b0deded118ea339836c51d38d24d88e6d8a16e64251a1b9abacce2bee5f757c36e1cdc2e3e1300dd346bef402ef27204c10d7b8c6a047d8d07
7
+ data.tar.gz: da01959c3fed7f6de6097d5e3f3821be0bc25f67af460be50758025f3802d708cd55a2d7074ad7cb53b1f8545740a8b9a0227f94c23a78df14a96d54c3249984
data/README.md CHANGED
@@ -1,28 +1,36 @@
1
1
  # rbcop
2
2
 
3
+ <p align="center"><img src="docs/rbcop.jpg" alt="rbcop logo: a rust-colored shield with a ruby" width="480"></p>
4
+
5
+ Drop-in replacement for RuboCop 1.92.2. Same config, same command line, same output, [about 14x faster](#speed) than `rubocop --parallel` in CI.
6
+
7
+ `gem "rbcop", require: false`, then `bundle exec rbcop`.
8
+
3
9
  A reimplementation of [RuboCop](https://github.com/rubocop/rubocop) 1.92.2 in Rust, built on [Prism](https://github.com/ruby/prism) (`ruby-prism` crate).
4
10
 
5
- The target is byte-identical output: same offenses, ranges, messages, `[Correctable]` flags, autocorrections, formatter output and exit status as RuboCop 1.92.2 for the same files and configuration. All 613 cops in RuboCop's `config/default.yml` are implemented. rubocop-performance, rubocop-rails, rubocop-minitest, rubocop-rspec, rubocop-rspec_rails, rubocop-factory_bot and rubocop-capybara run natively ([docs/plugins.md](docs/plugins.md)). Other plugins (rubocop-sorbet and so on) and custom cops do not; rbcop hands them to RuboCop when one is installed, and otherwise says which cops it skips (see [Plugins and custom cops](#plugins-and-custom-cops)).
11
+ The target is byte-identical output: same offenses, ranges, messages, `[Correctable]` flags, autocorrections, formatter output and exit status as RuboCop 1.92.2 for the same files and configuration. All 613 cops in RuboCop's `config/default.yml` are implemented. rubocop-performance, rubocop-rails, rubocop-minitest, rubocop-rspec, rubocop-rspec_rails, rubocop-factory_bot, rubocop-capybara, rubocop-thread_safety and rubocop-sorbet run natively ([docs/plugins.md](docs/plugins.md)). Other plugins (rubocop-i18n and so on) and custom cops do not; rbcop hands them to RuboCop when one is installed, and otherwise says which cops it skips (see [Plugins and custom cops](#plugins-and-custom-cops)).
6
12
 
7
13
  ## Install
8
14
 
9
15
  - Gemfile: `gem "rbcop", require: false`, then `bundle exec rbcop` where you ran `bundle exec rubocop`. The gem carries a prebuilt binary (macOS arm64/x86_64, Linux x86_64/aarch64 glibc and musl); no Rust toolchain is needed.
10
- - GitHub Actions: `uses: costajohnt/rbcop@v<version>` downloads and caches the release binary.
16
+ - GitHub Actions: `uses: costajohnt/rbcop@v<version>` downloads and caches the release binary, and keeps rbcop's result cache between runs ([inputs](docs/migration.md#github-actions)).
11
17
  - Homebrew: `brew install costajohnt/tap/rbcop`. Release archives with each release.
12
18
 
19
+ The Linux glibc binaries (`*-linux-gnu` archives and gems) need glibc 2.17 or newer (CentOS 7, Ubuntu 14.04, Debian 8 and later); the musl ones are statically linked. Each release lists every file's SHA-256 in `SHA256SUMS` (also committed as `packaging/checksums/<version>.sha256`), and releases after 0.1.4 carry a GitHub build-provenance attestation for each file: `gh attestation verify rbcop-<version>-<target>.tar.gz -R costajohnt/rbcop` checks that it was built by this repository's release workflow. rbcop is 0.x: every published release is meant to be pinned, and from the release after 0.1.4 on, patch releases fix bugs only ([docs/releasing.md](docs/releasing.md#versions)).
20
+
13
21
  [docs/migration.md](docs/migration.md) covers switching a project from RuboCop: Gemfile, binstubs, CI, editors and plugins. `docs/releasing.md` describes how releases are built.
14
22
 
15
23
  ## Build
16
24
 
17
25
  ```sh
18
- cargo build --release # needs Rust 1.89 or newer
26
+ cargo build --release # needs Rust 1.95 or newer and libclang (e.g. libclang-dev), for bindgen
19
27
  ```
20
28
 
21
29
  The binary is `target/release/rbcop`. The crate is not published to crates.io: it builds against a patched copy of `ruby-prism` in `vendor/ruby-prism`.
22
30
 
23
31
  ## Usage
24
32
 
25
- The command line is RuboCop's. Options, `.rubocop.yml` lookup and inheritance, `RUBOCOP_OPTS`, `.rubocop` argument files, inline `# rubocop:disable` / `enable` / `todo` comments, output and exit status follow RuboCop 1.91.0.
33
+ The command line is RuboCop's. Options, `.rubocop.yml` lookup and inheritance, `RUBOCOP_OPTS`, `.rubocop` argument files, inline `# rubocop:disable` / `enable` / `todo` comments, output and exit status follow RuboCop 1.92.2.
26
34
 
27
35
  ```sh
28
36
  rbcop [options] [paths...]
@@ -31,22 +39,22 @@ rbcop -A [paths...] # all autocorrections
31
39
  rbcop -f json -o report.json
32
40
  ```
33
41
 
34
- All builtin formatters are supported, as are the display options, `--fail-level`, `--stdin` (with `-a`/`-A` it prints the corrected source after the report), `-L`, `--show-cops`, `-v` and `-V`.
42
+ All builtin formatters are supported (`-f json` is documented, with the exit codes and a compatibility policy, in [docs/json-output.md](docs/json-output.md)), as are the display options, `--fail-level`, `--stdin` (with `-a`/`-A` it prints the corrected source after the report), `-L`, `--show-cops`, `-v` and `-V`.
35
43
 
36
- `--auto-gen-config` (with its options), `--regenerate-todo`, `--disable-uncorrectable` and `--report-unused-todo-entries` are supported. The server options are accepted and run in process (no server is started), and `--lsp` runs RuboCop's language server. Not supported: `--changed` and the MCP mode. Plugin and custom cops rbcop does not implement, `-r`/`--plugin` and custom formatter classes run with RuboCop when one is installed (see [Plugins and custom cops](#plugins-and-custom-cops)). ERB in config files is rendered by running `ruby`, as RuboCop renders it, and remote `inherit_from` URLs are fetched as RuboCop fetches them. The result cache (`--cache`, `--cache-root`, `AllCops: UseCache`) works as RuboCop's, in its own `rbcop_cache` directory. [docs/known-gaps.md](docs/known-gaps.md) lists these and every other known difference, including a few deliberate ones (for example, `-o` pointing at a file being inspected is refused). `-a`/`-A` do not write files that resolve (through symlinks) outside the working directory and the paths given on the command line; those are reported uncorrected with a warning.
44
+ `--auto-gen-config` (with its options), `--regenerate-todo`, `--disable-uncorrectable` and `--report-unused-todo-entries` are supported. The server options are accepted and run in process (no server is started), `--lsp` runs RuboCop's language server, `--mcp` its MCP server, and `--changed` limits the run to files git reports as changed. Plugin and custom cops rbcop does not implement, `-r`/`--plugin` and custom formatter classes run with RuboCop when one is installed (see [Plugins and custom cops](#plugins-and-custom-cops)). ERB in config files is rendered by running `ruby`, as RuboCop renders it, and remote `inherit_from` URLs are fetched as RuboCop fetches them. The result cache (`--cache`, `--cache-root`, `AllCops: UseCache`) works as RuboCop's, in its own `rbcop_cache` directory. [docs/known-gaps.md](docs/known-gaps.md) lists these and every other known difference, including a few deliberate ones (for example, `-o` pointing at a file being inspected is refused). `-a`/`-A` do not write files that resolve (through symlinks) outside the working directory and the paths given on the command line; those are reported uncorrected with a warning.
37
45
 
38
46
  ## Plugins and custom cops
39
47
 
40
- rbcop reads plugin configuration (`plugins:` and `require:` gems contribute their `config/default.yml`), and runs natively the cops it implements: RuboCop's own and those of the plugins in [docs/plugins.md](docs/plugins.md) (rubocop-performance, rubocop-rails, rubocop-minitest, rubocop-rspec, rubocop-rspec_rails, rubocop-factory_bot, rubocop-capybara). Cops it cannot run (other plugins such as rubocop-sorbet, custom cops from `require: ./lib/cops/my_cop.rb`) go to RuboCop: the fallback.
48
+ rbcop reads plugin configuration (`plugins:` and `require:` gems contribute their `config/default.yml`), and runs natively the cops it implements: RuboCop's own and those of the plugins in [docs/plugins.md](docs/plugins.md) (rubocop-performance, rubocop-rails, rubocop-minitest, rubocop-rspec, rubocop-rspec_rails, rubocop-factory_bot, rubocop-capybara, rubocop-thread_safety, rubocop-sorbet). Cops it cannot run (other plugins such as rubocop-i18n, custom cops from `require: ./lib/cops/my_cop.rb`) go to RuboCop: the fallback.
41
49
 
42
50
  The fallback is on by default and needs a RuboCop. rbcop uses `RBCOP_RUBOCOP` when set (for example `RBCOP_RUBOCOP="bin/rubocop"`), else `bundle exec rubocop` when the project's `Gemfile.lock` has the rubocop gem, else `rubocop` on `PATH`. It runs RuboCop once more for exactly the cops rbcop cannot run (`--except` every cop rbcop implements) on the same files with the same configuration and options, and merges its offenses into its own report, so formatters, `--fail-level` and the exit status see one run. The saving is smaller, since RuboCop still parses every file, but core cops no longer run in Ruby. A project that needs no fallback never starts RuboCop. If RuboCop fails to run (say `bundle exec` outside an installed bundle), rbcop exits 2 with its error.
43
51
 
44
- RuboCop loads the project's Ruby (its Gemfile, plugins, cop files), as it would if you ran it, so rbcop says so first on stderr: `rbcop: running bundle exec rubocop for 4 cops it does not implement (ThreadSafety: 4); set RBCOP_FALLBACK=0 to never run Ruby` (stdout is unchanged; no line under `RBCOP_FALLBACK=1`, which asked for it). Under `--lsp`, `--mcp`, the server options, `--editor-mode` or `--stdin` (an editor opening a project), wherever they come from (command line, `.rubocop`, `RUBOCOP_OPTS`), the fallback and the hand-off run only with `RBCOP_FALLBACK=1`. `RBCOP_FALLBACK=0` turns it off: no Ruby is started for it at all. rbcop also runs `ruby` to render ERB in config files and to fetch remote `inherit_from` URLs, only when the config has them; [docs/known-gaps.md](docs/known-gaps.md) ("Security: when rbcop runs Ruby") lists every case and how to avoid each.
52
+ RuboCop loads the project's Ruby (its Gemfile, plugins, cop files), as it would if you ran it, so rbcop says so first on stderr: `rbcop: running bundle exec rubocop for 6 cops it does not implement (I18n/GetText: 4, I18n/RailsI18n: 2); set RBCOP_FALLBACK=0 to skip RuboCop` (stdout is unchanged; no line under `RBCOP_FALLBACK=1`, which asked for it). Under `--lsp`, `--mcp`, the server options, `--editor-mode` or `--stdin` (an editor opening a project), wherever they come from (command line, `.rubocop`, `RUBOCOP_OPTS`), the fallback and the hand-off run only with `RBCOP_FALLBACK=1`. `RBCOP_FALLBACK=0` turns it off: no Ruby is started for it at all. rbcop also runs `ruby` to render ERB in config files and to fetch remote `inherit_from` URLs, only when the config has them; [docs/known-gaps.md](docs/known-gaps.md) ("Security: when rbcop runs Ruby") lists every case and how to avoid each.
45
53
 
46
54
  With no RuboCop found, or with `RBCOP_FALLBACK=0`, rbcop skips those cops and says so on stderr instead of skipping them silently:
47
55
 
48
56
  ```
49
- rbcop: not running 45 cops it does not implement (Sorbet: 41, ThreadSafety: 4); set RBCOP_FALLBACK=1 to run them with RuboCop
57
+ rbcop: not running 6 cops it does not implement (I18n/GetText: 4, I18n/RailsI18n: 2); set RBCOP_FALLBACK=1 to run them with RuboCop
50
58
  rbcop: RuboCop runs them when one is found: add the rubocop gem to the bundle, put rubocop on PATH, or set RBCOP_RUBOCOP
51
59
  ```
52
60
 
@@ -54,6 +62,8 @@ rbcop: RuboCop runs them when one is found: add the rubocop gem to the bundle, p
54
62
 
55
63
  `-r`/`--require`, `--plugin` and custom formatter classes (`-r ./my_formatter.rb --format MyFormatter`) load Ruby code that can change anything, so rbcop hands the whole run to the same RuboCop with the same arguments: the output is RuboCop's, with no speedup. With no RuboCop found, or `RBCOP_FALLBACK=0`, rbcop refuses them (exit 2).
56
64
 
65
+ `--no-ruby` (or `RBCOP_NO_RUBY=1`), rbcop's own option, guarantees rbcop never starts `ruby`, `rubocop` or `bundle`, whatever `RBCOP_FALLBACK` says: for a pinned binary in an environment without Ruby. The cops the fallback would run are skipped and reported (on stderr, and as `skipped_cops` and `skipped_ruby_code` in `-f json`); anything else that needs Ruby (ERB in config files, remote `inherit_from`, `inherit_gem`, `AllCops/ProjectIndexIncludesGems`, `-r`, `--plugin`, custom formatter classes) fails with exit 2 and a `rbcop: --no-ruby: ...` error. [docs/known-gaps.md](docs/known-gaps.md) ("Security: when rbcop runs Ruby") has the details.
66
+
57
67
  Limits of the fallback:
58
68
 
59
69
  - With `-a`/`-A`, RuboCop corrects its cops first, then rbcop corrects the result; the two never iterate together, so a correction that triggers the other side's cop is fixed on the next run.
@@ -98,10 +108,9 @@ rbcop with a warm result cache (an unchanged tree, as RuboCop's cache serves it)
98
108
  ## Gates
99
109
 
100
110
  ```sh
101
- cargo fmt --check
102
- cargo clippy --release --all-targets -- -D warnings
103
- cargo test --release
104
- RBCOP_CORPUS=<corpus dir> RBCOP_ORACLE=<oracle dir> scripts/verify.sh # the above plus check-cops.sh all
111
+ scripts/ci.sh # cargo fmt --check, clippy -D warnings, cargo build and cargo test (all --release --locked)
112
+ RBCOP_CORPUS=<corpus dir> RBCOP_ORACLE=<oracle dir> RUBOCOP=<rubocop 1.92.2> scripts/ci.sh
113
+ # the above plus check-cops.sh all, check-cold.sh and check-plugins.sh
105
114
  ```
106
115
 
107
116
  `cargo test` replays recorded RuboCop output: every cop's RuboCop spec examples with their config variants, offenses and `-A` results (`tests/spec_corpus`, recorded by `scripts/record-spec-corpus.sh`), config scenarios (`tests/scenarios`), formatter and CLI goldens (`tests/formatters`), `--show-cops` (`tests/show_cops`) and autocorrect cases (`tests/autocorrect`). The scripts that record them (`scripts/record-spec-corpus.sh`, `scripts/scenarios.sh`, `scripts/formatters.sh`, `scripts/show-cops.sh`, `tests/autocorrect/record.sh`) and the oracle, autocorrect and cold-corpus gates need RuboCop 1.92.2 as `$RUBOCOP` or on `PATH`. Each script's header documents its arguments and environment.
data/libexec/rbcop CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbcop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: x86_64-linux-gnu
6
6
  authors:
7
7
  - John Costa