gl_rubocop 0.2.18 → 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 +5 -1
- data/lib/gl_rubocop/gl_cops/no_stubbing_perform_async.rb +25 -24
- data/lib/gl_rubocop/version.rb +1 -1
- metadata +2 -2
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
|
|
@@ -162,8 +164,10 @@ Metrics/MethodLength:
|
|
|
162
164
|
Max: 15
|
|
163
165
|
|
|
164
166
|
Metrics/ParameterLists:
|
|
167
|
+
Max: 6
|
|
165
168
|
Exclude:
|
|
166
169
|
- "db/seeds/**/*"
|
|
170
|
+
- "app/components/**/*"
|
|
167
171
|
|
|
168
172
|
Metrics/PerceivedComplexity:
|
|
169
173
|
Exclude:
|
|
@@ -402,4 +406,4 @@ Style/HashAsLastArrayItem:
|
|
|
402
406
|
Enabled: false
|
|
403
407
|
|
|
404
408
|
Style/MultilineBlockChain:
|
|
405
|
-
Enabled: false
|
|
409
|
+
Enabled: false
|
|
@@ -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
|