rubocop-fourshark 0.5.0 → 0.6.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 +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +7 -1
- data/config/default.yml +14 -7
- data/lib/rubocop/cop/rails/bidirectional_association.rb +2 -2
- data/lib/rubocop/cop/rails/mandatory_inverse_of.rb +2 -2
- data/lib/rubocop/cop/rspec/inverse_of_matcher.rb +2 -2
- data/lib/rubocop/fourshark/version.rb +1 -1
- 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: c4b2d2e8d312ae14c7f582304f4b698783d89dcbaaabb97edbdbf8eb8637d782
|
|
4
|
+
data.tar.gz: 2c21cc3d147f2210f38dc5d694b72a3955da359518a037a9270d60c67bf352d3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c314121bb42e4b79fe8e2ab9f6658c47f44042ef9cc0038bdd62a905ac8bbe986ff26f1ee67521e6d73ea2585ddaf0fd3d393cb2b54d853f16e115985cc769a6
|
|
7
|
+
data.tar.gz: 861c512174a3a30f7ecbe223467f41899ea8a418f631eb3e44c51c35715538a667be755e5e4bd7f87d7370827347fd75958cfb8cac2296c998ba2e4c1a82c058
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## [0.6.0] - 2026-08-05
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
- `Naming/RescuedExceptionsVariableName` configured to `exception` — a rescued exception is no longer bound to a single-letter name
|
|
6
|
+
|
|
7
|
+
## [0.5.1] - 2026-06-29
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- `RSpec/Dialect` no longer remaps `subject`/`subject!` to `let`; only `let!` is remapped. The blind identifier rename rewrote value references such as `expect(subject)` into invalid `expect(let)`
|
|
12
|
+
|
|
1
13
|
## [0.5.0] - 2026-06-29
|
|
2
14
|
|
|
3
15
|
### Changed
|
data/README.md
CHANGED
|
@@ -52,7 +52,7 @@ Activating the plugin auto-loads the gem's `config/default.yml`, which enables e
|
|
|
52
52
|
|
|
53
53
|
All cops are **enabled by default** the moment the plugin is activated. Cops scoped to a path (models, specs, factories) only run on files matching that path. Each cop's source file under [`lib/rubocop/cop`](lib/rubocop/cop) carries runnable `@example` blocks showing the bad/good shapes.
|
|
54
54
|
|
|
55
|
-
###
|
|
55
|
+
### Cop naming
|
|
56
56
|
|
|
57
57
|
Cop names follow RuboCop's empirical convention — a noun phrase describing the construct or smell, no `Disallow*`/`No*` prefixes — with two deliberate exceptions:
|
|
58
58
|
|
|
@@ -81,6 +81,12 @@ Where a 4Shark cop supersedes or contradicts a stock cop, `config/default.yml` t
|
|
|
81
81
|
|---|---|
|
|
82
82
|
| `Layout/MultilineStatementSpacing` | Requires a blank line between two consecutive statements when either spans multiple lines, so multi-line statements read as distinct units. |
|
|
83
83
|
|
|
84
|
+
### Naming
|
|
85
|
+
|
|
86
|
+
| Cop | Intent |
|
|
87
|
+
|---|---|
|
|
88
|
+
| `Naming/RescuedExceptionsVariableName` | A rescued exception is bound to `exception` (`_exception` when unread), not the cop's default `e` — 4Shark bans single-letter variables, and this is the one slot where a stock cop demanded one. Stock cop, configured via `PreferredName`; autocorrects. |
|
|
89
|
+
|
|
84
90
|
### Rails (models)
|
|
85
91
|
|
|
86
92
|
| Cop | Intent |
|
data/config/default.yml
CHANGED
|
@@ -14,6 +14,14 @@ Layout/MultilineStatementSpacing:
|
|
|
14
14
|
Layout/MultilineMethodCallIndentation:
|
|
15
15
|
EnforcedStyle: indented
|
|
16
16
|
|
|
17
|
+
# Stock cop configured (not a 4Shark cop): name the rescued exception variable
|
|
18
|
+
# `exception`. The cop's default is `e`, and a single-letter variable is banned by
|
|
19
|
+
# the 4Shark naming convention — so the two disagree on every rescue in the
|
|
20
|
+
# codebase. `PreferredName` is the option the cop ships to settle exactly that,
|
|
21
|
+
# and the cop autocorrects, so the rename is mechanical.
|
|
22
|
+
Naming/RescuedExceptionsVariableName:
|
|
23
|
+
PreferredName: exception
|
|
24
|
+
|
|
17
25
|
Style/DisallowSafeNavigation:
|
|
18
26
|
Description: 'Do not use safe navigation (`&.`). Use explicit conditionals instead.'
|
|
19
27
|
Enabled: true
|
|
@@ -56,16 +64,15 @@ Rails/OrderedMacros:
|
|
|
56
64
|
- 'app/models/**/*.rb'
|
|
57
65
|
VersionAdded: '0.2.0'
|
|
58
66
|
|
|
59
|
-
# Stock cop configured (not a 4Shark cop): map `
|
|
60
|
-
#
|
|
61
|
-
# `
|
|
62
|
-
#
|
|
67
|
+
# Stock cop configured (not a 4Shark cop): map `let!` to `let` so every eager
|
|
68
|
+
# `let!` call is flagged in favor of a lazy `let` (force creation in an explicit
|
|
69
|
+
# `before`, not with `let!`). `subject`/`subject!` are intentionally NOT remapped:
|
|
70
|
+
# RSpec/Dialect renames the identifier blindly, so a `subject` -> `let` mapping
|
|
71
|
+
# also rewrites value references like `expect(subject)` into invalid `expect(let)`.
|
|
63
72
|
RSpec/Dialect:
|
|
64
|
-
Description: '
|
|
73
|
+
Description: 'Prefer a lazy `let` over `let!` — force creation in an explicit `before`, not with `let!`.'
|
|
65
74
|
Enabled: true
|
|
66
75
|
PreferredMethods:
|
|
67
|
-
subject: let
|
|
68
|
-
subject!: let
|
|
69
76
|
let!: let
|
|
70
77
|
Include:
|
|
71
78
|
- 'spec/**/*_spec.rb'
|
|
@@ -58,7 +58,7 @@ module RuboCop
|
|
|
58
58
|
add_global_offense("#{target_class} is missing opposite association for #{model_name}")
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
|
-
rescue StandardError =>
|
|
61
|
+
rescue StandardError => exception
|
|
62
62
|
source_name =
|
|
63
63
|
if processed_source && processed_source.buffer
|
|
64
64
|
processed_source.file_path
|
|
@@ -66,7 +66,7 @@ module RuboCop
|
|
|
66
66
|
'unknown'
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
warn "Rails/BidirectionalAssociation failed on #{source_name}: #{
|
|
69
|
+
warn "Rails/BidirectionalAssociation failed on #{source_name}: #{exception.message}"
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
private
|
|
@@ -41,7 +41,7 @@ module RuboCop
|
|
|
41
41
|
!kwargs || !kwargs.hash_type? || kwargs.keys.none? { |k| k.value == :inverse_of }
|
|
42
42
|
|
|
43
43
|
add_offense(node.loc.selector) if missing_inverse_of
|
|
44
|
-
rescue StandardError =>
|
|
44
|
+
rescue StandardError => exception
|
|
45
45
|
source_name =
|
|
46
46
|
if processed_source && processed_source.buffer
|
|
47
47
|
processed_source.file_path
|
|
@@ -49,7 +49,7 @@ module RuboCop
|
|
|
49
49
|
'unknown'
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
warn "Rails/MandatoryInverseOf failed on #{source_name}: #{
|
|
52
|
+
warn "Rails/MandatoryInverseOf failed on #{source_name}: #{exception.message}"
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
private
|
|
@@ -46,7 +46,7 @@ module RuboCop
|
|
|
46
46
|
elsif classification == :subclass
|
|
47
47
|
add_offense(node.loc.selector, message: MSG_FORBIDDEN_INVERSE) if chain_has_inverse_of?(node)
|
|
48
48
|
end
|
|
49
|
-
rescue StandardError =>
|
|
49
|
+
rescue StandardError => exception
|
|
50
50
|
source_name =
|
|
51
51
|
if processed_source && processed_source.buffer
|
|
52
52
|
processed_source.file_path
|
|
@@ -54,7 +54,7 @@ module RuboCop
|
|
|
54
54
|
'unknown'
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
warn "RSpec/InverseOfMatcher failed on #{source_name}: #{
|
|
57
|
+
warn "RSpec/InverseOfMatcher failed on #{source_name}: #{exception.message}"
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
private
|