gl_rubocop 0.2.9 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 598723d7094caaf313991dbda2d2d84e210756dcda15448be93911d49f2ba35d
4
- data.tar.gz: 636eed90643e40868de9e50a0ffd1207f5618280e0012451b35ed25e03389242
3
+ metadata.gz: 19d65dcff9ece63e91e4214d0c4fb6bab5588c4ee97bdc1ef241ca32a3d9afb1
4
+ data.tar.gz: 96844a8560bce6c4b2d4a2a313f3f3c39625110a3abff73589c56787c171843d
5
5
  SHA512:
6
- metadata.gz: 535039fab4b2b6e6681e6ff7f846de2163284540292102fe1926132063653d22e62e200c8cfbfd3c64bc684a16be078805098a7ebf3fec4028135da9ad9141cb
7
- data.tar.gz: 2d7a66f9fa41fee0ea58d2cb0ff3cc5a942068d464413df9b080704f8223cd833cb26de8f2788d620b494461329a2fff9e9006202d014e1be8e4bc04337a1adb
6
+ metadata.gz: fa74fd13e08edc286e3009a6f66fa42e9b47a81c592708f29a3c1f8085e55e39c8b11d1d7166387864e95706a2bbc271b403dd9e34e05a0082874462e8278565
7
+ data.tar.gz: f8aebf2e5be28e44d38e92a8cd083ae9e7768e0105e31e63b989e5d90e3ece00fd494112b7af4fb865e1e3f48ad2ef4e1a20a77141027899b0be36798946da05
data/README.md CHANGED
@@ -54,3 +54,31 @@ documentation](https://docs.rubocop.org/rubocop/configuration.html#inheriting-co
54
54
  8. Following the authorization prompts listed by the gem command.
55
55
 
56
56
  9. Your changes have now been published to the rubygems registry.
57
+
58
+ ## Testing Locally
59
+ It's likely the case you'll want to test your changes locally before opening a PR, getting approval, and publishing the gem.
60
+
61
+ To do so, complete the following steps:
62
+
63
+ 1. Save the changes to whichever files you have modified.
64
+
65
+ 2. Run the command `gem build` to create the bundle (this may require you to have bumped the version number)
66
+
67
+ 3. Go to the Gemfile in whichever ruby-based repo you want to test your rubocop changes against
68
+
69
+ 4. Create an entry for gl_rubocop specifiying the *relative* path to your local `gl_rubocop` repo (ex. `../code/gl_rubocop`):
70
+
71
+ ```ruby
72
+ gem 'gl_rubocop', '~> 0.2.9', path: '../path/to/your/local/gl_rubocop'
73
+ ```
74
+
75
+ 5. Within the same repo as the Gemfile you just updated run `bundle install`
76
+
77
+ 6. Finally add the following lines to your rubocop configuration file
78
+
79
+ ```yml
80
+ inherit_gem:
81
+ gl_rubocop: default.yml
82
+ ```
83
+
84
+ 7. Now you can test your rubocop changes local with the target repo.
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,63 +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/NoAssignment:
72
+ MagicNumbers/NoArgument:
73
+ Enabled: true
64
74
  Exclude:
65
75
  - "spec/**/*"
66
- Enabled: false
76
+ - "**/spec/**/*"
77
+ PermittedValues:
78
+ - 0
79
+ - 1
80
+
81
+ MagicNumbers/NoAssignment:
67
82
  AllowedAssignments:
68
83
  - instance_variables
69
84
  - class_variables
70
85
  - global_variables
71
-
72
- MagicNumbers/NoArgument:
86
+ Enabled: false
73
87
  Exclude:
74
88
  - "spec/**/*"
75
- Enabled: true
76
- PermittedValues:
77
- - 0
78
- - 1
89
+ - "**/spec/**/*"
79
90
 
80
91
  MagicNumbers/NoDefault:
92
+ Enabled: true
81
93
  Exclude:
82
94
  - "spec/**/*"
83
- Enabled: true
95
+ - "**/spec/**/*"
84
96
  PermittedValues:
85
97
  - 0
86
98
  - 1
87
99
 
88
100
  MagicNumbers/NoReturn:
101
+ Enabled: true
89
102
  Exclude:
90
103
  - "spec/**/*"
91
- Enabled: true
104
+ - "**/spec/**/*"
92
105
  PermittedReturnValues:
93
106
  - 0
94
107
  - 1
95
108
 
96
109
  Metrics/AbcSize:
97
- Max: 17
98
110
  Exclude:
99
111
  - "db/**/*"
100
112
  - "spec/**/*"
101
113
  - "config/routes.rb"
102
114
  - "config/routes/*"
103
-
104
- Metrics/MethodLength:
105
- Max: 15
106
- Exclude:
107
- - "app/mailers/**/*"
108
- - "config/routes/**/*"
109
- - "db/**/*"
110
- - "lib/tasks/**/*"
115
+ Max: 17
111
116
 
112
117
  Metrics/BlockLength:
113
118
  Exclude:
@@ -118,134 +123,157 @@ Metrics/BlockLength:
118
123
  - "spec/**/*"
119
124
 
120
125
  Metrics/ClassLength:
121
- Max: 150
122
126
  Exclude:
123
127
  - "db/seeds/**/*"
128
+ Max: 150
124
129
 
125
130
  Metrics/CyclomaticComplexity:
126
131
  Exclude:
127
132
  - "db/seeds/**/*"
128
133
 
129
- Metrics/PerceivedComplexity:
134
+ Metrics/MethodLength:
130
135
  Exclude:
131
- - "db/seeds/**/*"
136
+ - "app/mailers/**/*"
137
+ - "config/routes/**/*"
138
+ - "db/**/*"
139
+ - "lib/tasks/**/*"
140
+ Max: 15
132
141
 
133
142
  Metrics/ParameterLists:
134
143
  Exclude:
135
144
  - "db/seeds/**/*"
136
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
+
137
167
  Performance/MapCompact:
138
168
  Enabled: false
139
169
 
140
- Style/Alias:
141
- EnforcedStyle: prefer_alias_method
142
-
143
- Style/AsciiComments:
170
+ RSpec/AnyInstance:
144
171
  Enabled: false
145
172
 
146
- Naming/MethodParameterName:
147
- MinNameLength: 1
173
+ RSpec/DescribeClass:
174
+ Exclude:
175
+ - "spec/api/**/*"
176
+ - "spec/views/**/*"
177
+ - "spec/lib/tasks/**/*"
148
178
 
149
- Style/ClassAndModuleChildren:
179
+ RSpec/EmptyExampleGroup:
150
180
  Exclude:
151
- - "app/controllers/smart_donations_legacy/**/*"
181
+ - "spec/api/**/*"
152
182
 
153
- Style/Documentation:
154
- Enabled: false
183
+ RSpec/ExampleLength:
184
+ Exclude:
185
+ - "spec/lib/props_module_spec.rb"
186
+ - "spec/system/**/*"
187
+ - "spec/serializers/**/*"
188
+ Max: 30
155
189
 
156
- Style/FrozenStringLiteralComment:
157
- Enabled: false
190
+ RSpec/FilePath:
191
+ Enabled: true
192
+ Exclude:
193
+ - "packs/*/spec/**/*" # Because of automatic namespacing
158
194
 
159
- Rails/TimeZone:
160
- Enabled: false
195
+ RSpec/HookArgument:
196
+ Exclude:
197
+ - "spec/support/**/*"
161
198
 
162
- Rails/FindEach:
199
+ RSpec/IndexedLet:
163
200
  Enabled: false
164
201
 
165
- Rails/I18nLocaleTexts:
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:
166
211
  Enabled: false
167
212
 
168
- Rails/UnusedIgnoredColumns:
169
- # This rule is incompatible with our split schema for datawarehouse models
170
- # It is disabled by default in rubocop-rails
213
+ RSpec/MessageSpies:
171
214
  Enabled: false
172
215
 
173
- Style/GlobalVars:
216
+ RSpec/MultipleExpectations:
174
217
  Exclude:
175
- - "spec/**/*"
218
+ - "spec/system/**/*"
219
+ Max: 5
220
+
221
+ RSpec/MultipleMemoizedHelpers:
222
+ Enabled: false
176
223
 
177
224
  RSpec/NestedGroups:
178
- Max: 6
179
225
  Exclude:
180
226
  - "spec/controllers/**/*"
181
227
  - "spec/requests/**/*"
228
+ Max: 6
182
229
 
183
- RSpec/MultipleExpectations:
184
- Max: 5
185
- Exclude:
186
- - "spec/system/**/*"
187
-
188
- RSpec/ExampleLength:
189
- Max: 30
190
- Exclude:
191
- - "spec/lib/props_module_spec.rb"
192
- - "spec/system/**/*"
193
- - "spec/serializers/**/*"
194
-
195
- RSpec/AnyInstance:
230
+ RSpec/ReceiveMessages:
196
231
  Enabled: false
197
232
 
198
- RSpec/ReceiveMessages:
233
+ RSpec/SortMetadata:
199
234
  Enabled: false
200
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
+
201
245
  RSpec/VerifiedDoubles:
202
246
  IgnoreSymbolicNames: true
203
247
 
204
- Rails/SkipsModelValidations:
248
+ RSpecRails/InferredSpecType:
249
+ Enabled: false
250
+
251
+ Rails/ApplicationRecord:
205
252
  Exclude:
206
- - "spec/**/*"
207
- - "db/**/*"
253
+ - "db/migrate/*"
208
254
 
209
- RSpec/MessageSpies:
255
+ Rails/BulkChangeTable:
210
256
  Enabled: false
211
257
 
212
- RSpec/LetSetup:
258
+ Rails/CreateTableWithTimestamps:
213
259
  Enabled: false
214
260
 
215
- Rails/Output:
216
- Exclude:
217
- - "db/seeds/**/*"
218
-
219
- RSpec/EmptyExampleGroup:
220
- Exclude:
221
- - "spec/api/**/*"
222
-
223
- RSpec/DescribeClass:
224
- Exclude:
225
- - "spec/api/**/*"
226
- - "spec/views/**/*"
227
- - "spec/lib/tasks/**/*"
261
+ Rails/FindEach:
262
+ Enabled: false
228
263
 
229
- Rails/ApplicationRecord:
230
- Exclude:
231
- - "db/migrate/*"
264
+ Rails/I18nLocaleTexts:
265
+ Enabled: false
232
266
 
233
- RSpec/HookArgument:
267
+ Rails/Output:
234
268
  Exclude:
235
- - "spec/support/**/*"
269
+ - "db/seeds/**/*"
236
270
 
237
- RSpec/InstanceVariable:
271
+ Rails/SkipsModelValidations:
238
272
  Exclude:
239
- - "spec/workers/salesforce/**/*"
240
- - "spec/views/**/*"
241
- - "spec/services/salesforce/**/*"
242
- - "spec/controllers/salesforce_controller_spec.rb"
243
- - "spec/controllers/v1/**/*"
244
-
245
- Rails/BulkChangeTable:
246
- Enabled: false
273
+ - "spec/**/*"
274
+ - "db/**/*"
247
275
 
248
- Rails/CreateTableWithTimestamps:
276
+ Rails/TimeZone:
249
277
  Enabled: false
250
278
 
251
279
  Rails/UnknownEnv:
@@ -257,54 +285,33 @@ Rails/UnknownEnv:
257
285
  - production
258
286
  - test
259
287
 
260
- Style/HashAsLastArrayItem:
261
- Enabled: false
262
-
263
- 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
264
291
  Enabled: false
265
292
 
266
- Naming/VariableNumber:
267
- EnforcedStyle: "snake_case"
268
- AllowedIdentifiers:
269
- - is_501c3
270
- - last4
271
- - line1
272
- - line2
273
- - address_line1
274
- - address_line2
275
- - google_oauth2
276
- - s3
277
- - shift4
278
- - Shift4
293
+ Style/Alias:
294
+ EnforcedStyle: prefer_alias_method
279
295
 
280
- RSpec/MultipleMemoizedHelpers:
296
+ Style/AsciiComments:
281
297
  Enabled: false
282
298
 
283
- RSpecRails/InferredSpecType:
284
- Enabled: false
299
+ Style/ClassAndModuleChildren:
300
+ Exclude:
301
+ - "app/controllers/smart_donations_legacy/**/*"
285
302
 
286
- RSpec/SortMetadata:
303
+ Style/Documentation:
287
304
  Enabled: false
288
305
 
289
- RSpec/IndexedLet:
306
+ Style/FrozenStringLiteralComment:
290
307
  Enabled: false
291
308
 
292
- RSpec/FilePath:
293
- Enabled: true
294
- Exclude:
295
- - "packs/*/spec/**/*" # Because of automatic namespacing
296
-
297
- RSpec/SpecFilePathFormat:
298
- Enabled: true
309
+ Style/GlobalVars:
299
310
  Exclude:
300
- - "packs/*/spec/**/*" # Because of automatic namespacing
301
-
302
- RSpec/VariableName:
303
- AllowedPatterns:
304
- - "Authorization" # used in RSwag specs
311
+ - "spec/**/*"
305
312
 
306
- Capybara/ClickLinkOrButtonStyle:
307
- EnforcedStyle: link_or_button
313
+ Style/HashAsLastArrayItem:
314
+ Enabled: false
308
315
 
309
- Capybara/NegationMatcher:
310
- EnforcedStyle: not_to
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
@@ -1,3 +1,3 @@
1
1
  module GLRubocop
2
- VERSION = '0.2.9'.freeze
2
+ VERSION = '0.2.11'.freeze
3
3
  end
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.9
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-02-20 00:00:00.000000000 Z
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