gl_rubocop 0.2.17 → 0.2.19
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/default.yml +10 -1
- data/gl_rubocop.gemspec +0 -2
- data/lib/gl_rubocop/gl_cops/no_stubbing_perform_async.rb +25 -24
- data/lib/gl_rubocop/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bd4eb564bfaea4ae8ab15506ff2196070f55223989f1ac9504f281913a55dd6c
|
|
4
|
+
data.tar.gz: 931bb25c4f11632bacfada61d5cf99306dbfddf1d4ba056f9ee773f86a876e6c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1db06adef9f18338c30d02177c993ef7c7978f4563683ac821c933f824170476f0088b90cc29ce87629d6b0d5bf76e335cacb8662d25a6583de074e5f92de18b
|
|
7
|
+
data.tar.gz: d2631001ed66f5f91ede31f60387f07edf95bb297cd999e2b2528b29b79c215c75bfa0c79771804505b25b3ccfc457c54b8a42f35cc615f5af9d621e8769b86e
|
data/default.yml
CHANGED
|
@@ -50,6 +50,8 @@ GLCops/LimitFlashOptions:
|
|
|
50
50
|
|
|
51
51
|
GLCops/NoStubbingPerformAsync:
|
|
52
52
|
Enabled: true
|
|
53
|
+
Include:
|
|
54
|
+
- "**/*spec.rb"
|
|
53
55
|
|
|
54
56
|
GLCops/PreventErbFiles:
|
|
55
57
|
Enabled: true
|
|
@@ -72,6 +74,11 @@ I18n/GetText:
|
|
|
72
74
|
|
|
73
75
|
I18n/RailsI18n:
|
|
74
76
|
Enabled: true
|
|
77
|
+
Exclude:
|
|
78
|
+
- "spec/**/*"
|
|
79
|
+
- "packs/*/spec/**/*"
|
|
80
|
+
- Gemfile
|
|
81
|
+
- "*.gemspec"
|
|
75
82
|
|
|
76
83
|
Layout/ClassStructure:
|
|
77
84
|
Enabled: true
|
|
@@ -157,8 +164,10 @@ Metrics/MethodLength:
|
|
|
157
164
|
Max: 15
|
|
158
165
|
|
|
159
166
|
Metrics/ParameterLists:
|
|
167
|
+
Max: 6
|
|
160
168
|
Exclude:
|
|
161
169
|
- "db/seeds/**/*"
|
|
170
|
+
- "app/components/**/*"
|
|
162
171
|
|
|
163
172
|
Metrics/PerceivedComplexity:
|
|
164
173
|
Exclude:
|
|
@@ -397,4 +406,4 @@ Style/HashAsLastArrayItem:
|
|
|
397
406
|
Enabled: false
|
|
398
407
|
|
|
399
408
|
Style/MultilineBlockChain:
|
|
400
|
-
Enabled: false
|
|
409
|
+
Enabled: false
|
data/gl_rubocop.gemspec
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative 'lib/gl_rubocop/version'
|
|
4
4
|
|
|
5
|
-
# rubocop:disable I18n/RailsI18n/DecorateString
|
|
6
5
|
NON_GEM_FILES = ['Gemfile', 'Gemfile.lock', 'Guardfile', 'bin/lint'].freeze
|
|
7
6
|
|
|
8
7
|
Gem::Specification.new do |spec|
|
|
@@ -38,4 +37,3 @@ Gem::Specification.new do |spec|
|
|
|
38
37
|
|
|
39
38
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
40
39
|
end
|
|
41
|
-
# rubocop:enable I18n/RailsI18n/DecorateString
|
|
@@ -16,43 +16,44 @@ module GLRubocop
|
|
|
16
16
|
MSG = "Don't stub perform async. Use the rspec-sidekick matchers instead: " \
|
|
17
17
|
'expect(JobClass).to have_enqueued_sidekiq_job'.freeze
|
|
18
18
|
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
# expect(SomeWorker).to have_received(:perform_in)
|
|
23
|
-
def_node_matcher :perform_method_expectation?, <<~PATTERN
|
|
24
|
-
(send#{' '}
|
|
25
|
-
(send nil? :expect $_)#{' '}
|
|
26
|
-
{:not_to :to_not :to}#{' '}
|
|
27
|
-
(send nil? :have_received (sym {:perform_async :perform_in}) ...))
|
|
19
|
+
# Match have_received with perform_async or perform_in
|
|
20
|
+
def_node_matcher :have_received_perform?, <<~PATTERN
|
|
21
|
+
(send nil? :have_received (sym {:perform_async :perform_in}) ...)
|
|
28
22
|
PATTERN
|
|
29
23
|
|
|
30
|
-
#
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def_node_matcher :perform_method_allow?, <<~PATTERN
|
|
34
|
-
(send
|
|
35
|
-
(send nil? :allow $_)
|
|
36
|
-
:to
|
|
37
|
-
(send nil? :receive (sym {:perform_async :perform_in}) ...))
|
|
24
|
+
# Match receive with perform_async or perform_in
|
|
25
|
+
def_node_matcher :receive_perform?, <<~PATTERN
|
|
26
|
+
(send nil? :receive (sym {:perform_async :perform_in}) ...)
|
|
38
27
|
PATTERN
|
|
39
28
|
|
|
40
29
|
def on_send(node)
|
|
41
|
-
|
|
30
|
+
return unless have_received_perform?(node) || receive_perform?(node)
|
|
31
|
+
|
|
32
|
+
# Find the expect or allow context
|
|
33
|
+
offense_node = find_offense_node(node)
|
|
34
|
+
add_offense(offense_node) if offense_node
|
|
42
35
|
end
|
|
43
36
|
|
|
44
37
|
private
|
|
45
38
|
|
|
46
|
-
def
|
|
47
|
-
|
|
39
|
+
def find_offense_node(node)
|
|
40
|
+
current = node.parent
|
|
41
|
+
while current
|
|
42
|
+
return current if rspec_stubbing?(current)
|
|
48
43
|
|
|
49
|
-
|
|
44
|
+
current = current.parent
|
|
45
|
+
end
|
|
46
|
+
nil
|
|
50
47
|
end
|
|
51
48
|
|
|
52
|
-
def
|
|
53
|
-
|
|
49
|
+
def rspec_stubbing?(node)
|
|
50
|
+
return false unless node.send_type?
|
|
51
|
+
return false unless %i[to not_to to_not].include?(node.method_name)
|
|
52
|
+
|
|
53
|
+
receiver = node.receiver
|
|
54
|
+
return false unless receiver&.send_type?
|
|
54
55
|
|
|
55
|
-
|
|
56
|
+
%i[allow expect].include?(receiver.method_name)
|
|
56
57
|
end
|
|
57
58
|
end
|
|
58
59
|
end
|
data/lib/gl_rubocop/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gl_rubocop
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.19
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Give Lively
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-10-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rubocop
|
|
@@ -177,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
177
177
|
- !ruby/object:Gem::Version
|
|
178
178
|
version: '0'
|
|
179
179
|
requirements: []
|
|
180
|
-
rubygems_version: 3.
|
|
180
|
+
rubygems_version: 3.4.19
|
|
181
181
|
signing_key:
|
|
182
182
|
specification_version: 4
|
|
183
183
|
summary: A shareable configuration of Give Lively's rubocop rules.
|