sonicop 26.8.101
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/CONFORMANCE.md +109 -0
- data/Cargo.lock +975 -0
- data/Cargo.toml +40 -0
- data/LICENSE +21 -0
- data/NOTICE +7 -0
- data/README.ja.md +161 -0
- data/README.md +173 -0
- data/config/default.yml +6305 -0
- data/exe/sonicop +7 -0
- data/ext/sonicop/extconf.rb +38 -0
- data/lib/sonicop/runner.rb +67 -0
- data/lib/sonicop/version.rb +6 -0
- data/lib/sonicop.rb +8 -0
- data/licenses/RUBOCOP.txt +20 -0
- data/licenses/TREE_SITTER_RUBY.txt +21 -0
- data/src/cli.rs +940 -0
- data/src/config/inheritance.rs +332 -0
- data/src/config/loader.rs +117 -0
- data/src/config/mod.rs +461 -0
- data/src/config/paths.rs +436 -0
- data/src/config/plugin.rs +247 -0
- data/src/config/store.rs +141 -0
- data/src/cop_name.rs +71 -0
- data/src/diagnostic.rs +205 -0
- data/src/directives.rs +305 -0
- data/src/engine.rs +734 -0
- data/src/formatter.rs +684 -0
- data/src/lib.rs +42 -0
- data/src/main.rs +3 -0
- data/src/ruby_version.rs +393 -0
- data/src/rules/layout/empty_line_after_magic_comment.rs +49 -0
- data/src/rules/layout/end_of_line.rs +35 -0
- data/src/rules/layout/line_length.rs +167 -0
- data/src/rules/layout/mod.rs +13 -0
- data/src/rules/layout/space_after_comma.rs +32 -0
- data/src/rules/layout/space_around_operators.rs +104 -0
- data/src/rules/layout/space_inside_parens.rs +100 -0
- data/src/rules/layout/support.rs +23 -0
- data/src/rules/layout/trailing_empty_lines.rs +38 -0
- data/src/rules/layout/trailing_whitespace.rs +26 -0
- data/src/rules/lint/duplicate_methods.rs +72 -0
- data/src/rules/lint/mod.rs +7 -0
- data/src/rules/lint/syntax.rs +200 -0
- data/src/rules/lint/unused_block_argument.rs +74 -0
- data/src/rules/lint/useless_assignment.rs +104 -0
- data/src/rules/metrics/block_length.rs +39 -0
- data/src/rules/metrics/class_length.rs +34 -0
- data/src/rules/metrics/method_length.rs +10 -0
- data/src/rules/metrics/mod.rs +10 -0
- data/src/rules/metrics/module_length.rs +17 -0
- data/src/rules/metrics/parameter_lists.rs +21 -0
- data/src/rules/metrics/support.rs +105 -0
- data/src/rules/mod.rs +380 -0
- data/src/rules/naming/ascii_identifiers.rs +17 -0
- data/src/rules/naming/constant_name.rs +49 -0
- data/src/rules/naming/method_name.rs +51 -0
- data/src/rules/naming/mod.rs +9 -0
- data/src/rules/naming/support.rs +22 -0
- data/src/rules/naming/variable_name.rs +50 -0
- data/src/rules/security/eval.rs +170 -0
- data/src/rules/security/mod.rs +6 -0
- data/src/rules/style/frozen_string_literal_comment.rs +56 -0
- data/src/rules/style/hash_syntax.rs +63 -0
- data/src/rules/style/mod.rs +9 -0
- data/src/rules/style/numeric_literals.rs +59 -0
- data/src/rules/style/redundant_return.rs +143 -0
- data/src/rules/style/semicolon.rs +48 -0
- data/src/rules/style/string_literals.rs +74 -0
- data/src/rules/support.rs +31 -0
- data/src/source.rs +118 -0
- metadata +117 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 9c2383add6601b741d516e8efb4116d217555568a60b08517aa294e42a47fac4
|
|
4
|
+
data.tar.gz: 65fcd7157dbd75afe11b9f89d069c5c89a34a907517b1c83b022716477d6e373
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 410780fd39347da7d2b707a0573ec6ad26d3ed852929abc37d88d492fd499eaf4286790ad09137fb737b173358c8073804aa8d4afd7e6b631630f5a740d6e0c2
|
|
7
|
+
data.tar.gz: c0905dee79e639abd4cb472b7d7a18c60c198b34f20cef3f84d6ac6a878ce95a2c6fc7e65c7b9e6f90b6e4c32b7da4f0ca7d325ca0f7f4a49cd94c3260434417
|
data/CONFORMANCE.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# RuboCop conformance
|
|
2
|
+
|
|
3
|
+
Snapshot date: 2026-08-10
|
|
4
|
+
Reference: RuboCop 1.89.0
|
|
5
|
+
Corpus: the complete 1,759-file RuboCop source tree
|
|
6
|
+
Configuration: RuboCop 1.89.0 built-in defaults (`--force-default-config`)
|
|
7
|
+
|
|
8
|
+
The bundled `config/default.yml` records the upstream version it was vendored from in its header.
|
|
9
|
+
Re-fetch it with `scripts/sync_default_yml.sh <rubocop-version>`.
|
|
10
|
+
|
|
11
|
+
The comparison covers every cop Sonicop implemented at the snapshot date, listed verbatim in the
|
|
12
|
+
`cops` variable of the command below. Each JSON offense is normalized by path, cop, line, column,
|
|
13
|
+
length, severity, correctability, and message. Run `sonicop --show-cops` for the current set.
|
|
14
|
+
|
|
15
|
+
| Result | Count |
|
|
16
|
+
|---|---:|
|
|
17
|
+
| Reference offense locations | 4,052 |
|
|
18
|
+
| Sonicop offense locations | 4,052 |
|
|
19
|
+
| Matching locations | 4,052 |
|
|
20
|
+
| False positives | **0** |
|
|
21
|
+
| False negatives | **0** |
|
|
22
|
+
| Location recall | **100%** |
|
|
23
|
+
| Message/severity/correctability differences at matching locations | **0** |
|
|
24
|
+
|
|
25
|
+
All offenses from the implemented cops match RuboCop by location, message, severity, and
|
|
26
|
+
correctability. This includes RuboCop's source-line indexing for metric cops, line-length
|
|
27
|
+
correctability and exemptions, directive lexing around heredocs, and target-version syntax errors.
|
|
28
|
+
|
|
29
|
+
Run the harness against a local RuboCop and corpus. It defaults to `rubocop` on `PATH`
|
|
30
|
+
(`gem install rubocop`) as the reference and `./target/release/sonicop` (`make release`) as the
|
|
31
|
+
candidate, so both only need `--reference` / `--candidate` when they live elsewhere — for example
|
|
32
|
+
`--reference "bundle exec rubocop"` inside a bundled project:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
cops="Layout/EmptyLineAfterMagicComment,Layout/EndOfLine,Layout/LineLength,Layout/SpaceAfterComma,Layout/SpaceAroundOperators,Layout/SpaceInsideParens,Layout/TrailingEmptyLines,Layout/TrailingWhitespace,Lint/DuplicateMethods,Lint/Syntax,Lint/UnusedBlockArgument,Lint/UselessAssignment,Metrics/BlockLength,Metrics/ClassLength,Metrics/MethodLength,Metrics/ModuleLength,Metrics/ParameterLists,Naming/AsciiIdentifiers,Naming/ConstantName,Naming/MethodName,Naming/VariableName,Security/Eval,Style/FrozenStringLiteralComment,Style/HashSyntax,Style/NumericLiterals,Style/RedundantReturn,Style/Semicolon,Style/StringLiterals"
|
|
36
|
+
|
|
37
|
+
scripts/conformance_diff.sh \
|
|
38
|
+
--force-default-config \
|
|
39
|
+
--cop "${cops}" \
|
|
40
|
+
-- /path/to/rubocop
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`Lint/Syntax` is also run independently over the corpus. The latest owayo tree-sitter grammar
|
|
44
|
+
accepts the modern syntax in all 1,759 files, while Sonicop resolves Ruby 2.6 from the corpus
|
|
45
|
+
gemspec and applies a post-parse syntax feature gate. Its four fatal offenses, including the legacy
|
|
46
|
+
parser recovery diagnostics, exactly match RuboCop.
|
|
47
|
+
|
|
48
|
+
## Limits of this measurement
|
|
49
|
+
|
|
50
|
+
The 100% above is a property of *this corpus*, not a general accuracy claim. RuboCop's own source
|
|
51
|
+
tree is RuboCop-clean and stylistically uniform, so entire classes of input never occur in it and
|
|
52
|
+
the comparison cannot exercise them. A cop that is never triggered contributes nothing to the
|
|
53
|
+
match count, and its absence is indistinguishable from agreement.
|
|
54
|
+
|
|
55
|
+
Two implemented cops are confirmed to produce **zero offenses on both sides** over this corpus, so
|
|
56
|
+
this run says nothing about them:
|
|
57
|
+
|
|
58
|
+
| Cop | Offenses in this corpus | Verified elsewhere |
|
|
59
|
+
|---|---:|---|
|
|
60
|
+
| `Layout/TrailingEmptyLines` | 0 | Diverges on line, column, length, and message for a file ending in a blank line |
|
|
61
|
+
| `Naming/AsciiIdentifiers` | 0 | Rails contains exactly two occurrences; both diverge on message casing |
|
|
62
|
+
|
|
63
|
+
Running the same harness over application code rather than linter source surfaces divergences this
|
|
64
|
+
corpus does not. Treat a clean run on any single corpus as evidence about that corpus.
|
|
65
|
+
|
|
66
|
+
Two properties of the harness itself also bound what a run can tell you:
|
|
67
|
+
|
|
68
|
+
- Only the cops passed to `--cop` are compared. Cops that RuboCop reports and Sonicop has not
|
|
69
|
+
implemented show up as false negatives, which is expected rather than a defect.
|
|
70
|
+
- RuboCop emits **only** `Lint/Syntax` for a file it considers fatally unparseable and suppresses
|
|
71
|
+
every other cop for that file, while Sonicop keeps inspecting it. Whenever the two disagree
|
|
72
|
+
about syntax validity — most easily triggered by a `TargetRubyVersion` the source does not
|
|
73
|
+
satisfy — the false-positive count is dominated by that single behaviour rather than by cop
|
|
74
|
+
logic. Check the reference output for `"severity": "fatal"` before reading a large false-positive
|
|
75
|
+
count as a cop problem.
|
|
76
|
+
|
|
77
|
+
Closing these gaps properly means migrating RuboCop's own spec suite, which exercises each cop
|
|
78
|
+
against inputs written to break it. Until that lands, this document records what was measured, not
|
|
79
|
+
an upper bound on what could differ.
|
|
80
|
+
|
|
81
|
+
## Rails configuration and scale
|
|
82
|
+
|
|
83
|
+
Rails source snapshot: `adf307b03b4241cbc0ed3821faf3b153ca6cd5cd` (Rails 8.2.0.alpha).
|
|
84
|
+
The reference process uses RuboCop 1.89.0 with the five plugins declared by Rails:
|
|
85
|
+
rubocop-minitest 0.40.0, rubocop-packaging 0.6.0, rubocop-performance 1.26.1,
|
|
86
|
+
rubocop-rails 2.36.0, and rubocop-md 2.0.4.
|
|
87
|
+
|
|
88
|
+
This corpus exercises `AllCops/DisabledByDefault`, external plugin cops, recursive excludes,
|
|
89
|
+
hidden paths, and the inherited `guides/.rubocop.yml` configuration.
|
|
90
|
+
|
|
91
|
+
| Compatibility check | RuboCop | Sonicop | Result |
|
|
92
|
+
|---|---:|---:|---|
|
|
93
|
+
| Ruby target files from repository root | 3,453 | 3,453 | Exact paths and order |
|
|
94
|
+
| Enabled cops for `activerecord/lib/active_record.rb` | 107 | 107 | Exact names and order |
|
|
95
|
+
| Enabled cops for a file under `guides/` | 102 | 102 | Exact names and order |
|
|
96
|
+
| Full-tree false positives | — | 0 | Pass |
|
|
97
|
+
|
|
98
|
+
RuboCop also discovers 75 Markdown targets through rubocop-md. Markdown extraction is outside
|
|
99
|
+
Sonicop's current parser scope, so those files are removed before comparing `-L` output.
|
|
100
|
+
|
|
101
|
+
The full 3,453-Ruby-file offense comparison reports 10 reference locations and no Sonicop
|
|
102
|
+
locations: zero false positives and 10 visible false negatives. The missing locations are three
|
|
103
|
+
`Style/RedundantPercentQ`, two `Lint/RedundantCopDisableDirective`, two
|
|
104
|
+
`Layout/IndentationWidth`, two unsupported `Lint/DuplicateMethods` cases, and one
|
|
105
|
+
`Lint/Debugger`. Artifacts: `/tmp/sonicop-conformance-rails-full-2`.
|
|
106
|
+
|
|
107
|
+
On the 402-file `activerecord/lib` subset, a warmed single run with cache and color disabled took
|
|
108
|
+
4.37 seconds for RuboCop and 0.35 seconds for Sonicop (`/usr/bin/time -p`): approximately
|
|
109
|
+
**12.5x faster** on the validation machine.
|