gl_rubocop 0.2.6 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc932e911296ebd58c3e59febe32b734287f3ac302762c807c7f2cf58cc1c3ea
4
- data.tar.gz: 9e9a20252ffcf744d7c8faf367f53f355e07dfcd9d8cb20f29a7d28401c5fd42
3
+ metadata.gz: 67a8ea79eaac3f32be89d377fe078231dd55f7d82231ee0f33b744f45d231290
4
+ data.tar.gz: eea890a130dcffab3e5e2e9aba977cf34fe436ab102df89ff880c5e001451662
5
5
  SHA512:
6
- metadata.gz: c1f6f481ca4275167ba6c630eaf558a83bd29cac26f6a777c8354dd0dff798c792f86eaded520dab8df616294cb6c0941477a2343abc4a13bdfa548bb021e7b7
7
- data.tar.gz: 3ef8ba758032a3623ebfe92fbc3cef16b4736b78e0875051ef1f158131f78bbf5b1cb8933ea12c78d4beb103c86d525e3f4ddd607e19d03cc69ea3bc331290d9
6
+ metadata.gz: 332497964856ab54d4c1c1e5185267f7ee040efa8e6b60e53edfda7fed18fd34eb0ae207a1c226c4aa004d23f8e89511792792c74148b33742ab5413d5a6d72c
7
+ data.tar.gz: 7f96dc1fcc9e4a175af46daaed4f55cb0b60db443278b7cdc0e495dbcd6ffeb0498723832acf16d1157e1e881f3bed64ed82203d86ed03a7503c1f646d804414
data/README.md CHANGED
@@ -1,2 +1,56 @@
1
1
  # gl_rubocop
2
+
2
3
  A shareable configuration of rules we use at Give Lively to lint our Ruby code.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'gl_rubocop', require: false
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```bash
16
+ bundle install
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```bash
22
+ gem install gl_lint
23
+ ```
24
+
25
+ And finally add this to the top of your project's RuboCop configuration file:
26
+
27
+ ```yml
28
+ inherit_gem:
29
+ gl_rubocop: default.yml
30
+ ```
31
+
32
+ Any `Include` or `Exclude` configuration provided will be merged with RuboCop's defaults.
33
+
34
+ For more information about inheriting configuration from a gem please check
35
+ [RuboCop's
36
+ documentation](https://docs.rubocop.org/rubocop/configuration.html#inheriting-configuration-from-a-dependency-gem).
37
+
38
+ ## Making changes and publishing
39
+
40
+ 1. As per our code agreements, all code changes to this gem are required to be made via pull request with final approval from at least one Give Lively engineer.
41
+
42
+ 2. When creating a pull request, ensure that your code changes include an update to the gem's [version number](https://github.com/givelively/gl_rubocop/blob/main/lib/gl_rubocop/version.rb) using [semantic versioning](https://semver.org/)
43
+
44
+ 3. After getting approval, merge your changes to `main`.
45
+
46
+ 4. Once your CI build finishes sucessfully, pull the latest version of `main` locally.
47
+
48
+ 5. Run the command `gem build`. This bundles the relevant files from the gem and prepares it to be published to [rubygems.org](https://rubygems.org/). (Note: if you are not one of the owners listed you may need to request that that this and the following step be completed by one of the gem owners listed in CODEOWNERS)
49
+
50
+ 6. Once the bundle is successfully created there should be a new file created locally that looks like `gl_rubocop-<new_gem_version_number>.gem`.
51
+
52
+ 7. Run the command `gem push gl_rubocop-<new_gem_version_number>.gem`.
53
+
54
+ 8. Following the authorization prompts listed by the gem command.
55
+
56
+ 9. Your changes have now been published to the rubygems registry.
data/default.yml CHANGED
@@ -4,6 +4,7 @@ require:
4
4
  - rubocop-rspec
5
5
  - rubocop-magic_numbers
6
6
  - rubocop-haml
7
+ - rubocop-rake
7
8
  - ./lib/gl_rubocop/gl_cops/interactor_inherits_from_interactor_base.rb
8
9
  - ./lib/gl_rubocop/gl_cops/callback_method_names.rb
9
10
  - ./lib/gl_rubocop/gl_cops/prevent_erb_files.rb
@@ -11,26 +12,25 @@ require:
11
12
  - ./lib/gl_rubocop/gl_cops/sidekiq_inherits_from_sidekiq_job.rb
12
13
  - ./lib/gl_rubocop/gl_cops/unique_identifier.rb
13
14
 
14
-
15
15
  AllCops:
16
16
  SuggestExtensions: false
17
17
  NewCops: enable
18
18
  Exclude:
19
- - 'config/**/*'
20
- - 'db/**/*'
21
- - 'log/**/*'
22
- - 'public/**/*'
23
- - 'spec/factories/**/*'
24
- - 'spec/support/**/*'
25
- - 'swagger/**/*'
26
- - 'tmp/**/*'
27
- - 'vendor/**/*'
28
- - 'bin/**/*'
19
+ - "config/**/*"
20
+ - "db/**/*"
21
+ - "log/**/*"
22
+ - "public/**/*"
23
+ - "spec/factories/**/*"
24
+ - "spec/support/**/*"
25
+ - "swagger/**/*"
26
+ - "tmp/**/*"
27
+ - "vendor/**/*"
28
+ - "bin/**/*"
29
29
 
30
30
  GLCops/InteractorInheritsFromInteractorBase:
31
31
  Enabled: true
32
32
  Include:
33
- - 'app/interactors/**/*'
33
+ - "app/interactors/**/*"
34
34
 
35
35
  GLCops/CallbackMethodNames:
36
36
  Enabled: true
@@ -43,88 +43,96 @@ GLCops/RailsCache:
43
43
 
44
44
  GLCops/SidekiqInheritsFromSidekiqJob:
45
45
  Include:
46
- - 'app/**/*_worker.rb'
47
- - 'app/**/*_job.rb'
46
+ - "app/**/*_worker.rb"
47
+ - "app/**/*_job.rb"
48
48
 
49
49
  GLCops/UniqueIdentifier:
50
50
  Enabled: true
51
51
  Include:
52
- - 'app/components/**/*.haml'
52
+ - "app/components/**/*.haml"
53
53
 
54
54
  Layout/LineLength:
55
55
  Max: 100
56
56
  AllowedPatterns:
57
- - '^ *#' # Ignores full lines starting with any indentation and a comment (#)
57
+ - "^ *#" # Ignores full lines starting with any indentation and a comment (#)
58
58
 
59
59
  Lint/MissingSuper:
60
60
  Exclude:
61
- - 'app/components/**/*'
61
+ - "app/components/**/*"
62
62
 
63
63
  MagicNumbers/NoAssignment:
64
+ Exclude:
65
+ - "/spec/**/*"
64
66
  Enabled: false
65
67
  AllowedAssignments:
66
68
  - instance_variables
67
69
  - class_variables
68
70
  - global_variables
69
71
 
70
- MagicNumbers/NoArgument:
72
+ MagicNumbers/NoArgument:
73
+ Exclude:
74
+ - "/spec/**/*"
71
75
  Enabled: true
72
76
  PermittedValues:
73
- - 0
74
- - 1
77
+ - 0
78
+ - 1
75
79
 
76
80
  MagicNumbers/NoDefault:
81
+ Exclude:
82
+ - "/spec/**/*"
77
83
  Enabled: true
78
84
  PermittedValues:
79
- - 0
80
- - 1
85
+ - 0
86
+ - 1
81
87
 
82
88
  MagicNumbers/NoReturn:
89
+ Exclude:
90
+ - "/spec/**/*"
83
91
  Enabled: true
84
92
  PermittedReturnValues:
85
- - 0
86
- - 1
93
+ - 0
94
+ - 1
87
95
 
88
96
  Metrics/AbcSize:
89
97
  Max: 17
90
98
  Exclude:
91
- - 'db/**/*'
92
- - 'spec/**/*'
93
- - 'config/routes.rb'
94
- - 'config/routes/*'
99
+ - "db/**/*"
100
+ - "spec/**/*"
101
+ - "config/routes.rb"
102
+ - "config/routes/*"
95
103
 
96
104
  Metrics/MethodLength:
97
105
  Max: 15
98
106
  Exclude:
99
- - 'app/mailers/**/*'
100
- - 'config/routes/**/*'
101
- - 'db/**/*'
102
- - 'lib/tasks/**/*'
107
+ - "app/mailers/**/*"
108
+ - "config/routes/**/*"
109
+ - "db/**/*"
110
+ - "lib/tasks/**/*"
103
111
 
104
112
  Metrics/BlockLength:
105
113
  Exclude:
106
- - 'app/admin/**/*'
107
- - 'db/**/*'
108
- - 'config/routes/*'
109
- - 'config/coverband.rb'
110
- - 'spec/**/*'
114
+ - "app/admin/**/*"
115
+ - "db/**/*"
116
+ - "config/routes/*"
117
+ - "config/coverband.rb"
118
+ - "spec/**/*"
111
119
 
112
120
  Metrics/ClassLength:
113
121
  Max: 150
114
122
  Exclude:
115
- - 'db/seeds/**/*'
123
+ - "db/seeds/**/*"
116
124
 
117
125
  Metrics/CyclomaticComplexity:
118
126
  Exclude:
119
- - 'db/seeds/**/*'
127
+ - "db/seeds/**/*"
120
128
 
121
129
  Metrics/PerceivedComplexity:
122
130
  Exclude:
123
- - 'db/seeds/**/*'
131
+ - "db/seeds/**/*"
124
132
 
125
133
  Metrics/ParameterLists:
126
134
  Exclude:
127
- - 'db/seeds/**/*'
135
+ - "db/seeds/**/*"
128
136
 
129
137
  Performance/MapCompact:
130
138
  Enabled: false
@@ -140,7 +148,7 @@ Naming/MethodParameterName:
140
148
 
141
149
  Style/ClassAndModuleChildren:
142
150
  Exclude:
143
- - 'app/controllers/smart_donations_legacy/**/*'
151
+ - "app/controllers/smart_donations_legacy/**/*"
144
152
 
145
153
  Style/Documentation:
146
154
  Enabled: false
@@ -157,27 +165,32 @@ Rails/FindEach:
157
165
  Rails/I18nLocaleTexts:
158
166
  Enabled: false
159
167
 
168
+ Rails/UnusedIgnoredColumns:
169
+ # This rule is incompatible with our split schema for datawarehouse models
170
+ # It is disabled by default in rubocop-rails
171
+ Enabled: false
172
+
160
173
  Style/GlobalVars:
161
174
  Exclude:
162
- - 'spec/**/*'
175
+ - "spec/**/*"
163
176
 
164
177
  RSpec/NestedGroups:
165
178
  Max: 6
166
179
  Exclude:
167
- - 'spec/controllers/**/*'
168
- - 'spec/requests/**/*'
180
+ - "spec/controllers/**/*"
181
+ - "spec/requests/**/*"
169
182
 
170
183
  RSpec/MultipleExpectations:
171
184
  Max: 5
172
185
  Exclude:
173
- - 'spec/system/**/*'
186
+ - "spec/system/**/*"
174
187
 
175
188
  RSpec/ExampleLength:
176
189
  Max: 30
177
190
  Exclude:
178
- - 'spec/lib/props_module_spec.rb'
179
- - 'spec/system/**/*'
180
- - 'spec/serializers/**/*'
191
+ - "spec/lib/props_module_spec.rb"
192
+ - "spec/system/**/*"
193
+ - "spec/serializers/**/*"
181
194
 
182
195
  RSpec/AnyInstance:
183
196
  Enabled: false
@@ -190,8 +203,8 @@ RSpec/VerifiedDoubles:
190
203
 
191
204
  Rails/SkipsModelValidations:
192
205
  Exclude:
193
- - 'spec/**/*'
194
- - 'db/**/*'
206
+ - "spec/**/*"
207
+ - "db/**/*"
195
208
 
196
209
  RSpec/MessageSpies:
197
210
  Enabled: false
@@ -201,33 +214,33 @@ RSpec/LetSetup:
201
214
 
202
215
  Rails/Output:
203
216
  Exclude:
204
- - 'db/seeds/**/*'
217
+ - "db/seeds/**/*"
205
218
 
206
219
  RSpec/EmptyExampleGroup:
207
220
  Exclude:
208
- - 'spec/api/**/*'
221
+ - "spec/api/**/*"
209
222
 
210
223
  RSpec/DescribeClass:
211
224
  Exclude:
212
- - 'spec/api/**/*'
213
- - 'spec/views/**/*'
214
- - 'spec/lib/tasks/**/*'
225
+ - "spec/api/**/*"
226
+ - "spec/views/**/*"
227
+ - "spec/lib/tasks/**/*"
215
228
 
216
229
  Rails/ApplicationRecord:
217
230
  Exclude:
218
- - 'db/migrate/*'
231
+ - "db/migrate/*"
219
232
 
220
233
  RSpec/HookArgument:
221
234
  Exclude:
222
- - 'spec/support/**/*'
235
+ - "spec/support/**/*"
223
236
 
224
237
  RSpec/InstanceVariable:
225
238
  Exclude:
226
- - 'spec/workers/salesforce/**/*'
227
- - 'spec/views/**/*'
228
- - 'spec/services/salesforce/**/*'
229
- - 'spec/controllers/salesforce_controller_spec.rb'
230
- - 'spec/controllers/v1/**/*'
239
+ - "spec/workers/salesforce/**/*"
240
+ - "spec/views/**/*"
241
+ - "spec/services/salesforce/**/*"
242
+ - "spec/controllers/salesforce_controller_spec.rb"
243
+ - "spec/controllers/v1/**/*"
231
244
 
232
245
  Rails/BulkChangeTable:
233
246
  Enabled: false
@@ -251,7 +264,7 @@ Style/MultilineBlockChain:
251
264
  Enabled: false
252
265
 
253
266
  Naming/VariableNumber:
254
- EnforcedStyle: 'snake_case'
267
+ EnforcedStyle: "snake_case"
255
268
  AllowedIdentifiers:
256
269
  - is_501c3
257
270
  - last4
@@ -279,16 +292,16 @@ RSpec/IndexedLet:
279
292
  RSpec/FilePath:
280
293
  Enabled: true
281
294
  Exclude:
282
- - 'packs/*/spec/**/*' # Because of automatic namespacing
295
+ - "packs/*/spec/**/*" # Because of automatic namespacing
283
296
 
284
297
  RSpec/SpecFilePathFormat:
285
298
  Enabled: true
286
299
  Exclude:
287
- - 'packs/*/spec/**/*' # Because of automatic namespacing
300
+ - "packs/*/spec/**/*" # Because of automatic namespacing
288
301
 
289
302
  RSpec/VariableName:
290
303
  AllowedPatterns:
291
- - 'Authorization' # used in RSwag specs
304
+ - "Authorization" # used in RSwag specs
292
305
 
293
306
  Capybara/ClickLinkOrButtonStyle:
294
307
  EnforcedStyle: link_or_button
data/gl_rubocop.gemspec CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ['lib']
27
27
 
28
- spec.add_dependency 'rubocop', '~> 1.62.0'
28
+ spec.add_dependency 'rubocop', '~> 1.62.1'
29
29
  spec.add_dependency 'rubocop-haml', '~> 0.2.4'
30
30
  spec.add_dependency 'rubocop-magic_numbers'
31
31
  spec.add_dependency 'rubocop-performance'
@@ -4,10 +4,12 @@ module GLRubocop
4
4
  # This cop ensures that view components include a data-test-id attribute.
5
5
  #
6
6
  # Good:
7
- # {data-test-id: "unique-id"}
7
+ # {data-test-id: 'unique-id'}
8
8
  # {data-test-id: @unique_id }
9
- # {'data-test-id': "unique-id"}
9
+ # {'data-test-id': 'unique-id'}
10
10
  # {"data-test-id": "unique-id"}
11
+ # {data: {test-id: 'unique-id'}}
12
+ # {data: {'test-id': 'unique-id'}}
11
13
  #
12
14
  # Bad:
13
15
  # {data: {testId: "unique-id"}}
@@ -15,7 +17,7 @@ module GLRubocop
15
17
 
16
18
  MSG = 'View components must include a data-test-id attribute'.freeze
17
19
  EMPTY_MSG = 'data-test-id attribute must not be empty'.freeze
18
- UNIQUE_IDENTIFIER = 'data-test-id'.freeze
20
+ UNIQUE_IDENTIFIER = 'test-id'.freeze
19
21
 
20
22
  def on_send(node)
21
23
  return unless file_exists? && valid_method_name?(node)
@@ -42,7 +44,7 @@ module GLRubocop
42
44
 
43
45
  def regex_for_indentifier_and_value
44
46
  key = Regexp.quote(UNIQUE_IDENTIFIER)
45
- /(?:#{key}|["']#{key}["']):\s*(["']([^"']*)["']|@\w+)/
47
+ /(?:["']?data-#{key}["']?|data:.?\{["']?#{key}["']?):\s*(["']([^"']*)["']|@\w+)/
46
48
  end
47
49
 
48
50
  def test_id_value
@@ -1,3 +1,3 @@
1
1
  module GLRubocop
2
- VERSION = '0.2.6'.freeze
2
+ VERSION = '0.2.8'.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.6
4
+ version: 0.2.8
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-01-17 00:00:00.000000000 Z
11
+ date: 2025-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.62.0
19
+ version: 1.62.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.62.0
26
+ version: 1.62.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rubocop-haml
29
29
  requirement: !ruby/object:Gem::Requirement