rbcop 0.1.2 → 0.1.3
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 +4 -4
- data/README.md +20 -10
- data/libexec/aarch64-apple-darwin/rbcop +0 -0
- data/libexec/aarch64-unknown-linux-gnu/rbcop +0 -0
- data/libexec/aarch64-unknown-linux-musl/rbcop +0 -0
- data/libexec/x86_64-apple-darwin/rbcop +0 -0
- data/libexec/x86_64-unknown-linux-gnu/rbcop +0 -0
- data/libexec/x86_64-unknown-linux-musl/rbcop +0 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 34701791dafa42adb8d0c264d091285bcef7169a68a2c6d294577df0390a0d34
|
|
4
|
+
data.tar.gz: 60afd08defd3566db0ca6917dcd0da71874cbef92d9f81a3c49da71ff3d241aa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 68ae1b4e65e5d6df1456469d7fcf7f99c13e38bb17461c62b70908d0b5377f337dcf1cc55c73017a26405c839e4e84f89f002998b99f8acc49fbc4f430c38bd2
|
|
7
|
+
data.tar.gz: e16c71efa1ec9d1909a48051a1d0a4e9b2c937c7f8c8eaa4b0bbffe5fec54be49a7ca0bf2c8a7cba3b84dc8d42bd7b1f809c57ac7e7a15092240a01641f2a92d
|
data/README.md
CHANGED
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
A reimplementation of [RuboCop](https://github.com/rubocop/rubocop) 1.91.0 in Rust, built on [Prism](https://github.com/ruby/prism) (`ruby-prism` crate).
|
|
4
4
|
|
|
5
|
-
The target is byte-identical output: same offenses, ranges, messages, `[Correctable]` flags, autocorrections, formatter output and exit status as RuboCop 1.91.0 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
|
|
5
|
+
The target is byte-identical output: same offenses, ranges, messages, `[Correctable]` flags, autocorrections, formatter output and exit status as RuboCop 1.91.0 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)).
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
- 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
10
|
- GitHub Actions: `uses: costajohnt/rbcop@v<version>` downloads and caches the release binary.
|
|
11
|
-
- Homebrew
|
|
11
|
+
- Homebrew: `brew install costajohnt/tap/rbcop`. Release archives with each release.
|
|
12
12
|
|
|
13
13
|
[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
14
|
|
|
15
15
|
## Build
|
|
16
16
|
|
|
17
17
|
```sh
|
|
18
|
-
cargo build --release # needs Rust 1.
|
|
18
|
+
cargo build --release # needs Rust 1.89 or newer
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
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`.
|
|
@@ -31,24 +31,34 @@ rbcop -A [paths...] # all autocorrections
|
|
|
31
31
|
rbcop -f json -o report.json
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
All builtin formatters
|
|
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`.
|
|
35
35
|
|
|
36
|
-
|
|
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.
|
|
37
37
|
|
|
38
38
|
## Plugins and custom cops
|
|
39
39
|
|
|
40
|
-
rbcop reads plugin configuration (`plugins:` and `require:` gems contribute their `config/default.yml`),
|
|
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.
|
|
41
|
+
|
|
42
|
+
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
|
+
|
|
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.
|
|
45
|
+
|
|
46
|
+
With no RuboCop found, or with `RBCOP_FALLBACK=0`, rbcop skips those cops and says so on stderr instead of skipping them silently:
|
|
41
47
|
|
|
42
48
|
```
|
|
43
49
|
rbcop: not running 45 cops it does not implement (Sorbet: 41, ThreadSafety: 4); set RBCOP_FALLBACK=1 to run them with RuboCop
|
|
50
|
+
rbcop: RuboCop runs them when one is found: add the rubocop gem to the bundle, put rubocop on PATH, or set RBCOP_RUBOCOP
|
|
44
51
|
```
|
|
45
52
|
|
|
46
|
-
Cops defined by Ruby code the config requires (`require: ./lib/cops/my_cop.rb`, or a plugin gem rbcop could not load) are named
|
|
53
|
+
(the second line only when none was found). Cops defined by Ruby code the config requires (`require: ./lib/cops/my_cop.rb`, or a plugin gem rbcop could not load) are named as "cops from Ruby code the config requires", since rbcop cannot know their names. A plugin that defines no cops but works through Ruby code (rubocop-erb's ERB extraction) is named as "the Ruby code of plugin rubocop-erb": rbcop runs no cops on the files its `AllCops: Include` brings in (the `.erb` views), and with the fallback RuboCop runs every cop on them. `RBCOP_FALLBACK=1` runs the fallback with `rubocop` even when none was found.
|
|
54
|
+
|
|
55
|
+
`-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).
|
|
47
56
|
|
|
48
|
-
|
|
57
|
+
Limits of the fallback:
|
|
49
58
|
|
|
50
59
|
- 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.
|
|
51
|
-
- `--stdin` does not use the fallback (the notice is printed instead).
|
|
60
|
+
- `--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).
|
|
61
|
+
- 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.
|
|
52
62
|
- `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).
|
|
53
63
|
- The `offenses` formatter does not mark plugin cops `[Safe Correctable]`, and `--display-only-safe-correctable` leaves them out.
|
|
54
64
|
|
|
@@ -96,7 +106,7 @@ RBCOP_CORPUS=<corpus dir> RBCOP_ORACLE=<oracle dir> scripts/verify.sh # the ab
|
|
|
96
106
|
|
|
97
107
|
`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.91.0 on `PATH` (with rbenv: `RBENV_VERSION=4.0.6`). Each script's header documents its arguments and environment.
|
|
98
108
|
|
|
99
|
-
[docs/porting-cops.md](docs/porting-cops.md) describes how a cop is ported and checked, including how the corpora and oracles are laid out. [docs/rubocop-config-semantics.md](docs/rubocop-config-semantics.md) describes the configuration rules `src/config/` follows.
|
|
109
|
+
[docs/porting-cops.md](docs/porting-cops.md) describes how a cop is ported and checked, including how the corpora and oracles are laid out. [docs/rubocop-config-semantics.md](docs/rubocop-config-semantics.md) describes the configuration rules `src/config/` follows. [docs/upgrading-rubocop.md](docs/upgrading-rubocop.md) is the process for moving to a new RuboCop release.
|
|
100
110
|
|
|
101
111
|
## License and credits
|
|
102
112
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|