rbcop 0.2.0 → 0.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 347b67e5684d45debf0c5fb8e9a60d4f79ca2bf775f0130304b8a757f7da7f9e
4
- data.tar.gz: ef9adf2d657ce9bba491ba02d3bacfa885457a1e67cc19ed28fd967691b6da36
3
+ metadata.gz: ab3b43d708de5ba886762114590abe90800a0569205a44bb317129a423bb4e01
4
+ data.tar.gz: 8f58f2023ead7f63b09f4f9970d159da9c1342d7d5205242c7828b8ec259f75d
5
5
  SHA512:
6
- metadata.gz: fc3d3307367c66822a386e5804a30fbd01278d5bc438993304a007d9594059488b66e40073fb89120dd84e4c93806eb901e9426ff6a1e4dbe396f288ffc221b8
7
- data.tar.gz: 037c26e604b92e8e4c8631356af103e5fcd65b1511877ec7e59a2cddd5c67996d493b83f870ba18584735d42df1920220f32dbf9e011fc92cfdcd763be7107ec
6
+ metadata.gz: 0e8fe07ee91ff416b293ac73c0ea2f6f36ef02b0e6964360040d05b45c219b69b579da088e87951ab358a8ac3daa09d9a96a7f999e251aa664d0aaf79760a4b4
7
+ data.tar.gz: 4d30c72101a63a419f4db7badc405b74878848b3181b8780f81f3452a34251bada10b544fe5e9fa644029f531896acb578b2f90edf68d4d831cc1b4f855be144
data/README.md CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  <p align="center"><img src="docs/rbcop.jpg" alt="rbcop logo: a rust-colored shield with a ruby" width="480"></p>
4
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.
5
+ Drop-in replacement for RuboCop 1.92.2. Same config, same command line, same output, [2.4x to 25x faster](#speed) than `rubocop --parallel` in CI (20x to 25x when rbcop implements every enabled cop).
6
6
 
7
7
  `gem "rbcop", require: false`, then `bundle exec rbcop`.
8
8
 
9
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).
10
10
 
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)).
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, rubocop-sorbet, rubocop-packaging and rubocop-rake 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)).
12
12
 
13
13
  ## Install
14
14
 
@@ -45,9 +45,9 @@ All builtin formatters are supported (`-f json` is documented, with the exit cod
45
45
 
46
46
  ## Plugins and custom cops
47
47
 
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.
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, rubocop-packaging, rubocop-rake). Cops it cannot run (other plugins such as rubocop-i18n, custom cops from `require: ./lib/cops/my_cop.rb`) go to RuboCop: the fallback.
49
49
 
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.
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) 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. RuboCop parses only the files one of those cops may inspect (enabled there, its `Include`/`Exclude`, or an enable directive). With the result cache on, each file's fallback offenses are cached too (keyed also on the RuboCop command and the contents of the Ruby files RuboCop has loaded, as RuboCop's own cache is), so on a warm run RuboCop skips the unchanged files (it still starts: it loads the required code, and prints what that prints, on every run). The saving is smaller than without the fallback, since RuboCop still parses the files it gets, 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.
51
51
 
52
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.
53
53
 
@@ -66,8 +66,8 @@ rbcop: RuboCop runs them when one is found: add the rubocop gem to the bundle, p
66
66
 
67
67
  Limits of the fallback:
68
68
 
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.
70
- - `--stdin` does not use the fallback (the notice is printed instead), nor does `--diff` (the RuboCop child corrects by writing files; with `RBCOP_FALLBACK=1` the combination is refused).
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, and a formatter that quotes source lines (the default one) quotes rbcop's own offenses from the source RuboCop corrected.
70
+ - `--diff` does not use the fallback (the RuboCop child corrects by writing files; with `RBCOP_FALLBACK=1` the combination is refused). `--stdin` uses it only with `RBCOP_FALLBACK=1` (above): the child reads the same source and, with `-a`/`-A`, corrects it before rbcop does.
71
71
  - What a fallback cop prints itself (rubocop-require_tools' `Note: Could not load` lines) comes before rbcop's report instead of interleaved with RuboCop's.
72
72
  - `Lint/RedundantCopDisableDirective` never reports a directive naming a plugin or custom cop rbcop does not implement (nor a `disable all` while one is loaded), with or without the fallback; RuboCop reports those that turn out redundant (docs/known-gaps.md).
73
73
  - The `offenses` formatter does not mark plugin cops `[Safe Correctable]`, and `--display-only-safe-correctable` leaves them out.
@@ -78,30 +78,32 @@ Limits of the fallback:
78
78
 
79
79
  | Corpus | Offenses (RuboCop = rbcop) | Differences |
80
80
  |---|---:|---:|
81
- | specs (RuboCop's spec examples) | 78,303 | 0 |
82
- | rails | 371,334 | 0 |
83
- | discourse | 905,462 | 0 |
84
- | rubocop-src | 34,296 | 0 |
85
- | jekyll | 15,218 | 0 |
86
- | chef | 170,509 | 0 |
87
- | fastlane | 119,121 | 0 |
88
- | brew | 257,707 | 0 |
89
- | mastodon | 73,899 | 0 |
81
+ | specs (RuboCop's spec examples) | 78,225 | 0 |
82
+ | rails | 371,067 | 0 |
83
+ | discourse | 904,224 | 0 |
84
+ | rubocop-src | 34,217 | 0 |
85
+ | jekyll | 15,205 | 0 |
86
+ | chef | 170,319 | 0 |
87
+ | fastlane | 118,997 | 0 |
88
+ | brew | 257,246 | 0 |
89
+ | mastodon | 73,881 | 0 |
90
+
91
+ Counts are from the gate run on 2026-11-19 at commit 831eea1 against RuboCop 1.92.2.
90
92
 
91
93
  `scripts/check-cold.sh` covers cops that rarely fire on those corpora, using RuboCop's own spec examples with their config variants: 1,443 offenses, 0 differences, and `-A` output identical to a live `rubocop -A` run. `scripts/check-autocorrect.sh` and `scripts/check-autocorrect-all.sh` compare `-a`/`-A` output with RuboCop on corpus files. Files skipped by the gates are listed in `scripts/check-skip.txt`, `scripts/cold-skip.txt` and `scripts/autocorrect-skip.txt`, with the reasons in docs/known-gaps.md.
92
94
 
93
95
  ## Speed
94
96
 
95
- CI-shaped runs (Linux container, 4 vCPUs, each project's own config, RuboCop with an empty result cache, median of 3): rbcop is 10x to 19x faster than `rubocop --parallel`, about 14x on average.
97
+ CI-shaped runs (Linux container, 4 vCPUs, each project's own config, RuboCop 1.92.2 with an empty result cache, median of 3): rbcop is 20x to 25x faster than `rubocop --parallel` where it implements every enabled cop (rails, brew). Where the config enables cops rbcop does not implement, rbcop runs them with RuboCop (on by default, see [Plugins and custom cops](#plugins-and-custom-cops)), and that RuboCop child takes most of the time: 2.4x to 6.4x. With `RBCOP_FALLBACK=0` (those cops skipped) it is 16x to 21x there.
96
98
 
97
- | Codebase | Files | `rubocop --parallel` | rbcop | Speedup |
98
- |---|---:|---:|---:|---:|
99
- | rails | 3,476 | 50.6 s | 2.64 s | 19x |
100
- | discourse | 12,441 | 140.6 s | 10.16 s | 14x |
101
- | mastodon | 3,297 | 61.2 s | 6.10 s | 10x |
102
- | brew | 1,977 | 69.0 s | 4.39 s | 16x |
103
- | solidus | 2,171 | 28.3 s | 2.12 s | 13x |
104
- | fastlane | 1,355 | 30.3 s | 2.02 s | 15x |
99
+ | Codebase | Files | `rubocop --parallel` | rbcop | Speedup | rbcop, `RBCOP_FALLBACK=0` | Speedup |
100
+ |---|---:|---:|---:|---:|---:|---:|
101
+ | rails | 3,476 | 51.2 s | 2.02 s | 25x | | |
102
+ | discourse | 12,441 | 142.4 s | 48.67 s | 2.9x | 6.80 s | 21x |
103
+ | mastodon | 3,297 | 61.8 s | 9.73 s | 6.4x | 3.91 s | 16x |
104
+ | brew | 1,977 | 71.1 s | 3.51 s | 20x | | |
105
+ | solidus | 2,171 | 28.5 s | 9.78 s | 2.9x | 1.53 s | 19x |
106
+ | fastlane | 1,355 | 30.6 s | 12.93 s | 2.4x | 1.57 s | 19x |
105
107
 
106
108
  rbcop with a warm result cache (an unchanged tree, as RuboCop's cache serves it) takes about 3% of the CPU time of an uncached run: 0.9 s of CPU instead of 27 s on rails, 3.0 s instead of 82 s on discourse. Method, 2 vCPU numbers and raw data: [docs/benchmarks.md](docs/benchmarks.md).
107
109
 
Binary file
Binary file
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.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Costa