rbcop 0.1.0-arm64-darwin
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 +7 -0
- data/LICENSE +20 -0
- data/README.md +104 -0
- data/exe/rbcop +21 -0
- data/libexec/rbcop +0 -0
- data/licenses/prism-LICENSE.md +7 -0
- data/licenses/rubocop-LICENSE +20 -0
- metadata +48 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: e17f65105ca4af88b4808a24d84c8800c85bdb79c71d4cedbdb720080d841080
|
|
4
|
+
data.tar.gz: 8d60cae9eff973e8f237b621b2ed51091499e9ec27829abb93b99bc3e4b85c24
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: '08bea324695d2978131b17de21fc483c8faa268c30f2003fe74f80ea54fa09c91b7e5ed21958197d7ad647e9a51d8f392b344590143b9c0604cb8a3eaafd9c59'
|
|
7
|
+
data.tar.gz: 5fb7b4df0e56591d572fba69ef1d0ad3aacdade866a4d6411ccf1bbe02bfda7142bf9e10d302afa1f357234af41164d67730443811d83c74e615dc35156592a8
|
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2026 John Costa
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# rbcop
|
|
2
|
+
|
|
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
|
+
|
|
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 says which cops it skips and can hand them to RuboCop (see [Plugins and custom cops](#plugins-and-custom-cops)).
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
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
|
+
- GitHub Actions: `uses: costajohnt/rbcop@v<version>` downloads and caches the release binary.
|
|
11
|
+
- Homebrew formula and release archives with each release.
|
|
12
|
+
|
|
13
|
+
[docs/migration.md](docs/migration.md) covers switching a project from RuboCop: Gemfile, binstubs, CI, editors and plugins. None of these is published yet (#298); `docs/releasing.md` describes how they are built.
|
|
14
|
+
|
|
15
|
+
## Build
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
cargo build --release # needs Rust 1.88 or newer
|
|
19
|
+
```
|
|
20
|
+
|
|
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`.
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
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.
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
rbcop [options] [paths...]
|
|
29
|
+
rbcop -a [paths...] # safe autocorrect
|
|
30
|
+
rbcop -A [paths...] # all autocorrections
|
|
31
|
+
rbcop -f json -o report.json
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
All builtin formatters except `autogenconf` 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
|
+
|
|
36
|
+
Not supported: `--auto-gen-config`, `--regenerate-todo`, `--disable-uncorrectable`, `--report-unused-todo-entries`, `--display-suppressed`, `--diff`, `--changed`, the server, LSP and MCP modes, `-r`/`--plugin`, `-d`, `--profile`, `--memory`, custom formatter classes, `require:` of local Ruby files, ERB in `.rubocop.yml` and remote `inherit_from` URLs. `--cache` is accepted and has no effect. [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
|
+
|
|
38
|
+
## Plugins and custom cops
|
|
39
|
+
|
|
40
|
+
rbcop reads plugin configuration (`plugins:` and `require:` gems contribute their `config/default.yml`), but it only runs 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). When the configuration enables cops rbcop cannot run, it says so on stderr instead of silently skipping them:
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
rbcop: not running 45 cops it does not implement (Sorbet: 41, ThreadSafety: 4); set RBCOP_FALLBACK=1 to run them with RuboCop
|
|
44
|
+
```
|
|
45
|
+
|
|
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 the same way ("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.
|
|
47
|
+
|
|
48
|
+
With `RBCOP_FALLBACK=1`, rbcop runs RuboCop once more for exactly those cops (`--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. RuboCop must be installed: `rubocop` on `PATH`, or the command in `RBCOP_RUBOCOP` (for example `RBCOP_RUBOCOP="bundle exec rubocop"`). The saving is smaller, since RuboCop still parses every file, but core cops no longer run in Ruby. Limits:
|
|
49
|
+
|
|
50
|
+
- 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).
|
|
52
|
+
- `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
|
+
- The `offenses` formatter does not mark plugin cops `[Safe Correctable]`, and `--display-only-safe-correctable` leaves them out.
|
|
54
|
+
|
|
55
|
+
## Parity
|
|
56
|
+
|
|
57
|
+
`scripts/oracle.sh` records RuboCop's offenses on a corpus with every cop enabled (`config/all-cops.yml`), and `scripts/check-cops.sh` compares rbcop with those recordings. On nine corpora every implemented cop matches with zero differences:
|
|
58
|
+
|
|
59
|
+
| Corpus | Offenses (RuboCop = rbcop) | Differences |
|
|
60
|
+
|---|---:|---:|
|
|
61
|
+
| specs (RuboCop's spec examples) | 78,303 | 0 |
|
|
62
|
+
| rails | 371,334 | 0 |
|
|
63
|
+
| discourse | 905,462 | 0 |
|
|
64
|
+
| rubocop-src | 34,296 | 0 |
|
|
65
|
+
| jekyll | 15,218 | 0 |
|
|
66
|
+
| chef | 170,509 | 0 |
|
|
67
|
+
| fastlane | 119,121 | 0 |
|
|
68
|
+
| brew | 257,707 | 0 |
|
|
69
|
+
| mastodon | 73,899 | 0 |
|
|
70
|
+
|
|
71
|
+
`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.
|
|
72
|
+
|
|
73
|
+
## Speed
|
|
74
|
+
|
|
75
|
+
`scripts/bench.sh` on the rails corpus (3,573 files, 612 cops, `--force-default-config`), Apple M4 with 10 cores, wall time. The machine was running other heavy jobs at the time (load average 12 to 26), so these are rough:
|
|
76
|
+
|
|
77
|
+
| Run | Time |
|
|
78
|
+
|---|---:|
|
|
79
|
+
| rubocop, one process, no cache | 198 s |
|
|
80
|
+
| rubocop --parallel, cold cache | 62 s |
|
|
81
|
+
| rubocop --parallel, warm cache | 6 s |
|
|
82
|
+
| rbcop (no cache; uses every core) | 10 s |
|
|
83
|
+
|
|
84
|
+
rbcop has no result cache, so RuboCop with a warm cache is faster on an unchanged tree.
|
|
85
|
+
|
|
86
|
+
## Gates
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
cargo fmt --check
|
|
90
|
+
cargo clippy --release --all-targets -- -D warnings
|
|
91
|
+
cargo test --release
|
|
92
|
+
RBCOP_CORPUS=<corpus dir> RBCOP_ORACLE=<oracle dir> scripts/verify.sh # the above plus check-cops.sh all
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`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.
|
|
96
|
+
|
|
97
|
+
[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.
|
|
98
|
+
|
|
99
|
+
## License and credits
|
|
100
|
+
|
|
101
|
+
rbcop is released under the MIT license (see `LICENSE`).
|
|
102
|
+
|
|
103
|
+
- [RuboCop](https://github.com/rubocop/rubocop) (MIT, Copyright (c) 2012-26 Bozhidar Batsov): rbcop's cop logic, messages and behaviour are ported from RuboCop's source, and `config/default.yml` and `config/obsoletion.yml` are RuboCop's files, compiled into the binary. RuboCop's license is in `config/LICENSE`.
|
|
104
|
+
- [Prism](https://github.com/ruby/prism) (MIT, Copyright 2022-present Shopify Inc.): the Ruby parser, through the `ruby-prism` crate. A patched copy lives in `vendor/ruby-prism` with its license in `vendor/ruby-prism/LICENSE.md`.
|
data/exe/rbcop
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# Runs the native binary the gem ships: libexec/rbcop in a platform gem, or in the `ruby` platform
|
|
5
|
+
# gem (every binary, for lockfiles that only list `ruby`) libexec/<rust target>/rbcop for this host.
|
|
6
|
+
require 'rbconfig'
|
|
7
|
+
|
|
8
|
+
libexec = File.expand_path('../libexec', __dir__)
|
|
9
|
+
binary = File.join(libexec, 'rbcop')
|
|
10
|
+
unless File.exist?(binary)
|
|
11
|
+
host = RbConfig::CONFIG
|
|
12
|
+
cpu = { 'arm64' => 'aarch64', 'amd64' => 'x86_64', 'x64' => 'x86_64' }.fetch(host['host_cpu'], host['host_cpu'])
|
|
13
|
+
target = case host['host_os']
|
|
14
|
+
when /darwin/ then "#{cpu}-apple-darwin"
|
|
15
|
+
when /linux-musl/ then "#{cpu}-unknown-linux-musl"
|
|
16
|
+
when /linux/ then "#{cpu}-unknown-linux-gnu"
|
|
17
|
+
end
|
|
18
|
+
binary = File.join(libexec, target.to_s, 'rbcop')
|
|
19
|
+
abort "rbcop: this gem has no binary for #{host['host']}" unless target && File.exist?(binary)
|
|
20
|
+
end
|
|
21
|
+
exec([binary, 'rbcop'], *ARGV)
|
data/libexec/rbcop
ADDED
|
Binary file
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2022-present, Shopify Inc.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2012-26 Bozhidar Batsov
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
metadata
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: rbcop
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: arm64-darwin
|
|
6
|
+
authors:
|
|
7
|
+
- John Costa
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: 'A native reimplementation of RuboCop 1.91: same command line, configuration,
|
|
13
|
+
offenses, autocorrections and formatter output, run by the `rbcop` executable.'
|
|
14
|
+
executables:
|
|
15
|
+
- rbcop
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- LICENSE
|
|
20
|
+
- README.md
|
|
21
|
+
- exe/rbcop
|
|
22
|
+
- libexec/rbcop
|
|
23
|
+
- licenses/prism-LICENSE.md
|
|
24
|
+
- licenses/rubocop-LICENSE
|
|
25
|
+
homepage: https://github.com/costajohnt/rbcop
|
|
26
|
+
licenses:
|
|
27
|
+
- MIT
|
|
28
|
+
metadata:
|
|
29
|
+
rubygems_mfa_required: 'true'
|
|
30
|
+
source_code_uri: https://github.com/costajohnt/rbcop
|
|
31
|
+
rdoc_options: []
|
|
32
|
+
require_paths:
|
|
33
|
+
- lib
|
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '2.7'
|
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '0'
|
|
44
|
+
requirements: []
|
|
45
|
+
rubygems_version: 3.6.9
|
|
46
|
+
specification_version: 4
|
|
47
|
+
summary: RuboCop reimplemented in Rust, aiming for byte-identical output
|
|
48
|
+
test_files: []
|