rubocop-legion 0.1.0 → 0.1.1
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/config/default.yml +6 -2
- data/lib/rubocop/cop/legion/rescue_logging/bare_rescue.rb +11 -0
- data/lib/rubocop/cop/legion/rescue_logging/no_capture.rb +12 -6
- data/lib/rubocop/cop/legion/rescue_logging/silent_capture.rb +2 -0
- data/lib/rubocop/legion/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: 761ab5c8fe6b85b1df48dddace038f224e7a1a65289c8f06a4c8e37543a284f3
|
|
4
|
+
data.tar.gz: 20316578e3b32c13a62b1524167523ce2f9105557d4bf4301b1f146108cbf05c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ca163ec06479b86169f5fa4016950c85b9d7ffdb2d7636fbd7f2a5afaf93cf98ad488ff23acee8c77b6ce505c09e8ac6928592b7d16a7a088f8edeeed11a97e0
|
|
7
|
+
data.tar.gz: 51ec78f8b560249fb871e185e0989f3f9af27bfc40b637adc46b9c6d20c4f10a376a60aa7ad397f08f89b10e10267de3e815a98bc9faf7dddd0903e55ffe0a8f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.1.1] - 2026-03-29
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- BareRescue auto-corrector no longer corrupts inline rescue modifiers (`foo rescue nil`)
|
|
7
|
+
- NoCapture removed auto-correct to prevent correction loop with Lint/UselessAssignment
|
|
8
|
+
- SilentCapture skips `_`-prefixed variables (Ruby unused variable convention)
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- HelperMigration cops scoped to `lib/legion/extensions/**/*.rb` (lex-* gems only)
|
|
12
|
+
- Extension cops scoped to `lib/legion/extensions/**/*.rb` with spec exclusion
|
|
13
|
+
- ApiStringKeys scoped to `lib/legion/extensions/**/*.rb` (Faraday responses use string keys)
|
|
14
|
+
|
|
3
15
|
## [0.1.0] - 2026-03-29
|
|
4
16
|
|
|
5
17
|
### Added
|
data/config/default.yml
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Legion/HelperMigration:
|
|
4
4
|
Enabled: true
|
|
5
5
|
Include:
|
|
6
|
-
- 'lib/**/*.rb'
|
|
6
|
+
- 'lib/legion/extensions/**/*.rb'
|
|
7
7
|
Exclude:
|
|
8
8
|
- 'spec/**/*'
|
|
9
9
|
|
|
@@ -163,7 +163,7 @@ Legion/Framework/ApiStringKeys:
|
|
|
163
163
|
Severity: warning
|
|
164
164
|
VersionAdded: '0.1'
|
|
165
165
|
Include:
|
|
166
|
-
- 'lib/**/*.rb'
|
|
166
|
+
- 'lib/legion/extensions/**/*.rb'
|
|
167
167
|
Exclude:
|
|
168
168
|
- 'spec/**/*'
|
|
169
169
|
|
|
@@ -171,6 +171,10 @@ Legion/Framework/ApiStringKeys:
|
|
|
171
171
|
|
|
172
172
|
Legion/Extension:
|
|
173
173
|
Enabled: true
|
|
174
|
+
Include:
|
|
175
|
+
- 'lib/legion/extensions/**/*.rb'
|
|
176
|
+
Exclude:
|
|
177
|
+
- 'spec/**/*'
|
|
174
178
|
|
|
175
179
|
Legion/Extension/ActorSingularModule:
|
|
176
180
|
Description: 'Use `module Actor` (singular). Framework discovers actors in `Actor`, not `Actors`.'
|
|
@@ -29,11 +29,22 @@ module RuboCop
|
|
|
29
29
|
|
|
30
30
|
def on_resbody(node)
|
|
31
31
|
return unless node.exceptions.empty? && node.exception_variable.nil?
|
|
32
|
+
return if rescue_modifier?(node)
|
|
32
33
|
|
|
33
34
|
add_offense(node, severity: :warning) do |corrector|
|
|
34
35
|
corrector.insert_after(node.loc.keyword, ' => e')
|
|
35
36
|
end
|
|
36
37
|
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def rescue_modifier?(node)
|
|
42
|
+
rescue_node = node.parent
|
|
43
|
+
return false unless rescue_node&.rescue_type?
|
|
44
|
+
|
|
45
|
+
body = rescue_node.children.first
|
|
46
|
+
body && body.source_range.line == node.loc.keyword.line
|
|
47
|
+
end
|
|
37
48
|
end
|
|
38
49
|
end
|
|
39
50
|
end
|
|
@@ -23,21 +23,27 @@ module RuboCop
|
|
|
23
23
|
# log.error(e.message)
|
|
24
24
|
# end
|
|
25
25
|
class NoCapture < RuboCop::Cop::Base
|
|
26
|
-
extend AutoCorrector
|
|
27
|
-
|
|
28
26
|
MSG = 'Exception class specified but not captured. ' \
|
|
29
27
|
'Use `rescue %<classes>s => e` and log the exception.'
|
|
30
28
|
|
|
31
29
|
def on_resbody(node)
|
|
32
30
|
return if node.exceptions.empty? || !node.exception_variable.nil?
|
|
31
|
+
return if rescue_modifier?(node)
|
|
33
32
|
|
|
34
33
|
classes = node.exceptions.map(&:source).join(', ')
|
|
35
34
|
message = format(MSG, classes: classes)
|
|
36
35
|
|
|
37
|
-
add_offense(node, message: message, severity: :convention)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
add_offense(node, message: message, severity: :convention)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def rescue_modifier?(node)
|
|
42
|
+
rescue_node = node.parent
|
|
43
|
+
return false unless rescue_node&.rescue_type?
|
|
44
|
+
|
|
45
|
+
body = rescue_node.children.first
|
|
46
|
+
body && body.source_range.line == node.loc.keyword.line
|
|
41
47
|
end
|
|
42
48
|
end
|
|
43
49
|
end
|
|
@@ -32,6 +32,8 @@ module RuboCop
|
|
|
32
32
|
return unless node.exception_variable
|
|
33
33
|
|
|
34
34
|
var_name = variable_name(node.exception_variable)
|
|
35
|
+
return if var_name.to_s.start_with?('_')
|
|
36
|
+
|
|
35
37
|
body = node.body
|
|
36
38
|
|
|
37
39
|
return if body && (references_variable?(body, var_name) || contains_raise?(body))
|