gl_rubocop 0.2.10 → 0.2.11
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 +136 -133
- data/lib/gl_rubocop/gl_cops/interactor_inherits_from_interactor_base.rb +2 -2
- data/lib/gl_rubocop/gl_cops/no_stubbing_perform_async.rb +59 -0
- data/lib/gl_rubocop/gl_cops/sidekiq_inherits_from_sidekiq_job.rb +2 -2
- data/lib/gl_rubocop/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19d65dcff9ece63e91e4214d0c4fb6bab5588c4ee97bdc1ef241ca32a3d9afb1
|
4
|
+
data.tar.gz: 96844a8560bce6c4b2d4a2a313f3f3c39625110a3abff73589c56787c171843d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa74fd13e08edc286e3009a6f66fa42e9b47a81c592708f29a3c1f8085e55e39c8b11d1d7166387864e95706a2bbc271b403dd9e34e05a0082874462e8278565
|
7
|
+
data.tar.gz: f8aebf2e5be28e44d38e92a8cd083ae9e7768e0105e31e63b989e5d90e3ece00fd494112b7af4fb865e1e3f48ad2ef4e1a20a77141027899b0be36798946da05
|
data/default.yml
CHANGED
@@ -27,14 +27,20 @@ AllCops:
|
|
27
27
|
- "vendor/**/*"
|
28
28
|
- "bin/**/*"
|
29
29
|
|
30
|
+
Capybara/ClickLinkOrButtonStyle:
|
31
|
+
EnforcedStyle: link_or_button
|
32
|
+
|
33
|
+
Capybara/NegationMatcher:
|
34
|
+
EnforcedStyle: not_to
|
35
|
+
|
36
|
+
GLCops/CallbackMethodNames:
|
37
|
+
Enabled: true
|
38
|
+
|
30
39
|
GLCops/InteractorInheritsFromInteractorBase:
|
31
40
|
Enabled: true
|
32
41
|
Include:
|
33
42
|
- "app/interactors/**/*"
|
34
43
|
|
35
|
-
GLCops/CallbackMethodNames:
|
36
|
-
Enabled: true
|
37
|
-
|
38
44
|
GLCops/PreventErbFiles:
|
39
45
|
Enabled: true
|
40
46
|
|
@@ -51,67 +57,62 @@ GLCops/UniqueIdentifier:
|
|
51
57
|
Include:
|
52
58
|
- "app/components/**/*.haml"
|
53
59
|
|
60
|
+
Layout/ClassStructure:
|
61
|
+
Enabled: true
|
62
|
+
|
54
63
|
Layout/LineLength:
|
55
|
-
Max: 100
|
56
64
|
AllowedPatterns:
|
57
65
|
- "^ *#" # Ignores full lines starting with any indentation and a comment (#)
|
66
|
+
Max: 100
|
58
67
|
|
59
68
|
Lint/MissingSuper:
|
60
69
|
Exclude:
|
61
70
|
- "app/components/**/*"
|
62
71
|
|
63
|
-
MagicNumbers/
|
72
|
+
MagicNumbers/NoArgument:
|
73
|
+
Enabled: true
|
64
74
|
Exclude:
|
65
75
|
- "spec/**/*"
|
66
76
|
- "**/spec/**/*"
|
67
|
-
|
77
|
+
PermittedValues:
|
78
|
+
- 0
|
79
|
+
- 1
|
80
|
+
|
81
|
+
MagicNumbers/NoAssignment:
|
68
82
|
AllowedAssignments:
|
69
83
|
- instance_variables
|
70
84
|
- class_variables
|
71
85
|
- global_variables
|
72
|
-
|
73
|
-
MagicNumbers/NoArgument:
|
86
|
+
Enabled: false
|
74
87
|
Exclude:
|
75
88
|
- "spec/**/*"
|
76
89
|
- "**/spec/**/*"
|
77
|
-
Enabled: true
|
78
|
-
PermittedValues:
|
79
|
-
- 0
|
80
|
-
- 1
|
81
90
|
|
82
91
|
MagicNumbers/NoDefault:
|
92
|
+
Enabled: true
|
83
93
|
Exclude:
|
84
94
|
- "spec/**/*"
|
85
95
|
- "**/spec/**/*"
|
86
|
-
Enabled: true
|
87
96
|
PermittedValues:
|
88
97
|
- 0
|
89
98
|
- 1
|
90
99
|
|
91
100
|
MagicNumbers/NoReturn:
|
101
|
+
Enabled: true
|
92
102
|
Exclude:
|
93
103
|
- "spec/**/*"
|
94
104
|
- "**/spec/**/*"
|
95
|
-
Enabled: true
|
96
105
|
PermittedReturnValues:
|
97
106
|
- 0
|
98
107
|
- 1
|
99
108
|
|
100
109
|
Metrics/AbcSize:
|
101
|
-
Max: 17
|
102
110
|
Exclude:
|
103
111
|
- "db/**/*"
|
104
112
|
- "spec/**/*"
|
105
113
|
- "config/routes.rb"
|
106
114
|
- "config/routes/*"
|
107
|
-
|
108
|
-
Metrics/MethodLength:
|
109
|
-
Max: 15
|
110
|
-
Exclude:
|
111
|
-
- "app/mailers/**/*"
|
112
|
-
- "config/routes/**/*"
|
113
|
-
- "db/**/*"
|
114
|
-
- "lib/tasks/**/*"
|
115
|
+
Max: 17
|
115
116
|
|
116
117
|
Metrics/BlockLength:
|
117
118
|
Exclude:
|
@@ -122,134 +123,157 @@ Metrics/BlockLength:
|
|
122
123
|
- "spec/**/*"
|
123
124
|
|
124
125
|
Metrics/ClassLength:
|
125
|
-
Max: 150
|
126
126
|
Exclude:
|
127
127
|
- "db/seeds/**/*"
|
128
|
+
Max: 150
|
128
129
|
|
129
130
|
Metrics/CyclomaticComplexity:
|
130
131
|
Exclude:
|
131
132
|
- "db/seeds/**/*"
|
132
133
|
|
133
|
-
Metrics/
|
134
|
+
Metrics/MethodLength:
|
134
135
|
Exclude:
|
135
|
-
- "
|
136
|
+
- "app/mailers/**/*"
|
137
|
+
- "config/routes/**/*"
|
138
|
+
- "db/**/*"
|
139
|
+
- "lib/tasks/**/*"
|
140
|
+
Max: 15
|
136
141
|
|
137
142
|
Metrics/ParameterLists:
|
138
143
|
Exclude:
|
139
144
|
- "db/seeds/**/*"
|
140
145
|
|
146
|
+
Metrics/PerceivedComplexity:
|
147
|
+
Exclude:
|
148
|
+
- "db/seeds/**/*"
|
149
|
+
|
150
|
+
Naming/MethodParameterName:
|
151
|
+
MinNameLength: 1
|
152
|
+
|
153
|
+
Naming/VariableNumber:
|
154
|
+
AllowedIdentifiers:
|
155
|
+
- is_501c3
|
156
|
+
- last4
|
157
|
+
- line1
|
158
|
+
- line2
|
159
|
+
- address_line1
|
160
|
+
- address_line2
|
161
|
+
- google_oauth2
|
162
|
+
- s3
|
163
|
+
- shift4
|
164
|
+
- Shift4
|
165
|
+
EnforcedStyle: "snake_case"
|
166
|
+
|
141
167
|
Performance/MapCompact:
|
142
168
|
Enabled: false
|
143
169
|
|
144
|
-
|
145
|
-
EnforcedStyle: prefer_alias_method
|
146
|
-
|
147
|
-
Style/AsciiComments:
|
170
|
+
RSpec/AnyInstance:
|
148
171
|
Enabled: false
|
149
172
|
|
150
|
-
|
151
|
-
|
173
|
+
RSpec/DescribeClass:
|
174
|
+
Exclude:
|
175
|
+
- "spec/api/**/*"
|
176
|
+
- "spec/views/**/*"
|
177
|
+
- "spec/lib/tasks/**/*"
|
152
178
|
|
153
|
-
|
179
|
+
RSpec/EmptyExampleGroup:
|
154
180
|
Exclude:
|
155
|
-
- "
|
181
|
+
- "spec/api/**/*"
|
156
182
|
|
157
|
-
|
158
|
-
|
183
|
+
RSpec/ExampleLength:
|
184
|
+
Exclude:
|
185
|
+
- "spec/lib/props_module_spec.rb"
|
186
|
+
- "spec/system/**/*"
|
187
|
+
- "spec/serializers/**/*"
|
188
|
+
Max: 30
|
159
189
|
|
160
|
-
|
161
|
-
Enabled:
|
190
|
+
RSpec/FilePath:
|
191
|
+
Enabled: true
|
192
|
+
Exclude:
|
193
|
+
- "packs/*/spec/**/*" # Because of automatic namespacing
|
162
194
|
|
163
|
-
|
164
|
-
|
195
|
+
RSpec/HookArgument:
|
196
|
+
Exclude:
|
197
|
+
- "spec/support/**/*"
|
165
198
|
|
166
|
-
|
199
|
+
RSpec/IndexedLet:
|
167
200
|
Enabled: false
|
168
201
|
|
169
|
-
|
202
|
+
RSpec/InstanceVariable:
|
203
|
+
Exclude:
|
204
|
+
- "spec/workers/salesforce/**/*"
|
205
|
+
- "spec/views/**/*"
|
206
|
+
- "spec/services/salesforce/**/*"
|
207
|
+
- "spec/controllers/salesforce_controller_spec.rb"
|
208
|
+
- "spec/controllers/v1/**/*"
|
209
|
+
|
210
|
+
RSpec/LetSetup:
|
170
211
|
Enabled: false
|
171
212
|
|
172
|
-
|
173
|
-
# This rule is incompatible with our split schema for datawarehouse models
|
174
|
-
# It is disabled by default in rubocop-rails
|
213
|
+
RSpec/MessageSpies:
|
175
214
|
Enabled: false
|
176
215
|
|
177
|
-
|
216
|
+
RSpec/MultipleExpectations:
|
178
217
|
Exclude:
|
179
|
-
- "spec/**/*"
|
218
|
+
- "spec/system/**/*"
|
219
|
+
Max: 5
|
220
|
+
|
221
|
+
RSpec/MultipleMemoizedHelpers:
|
222
|
+
Enabled: false
|
180
223
|
|
181
224
|
RSpec/NestedGroups:
|
182
|
-
Max: 6
|
183
225
|
Exclude:
|
184
226
|
- "spec/controllers/**/*"
|
185
227
|
- "spec/requests/**/*"
|
228
|
+
Max: 6
|
186
229
|
|
187
|
-
RSpec/
|
188
|
-
Max: 5
|
189
|
-
Exclude:
|
190
|
-
- "spec/system/**/*"
|
191
|
-
|
192
|
-
RSpec/ExampleLength:
|
193
|
-
Max: 30
|
194
|
-
Exclude:
|
195
|
-
- "spec/lib/props_module_spec.rb"
|
196
|
-
- "spec/system/**/*"
|
197
|
-
- "spec/serializers/**/*"
|
198
|
-
|
199
|
-
RSpec/AnyInstance:
|
230
|
+
RSpec/ReceiveMessages:
|
200
231
|
Enabled: false
|
201
232
|
|
202
|
-
RSpec/
|
233
|
+
RSpec/SortMetadata:
|
203
234
|
Enabled: false
|
204
235
|
|
236
|
+
RSpec/SpecFilePathFormat:
|
237
|
+
Enabled: true
|
238
|
+
Exclude:
|
239
|
+
- "packs/*/spec/**/*" # Because of automatic namespacing
|
240
|
+
|
241
|
+
RSpec/VariableName:
|
242
|
+
AllowedPatterns:
|
243
|
+
- "Authorization" # used in RSwag specs
|
244
|
+
|
205
245
|
RSpec/VerifiedDoubles:
|
206
246
|
IgnoreSymbolicNames: true
|
207
247
|
|
208
|
-
|
248
|
+
RSpecRails/InferredSpecType:
|
249
|
+
Enabled: false
|
250
|
+
|
251
|
+
Rails/ApplicationRecord:
|
209
252
|
Exclude:
|
210
|
-
- "
|
211
|
-
- "db/**/*"
|
253
|
+
- "db/migrate/*"
|
212
254
|
|
213
|
-
|
255
|
+
Rails/BulkChangeTable:
|
214
256
|
Enabled: false
|
215
257
|
|
216
|
-
|
258
|
+
Rails/CreateTableWithTimestamps:
|
217
259
|
Enabled: false
|
218
260
|
|
219
|
-
Rails/
|
220
|
-
|
221
|
-
- "db/seeds/**/*"
|
222
|
-
|
223
|
-
RSpec/EmptyExampleGroup:
|
224
|
-
Exclude:
|
225
|
-
- "spec/api/**/*"
|
226
|
-
|
227
|
-
RSpec/DescribeClass:
|
228
|
-
Exclude:
|
229
|
-
- "spec/api/**/*"
|
230
|
-
- "spec/views/**/*"
|
231
|
-
- "spec/lib/tasks/**/*"
|
261
|
+
Rails/FindEach:
|
262
|
+
Enabled: false
|
232
263
|
|
233
|
-
Rails/
|
234
|
-
|
235
|
-
- "db/migrate/*"
|
264
|
+
Rails/I18nLocaleTexts:
|
265
|
+
Enabled: false
|
236
266
|
|
237
|
-
|
267
|
+
Rails/Output:
|
238
268
|
Exclude:
|
239
|
-
- "
|
269
|
+
- "db/seeds/**/*"
|
240
270
|
|
241
|
-
|
271
|
+
Rails/SkipsModelValidations:
|
242
272
|
Exclude:
|
243
|
-
- "spec
|
244
|
-
- "
|
245
|
-
- "spec/services/salesforce/**/*"
|
246
|
-
- "spec/controllers/salesforce_controller_spec.rb"
|
247
|
-
- "spec/controllers/v1/**/*"
|
248
|
-
|
249
|
-
Rails/BulkChangeTable:
|
250
|
-
Enabled: false
|
273
|
+
- "spec/**/*"
|
274
|
+
- "db/**/*"
|
251
275
|
|
252
|
-
Rails/
|
276
|
+
Rails/TimeZone:
|
253
277
|
Enabled: false
|
254
278
|
|
255
279
|
Rails/UnknownEnv:
|
@@ -261,54 +285,33 @@ Rails/UnknownEnv:
|
|
261
285
|
- production
|
262
286
|
- test
|
263
287
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
Style/MultilineBlockChain:
|
288
|
+
Rails/UnusedIgnoredColumns:
|
289
|
+
# This rule is incompatible with our split schema for datawarehouse models
|
290
|
+
# It is disabled by default in rubocop-rails
|
268
291
|
Enabled: false
|
269
292
|
|
270
|
-
|
271
|
-
EnforcedStyle:
|
272
|
-
AllowedIdentifiers:
|
273
|
-
- is_501c3
|
274
|
-
- last4
|
275
|
-
- line1
|
276
|
-
- line2
|
277
|
-
- address_line1
|
278
|
-
- address_line2
|
279
|
-
- google_oauth2
|
280
|
-
- s3
|
281
|
-
- shift4
|
282
|
-
- Shift4
|
293
|
+
Style/Alias:
|
294
|
+
EnforcedStyle: prefer_alias_method
|
283
295
|
|
284
|
-
|
296
|
+
Style/AsciiComments:
|
285
297
|
Enabled: false
|
286
298
|
|
287
|
-
|
288
|
-
|
299
|
+
Style/ClassAndModuleChildren:
|
300
|
+
Exclude:
|
301
|
+
- "app/controllers/smart_donations_legacy/**/*"
|
289
302
|
|
290
|
-
|
303
|
+
Style/Documentation:
|
291
304
|
Enabled: false
|
292
305
|
|
293
|
-
|
306
|
+
Style/FrozenStringLiteralComment:
|
294
307
|
Enabled: false
|
295
308
|
|
296
|
-
|
297
|
-
Enabled: true
|
298
|
-
Exclude:
|
299
|
-
- "packs/*/spec/**/*" # Because of automatic namespacing
|
300
|
-
|
301
|
-
RSpec/SpecFilePathFormat:
|
302
|
-
Enabled: true
|
309
|
+
Style/GlobalVars:
|
303
310
|
Exclude:
|
304
|
-
- "
|
305
|
-
|
306
|
-
RSpec/VariableName:
|
307
|
-
AllowedPatterns:
|
308
|
-
- "Authorization" # used in RSwag specs
|
311
|
+
- "spec/**/*"
|
309
312
|
|
310
|
-
|
311
|
-
|
313
|
+
Style/HashAsLastArrayItem:
|
314
|
+
Enabled: false
|
312
315
|
|
313
|
-
|
314
|
-
|
316
|
+
Style/MultilineBlockChain:
|
317
|
+
Enabled: false
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module GLRubocop
|
2
2
|
module GLCops
|
3
3
|
class InteractorInheritsFromInteractorBase < RuboCop::Cop::Cop
|
4
|
+
MSG = 'Interactor should inherit from InteractorBase'.freeze
|
5
|
+
|
4
6
|
def on_class(klass)
|
5
7
|
return unless klass.instance_of?(RuboCop::AST::ClassNode)
|
6
8
|
return unless klass.parent_class.nil?
|
7
9
|
|
8
10
|
add_offense(klass)
|
9
11
|
end
|
10
|
-
|
11
|
-
MSG = 'Interactor should inherit from InteractorBase'.freeze
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module GLRubocop
|
2
|
+
module GLCops
|
3
|
+
# This cop ensures that you don't stub perform_async. Stubbing prevents seeing errors from
|
4
|
+
# invalid argumens - because sidekiq arguments have to be valid JSON data types:
|
5
|
+
# github.com/sidekiq/sidekiq/wiki/Best-Practices#1-make-your-job-parameters-small-and-simple
|
6
|
+
#
|
7
|
+
# Good:
|
8
|
+
# expect(ExampleWorker).to have_enqueued_sidekiq_job
|
9
|
+
|
10
|
+
#
|
11
|
+
# Bad:
|
12
|
+
# allow(ExampleWorker).to receive(:perform_async)
|
13
|
+
# expect(ExampleWorker).to receive(:perform_async)
|
14
|
+
# expect(SomeWorker).not_to have_received(:perform_in)
|
15
|
+
class NoStubbingPerformAsync < RuboCop::Cop::Cop
|
16
|
+
MSG = "Don't stub perform async. Use the rspec-sidekick matchers instead: " \
|
17
|
+
'expect(JobClass).to have_enqueued_sidekiq_job'.freeze
|
18
|
+
|
19
|
+
# This pattern captures expectations for perform_async and perform_in
|
20
|
+
# expect(SomeWorker).not_to have_received(:perform_async)
|
21
|
+
# expect(SomeWorker).to have_received(:perform_async)
|
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}) ...))
|
28
|
+
PATTERN
|
29
|
+
|
30
|
+
# This pattern captures allow statements for perform_async and perform_in
|
31
|
+
# allow(SomeWorker).to receive(:perform_async)
|
32
|
+
# allow(SomeWorker).to receive(:perform_in)
|
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}) ...))
|
38
|
+
PATTERN
|
39
|
+
|
40
|
+
def on_send(node)
|
41
|
+
check_expectation(node) || check_allow(node)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def check_expectation(node)
|
47
|
+
perform_method_expectation?(node) { return add_offense(node) }
|
48
|
+
|
49
|
+
false
|
50
|
+
end
|
51
|
+
|
52
|
+
def check_allow(node)
|
53
|
+
perform_method_allow?(node) { return add_offense(node) }
|
54
|
+
|
55
|
+
false
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module GLRubocop
|
2
2
|
module GLCops
|
3
3
|
class SidekiqInheritsFromSidekiqJob < RuboCop::Cop::Cop
|
4
|
+
MSG = 'All Sidekiq workers and jobs should inherit from SidekiqJob'.freeze
|
5
|
+
|
4
6
|
def on_class(klass)
|
5
7
|
return unless klass.instance_of?(RuboCop::AST::ClassNode)
|
6
8
|
return if klass.parent_class.present? || klass.identifier.short_name == :SidekiqJob
|
7
9
|
|
8
10
|
add_offense(klass)
|
9
11
|
end
|
10
|
-
|
11
|
-
MSG = 'All Sidekiq workers and jobs should inherit from SidekiqJob'.freeze
|
12
12
|
end
|
13
13
|
end
|
14
14
|
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.11
|
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-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- lib/gl_rubocop.rb
|
123
123
|
- lib/gl_rubocop/gl_cops/callback_method_names.rb
|
124
124
|
- lib/gl_rubocop/gl_cops/interactor_inherits_from_interactor_base.rb
|
125
|
+
- lib/gl_rubocop/gl_cops/no_stubbing_perform_async.rb
|
125
126
|
- lib/gl_rubocop/gl_cops/prevent_erb_files.rb
|
126
127
|
- lib/gl_rubocop/gl_cops/rails_cache.rb
|
127
128
|
- lib/gl_rubocop/gl_cops/sidekiq_inherits_from_sidekiq_job.rb
|