ezcater_rubocop 2.3.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.tool-versions +1 -0
- data/CHANGELOG.md +34 -0
- data/conf/rubocop.yml +204 -18
- data/conf/rubocop_rails.yml +1 -0
- data/config/default.yml +15 -15
- data/ezcater_rubocop.gemspec +3 -3
- data/lib/ezcater_rubocop/version.rb +1 -1
- data/lib/rubocop/cop/ezcater/feature_flag_active.rb +16 -2
- data/lib/rubocop/cop/ezcater/graphql_fields_naming.rb +2 -2
- data/lib/rubocop/cop/ezcater/rspec_dot_not_self_dot.rb +28 -12
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32ed01c4904b105bcd1ac2b3b8871485448284bffe06dc6b90fda19775748175
|
4
|
+
data.tar.gz: 19755e3e83359f473ff961e1679c39b1bdb5f6d78a9c78e3ca6118be344c8400
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c215237f6c8fc40398c3947944261a457a2fc3efbebb51bc3e01ba743a3a4ad099a1a3ecfcc2782c056a78df6231b5bc0c258e0fa0f7ab8fd04e13be9ad26f79
|
7
|
+
data.tar.gz: f5066524144f916ff5d56c4aa320d916d4ed383b4eee01d20db2809a67eb2ed65bdf541709b8c0c9cec36a977a6ff9c92704564dacd7e9726a5b99bf02c0fffc
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.7.3
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,40 @@ This gem is moving onto its own [Semantic Versioning](https://semver.org/) schem
|
|
6
6
|
|
7
7
|
Prior to v1.0.0 this gem was versioned based on the `MAJOR`.`MINOR` version of RuboCop. The first release of the ezcater_rubocop gem was `v0.49.0`.
|
8
8
|
|
9
|
+
## v3.0.1
|
10
|
+
- Fix the RspecDotNotSelfDot cop to work with rubocop-rspec
|
11
|
+
- Exclude appraisal generated gemfiles for possible embedded gems in rails apps
|
12
|
+
|
13
|
+
## v3.0.0
|
14
|
+
|
15
|
+
- Upgrade rubocop: 1.16.0
|
16
|
+
- Upgrade rubocop-rails: 2.10.1
|
17
|
+
- Upgrade rubocop-rspec: 2.3.0
|
18
|
+
- This is a major upgrade because a large number of cops have been introduced, tweaked, or renamed. Here is an aggregate of the breaking changes introduced
|
19
|
+
- RuboCop assumes that Cop classes do not define new `on_<type>` methods at runtime (e.g. via `extend` in `initialize`).
|
20
|
+
- Enable all pending cops for RuboCop 1.0.
|
21
|
+
- Change logic for cop department name computation. Cops inside deep namespaces (5 or more levels deep) now belong to departments with names that are calculated by joining module names starting from the third one with slashes as separators. For example, cop `Rubocop::Cop::Foo::Bar::Baz` now belongs to `Foo/Bar` department (previously it was `Bar`).
|
22
|
+
- `RegexpNode#parsed_tree` now processes regexps including interpolation (by blanking the interpolation before parsing, rather than skipping).
|
23
|
+
- Cop `Metrics/AbcSize` now counts ||=, &&=, multiple assignments, for, yield, iterating blocks. `&.` now count as conditions too (unless repeated on the same variable). Default bumped from 15 to 17. Consider using `rubocop -a --disable-uncorrectable` to ease transition.
|
24
|
+
- Cop `Metrics/PerceivedComplexity` now counts `else` in `case` statements, `&.`, `||=`, `&&=` and blocks known to iterate. Default bumped from 7 to 8. Consider using `rubocop -a --disable-uncorrectable` to ease transition.
|
25
|
+
- Extensive refactoring of internal classes `Team`, `Commissioner`, `Corrector`. `Cop::Cop#corrections` not completely compatible. See Upgrade Notes.
|
26
|
+
- `rubocop -a / --autocorrect` no longer run unsafe corrections; `rubocop -A / --autocorrect-all` run both safe and unsafe corrections. Options `--safe-autocorrect` is deprecated.
|
27
|
+
- Order for gems names now disregards underscores and dashes unless `ConsiderPunctuation` setting is set to `true`.
|
28
|
+
- Cop `Metrics/CyclomaticComplexity` now counts `&.`, `||=`, `&&=` and blocks known to iterate. Default bumped from 6 to 7. Consider using `rubocop -a --disable-uncorrectable` to ease transition.
|
29
|
+
- Remove support for unindent/active_support/powerpack from `Layout/HeredocIndentation`, so it only recommends using squiggy heredoc.
|
30
|
+
- Change the max line length of `Layout/LineLength` to 120 by default.
|
31
|
+
- Inspect all files given on command line unless `--only-recognized-file-types` is given.
|
32
|
+
- Enabling a cop overrides disabling its department.
|
33
|
+
- Renamed `Layout/Tab` cop to `Layout/IndentationStyle`.
|
34
|
+
- Drop support for Ruby 2.3.
|
35
|
+
- Drop support for ruby 2.4.
|
36
|
+
- Retire `RSpec/InvalidPredicateMatcher` cop.
|
37
|
+
- Enabled pending cop (`RSpec/StubbedMock`).
|
38
|
+
|
39
|
+
## v2.4.0
|
40
|
+
- Fix `FeatureFlagActive` cop so that it allows feature flag names to be variables in addition to strings.
|
41
|
+
- Add check to `FeatureFlagActive` that the first parameter is a string or a variable, and use the appropriate messaging.
|
42
|
+
|
9
43
|
## v2.3.0
|
10
44
|
- Add `FeatureFlagActive` cop. This provides confidence that upgrading to `ezcater_feature_flag-client` v2.0.0, which
|
11
45
|
contains breaking API changes, can be done safely.
|
data/conf/rubocop.yml
CHANGED
@@ -2,6 +2,8 @@ require: ezcater_rubocop
|
|
2
2
|
|
3
3
|
AllCops:
|
4
4
|
DisplayCopNames: true
|
5
|
+
NewCops: disable
|
6
|
+
SuggestExtensions: false
|
5
7
|
|
6
8
|
Layout/FirstHashElementIndentation:
|
7
9
|
EnforcedStyle: consistent
|
@@ -20,8 +22,8 @@ Metrics/AbcSize:
|
|
20
22
|
|
21
23
|
Metrics/BlockLength:
|
22
24
|
Exclude:
|
23
|
-
|
24
|
-
|
25
|
+
- "*.gemspec"
|
26
|
+
- "spec/**/*.rb"
|
25
27
|
|
26
28
|
Metrics/CyclomaticComplexity:
|
27
29
|
Enabled: false
|
@@ -29,7 +31,7 @@ Metrics/CyclomaticComplexity:
|
|
29
31
|
Layout/LineLength:
|
30
32
|
Max: 120
|
31
33
|
Exclude:
|
32
|
-
|
34
|
+
- "Gemfile"
|
33
35
|
|
34
36
|
Metrics/MethodLength:
|
35
37
|
Enabled: true
|
@@ -44,9 +46,12 @@ Naming/MemoizedInstanceVariableName:
|
|
44
46
|
|
45
47
|
Naming/MethodParameterName:
|
46
48
|
AllowedNames:
|
47
|
-
|
48
|
-
|
49
|
-
|
49
|
+
- e
|
50
|
+
- ex
|
51
|
+
- id
|
52
|
+
|
53
|
+
Naming/VariableNumber:
|
54
|
+
Enabled: false
|
50
55
|
|
51
56
|
Rails:
|
52
57
|
Enabled: false
|
@@ -56,12 +61,12 @@ RSpec/ContextWording:
|
|
56
61
|
|
57
62
|
RSpec/DescribeClass:
|
58
63
|
Exclude:
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
64
|
+
- "spec/requests/**/*.rb"
|
65
|
+
- "spec/features/**/*.rb"
|
66
|
+
- "spec/routing/**/*.rb"
|
67
|
+
- "spec/views/**/*.rb"
|
68
|
+
- "spec/system/**/*.rb"
|
69
|
+
- "spec/integrations/**/*.rb"
|
65
70
|
|
66
71
|
RSpec/ExampleLength:
|
67
72
|
Max: 25
|
@@ -109,12 +114,12 @@ Style/NumericLiterals:
|
|
109
114
|
|
110
115
|
Style/PercentLiteralDelimiters:
|
111
116
|
PreferredDelimiters:
|
112
|
-
default:
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
117
|
+
default: "()"
|
118
|
+
"%i": "()"
|
119
|
+
"%I": "()"
|
120
|
+
"%r": "{}"
|
121
|
+
"%w": "()"
|
122
|
+
"%W": "()"
|
118
123
|
|
119
124
|
Style/RaiseArgs:
|
120
125
|
EnforcedStyle: compact
|
@@ -131,6 +136,9 @@ Style/StderrPuts:
|
|
131
136
|
Exclude:
|
132
137
|
- "bin/yarn"
|
133
138
|
|
139
|
+
Style/StringConcatenation:
|
140
|
+
Enabled: false
|
141
|
+
|
134
142
|
Style/StringLiterals:
|
135
143
|
EnforcedStyle: double_quotes
|
136
144
|
|
@@ -146,6 +154,184 @@ Style/TrailingCommaInHashLiteral:
|
|
146
154
|
# enabled or disabled. New cops are not enabled by default until the
|
147
155
|
# next major release.
|
148
156
|
|
157
|
+
# New cops introduced between 0.81.0 and 1.16.0
|
158
|
+
Layout/BeginEndAlignment:
|
159
|
+
Enabled: false
|
160
|
+
|
161
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
162
|
+
Enabled: false
|
163
|
+
|
164
|
+
Layout/IndentationStyle:
|
165
|
+
Enabled: false
|
166
|
+
|
167
|
+
Layout/SpaceAroundMethodCallOperator:
|
168
|
+
Enabled: false
|
169
|
+
|
170
|
+
Lint/BinaryOperatorWithIdenticalOperands:
|
171
|
+
Enabled: false
|
172
|
+
|
173
|
+
Lint/ConstantDefinitionInBlock:
|
174
|
+
Enabled: false
|
175
|
+
|
176
|
+
Lint/DeprecatedOpenSSLConstant:
|
177
|
+
Enabled: false
|
178
|
+
|
179
|
+
Lint/DuplicateElsifCondition:
|
180
|
+
Enabled: false
|
181
|
+
|
182
|
+
Lint/DuplicateRequire:
|
183
|
+
Enabled: false
|
184
|
+
|
185
|
+
Lint/DuplicateRescueException:
|
186
|
+
Enabled: false
|
187
|
+
|
188
|
+
Lint/EmptyConditionalBody:
|
189
|
+
Enabled: false
|
190
|
+
|
191
|
+
Lint/EmptyFile:
|
192
|
+
Enabled: false
|
193
|
+
|
194
|
+
Lint/FloatComparison:
|
195
|
+
Enabled: false
|
196
|
+
|
197
|
+
Lint/HashCompareByIdentity:
|
198
|
+
Enabled: false
|
199
|
+
|
200
|
+
Lint/IdentityComparison:
|
201
|
+
Enabled: false
|
202
|
+
|
203
|
+
Lint/MissingSuper:
|
204
|
+
Enabled: false
|
205
|
+
|
206
|
+
Lint/MixedRegexpCaptureTypes:
|
207
|
+
Enabled: false
|
208
|
+
|
209
|
+
Lint/OutOfRangeRegexpRef:
|
210
|
+
Enabled: false
|
211
|
+
|
212
|
+
Lint/RedundantSafeNavigation:
|
213
|
+
Enabled: false
|
214
|
+
|
215
|
+
Lint/SelfAssignment:
|
216
|
+
Enabled: false
|
217
|
+
|
218
|
+
Lint/TopLevelReturnWithArgument:
|
219
|
+
Enabled: false
|
220
|
+
|
221
|
+
Lint/TrailingCommaInAttributeDeclaration:
|
222
|
+
Enabled: false
|
223
|
+
|
224
|
+
Lint/UnreachableLoop:
|
225
|
+
Enabled: false
|
226
|
+
|
227
|
+
Lint/UselessMethodDefinition:
|
228
|
+
Enabled: false
|
229
|
+
|
230
|
+
Lint/UselessTimes:
|
231
|
+
Enabled: false
|
232
|
+
|
233
|
+
Rails/ArelStar:
|
234
|
+
Enabled: false
|
235
|
+
|
236
|
+
Rails/Pick:
|
237
|
+
Enabled: false
|
238
|
+
|
239
|
+
Rails/RedundantForeignKey:
|
240
|
+
Enabled: false
|
241
|
+
|
242
|
+
RSpec/Capybara/CurrentPathExpectation:
|
243
|
+
Enabled: false
|
244
|
+
|
245
|
+
RSpec/Capybara/FeatureMethods:
|
246
|
+
Enabled: false
|
247
|
+
|
248
|
+
RSpec/Capybara/VisibilityMatcher:
|
249
|
+
Enabled: false
|
250
|
+
|
251
|
+
RSpec/EmptyHook:
|
252
|
+
Enabled: false
|
253
|
+
|
254
|
+
RSpec/FactoryBot/AttributeDefinedStatically:
|
255
|
+
Enabled: false
|
256
|
+
|
257
|
+
RSpec/FactoryBot/CreateList:
|
258
|
+
Enabled: false
|
259
|
+
|
260
|
+
RSpec/FactoryBot/FactoryClassName:
|
261
|
+
Enabled: false
|
262
|
+
|
263
|
+
RSpec/MultipleMemoizedHelpers:
|
264
|
+
Enabled: false
|
265
|
+
|
266
|
+
RSpec/NotToNot:
|
267
|
+
Enabled: false
|
268
|
+
|
269
|
+
RSpec/Rails/HttpStatus:
|
270
|
+
Enabled: false
|
271
|
+
|
272
|
+
RSpec/RepeatedIncludeExample:
|
273
|
+
Enabled: false
|
274
|
+
|
275
|
+
RSpec/StubbedMock:
|
276
|
+
Enabled: false
|
277
|
+
|
278
|
+
RSpec/VariableDefinition:
|
279
|
+
Enabled: false
|
280
|
+
|
281
|
+
RSpec/VariableName:
|
282
|
+
Enabled: false
|
283
|
+
|
284
|
+
Style/AccessorGrouping:
|
285
|
+
Enabled: false
|
286
|
+
|
287
|
+
Style/BisectedAttrAccessor:
|
288
|
+
Enabled: false
|
289
|
+
|
290
|
+
Style/CaseLikeIf:
|
291
|
+
Enabled: false
|
292
|
+
|
293
|
+
Style/CombinableLoops:
|
294
|
+
Enabled: false
|
295
|
+
|
296
|
+
Style/ExponentialNotation:
|
297
|
+
Enabled: false
|
298
|
+
|
299
|
+
Style/GlobalStdStream:
|
300
|
+
Enabled: false
|
301
|
+
|
302
|
+
Style/HashAsLastArrayItem:
|
303
|
+
Enabled: false
|
304
|
+
|
305
|
+
Style/HashLikeCase:
|
306
|
+
Enabled: false
|
307
|
+
|
308
|
+
Style/KeywordParametersOrder:
|
309
|
+
Enabled: false
|
310
|
+
|
311
|
+
Style/OptionalBooleanParameter:
|
312
|
+
Enabled: false
|
313
|
+
|
314
|
+
Style/RedundantAssignment:
|
315
|
+
Enabled: false
|
316
|
+
|
317
|
+
Style/RedundantRegexpCharacterClass:
|
318
|
+
Enabled: false
|
319
|
+
|
320
|
+
Style/RedundantRegexpEscape:
|
321
|
+
Enabled: false
|
322
|
+
|
323
|
+
Style/RedundantSelfAssignment:
|
324
|
+
Enabled: false
|
325
|
+
|
326
|
+
Style/SingleArgumentDig:
|
327
|
+
Enabled: false
|
328
|
+
|
329
|
+
Style/SlicingWithRange:
|
330
|
+
Enabled: false
|
331
|
+
|
332
|
+
Style/SoleNestedConditional:
|
333
|
+
Enabled: false
|
334
|
+
|
149
335
|
#### New cops in v0.81
|
150
336
|
|
151
337
|
Lint/RaiseException:
|
data/conf/rubocop_rails.yml
CHANGED
data/config/default.yml
CHANGED
@@ -5,57 +5,57 @@ Ezcater/GraphqlFieldsNaming:
|
|
5
5
|
- snake_case
|
6
6
|
- camelCase
|
7
7
|
Include:
|
8
|
-
-
|
8
|
+
- "app/graphql/**/*.rb"
|
9
9
|
|
10
10
|
Ezcater/RailsConfiguration:
|
11
|
-
Description:
|
11
|
+
Description: "Enforce the use of `Rails.configuration` instead of `Rails.application.config`."
|
12
12
|
Enabled: true
|
13
13
|
|
14
14
|
Ezcater/RailsEnv:
|
15
|
-
Description:
|
15
|
+
Description: "Enforce the use of `Rails.configuration.x.<foo>` instead of checking `Rails.env`."
|
16
16
|
Enabled: false
|
17
17
|
|
18
18
|
Ezcater/DirectEnvCheck:
|
19
|
-
Description:
|
19
|
+
Description: "Enforce the use of `Rails.configuration.x.<foo>` instead of checking `ENV`."
|
20
20
|
Enabled: false
|
21
21
|
|
22
22
|
Ezcater/FeatureFlagActive:
|
23
|
-
Description:
|
23
|
+
Description: "Enforce the proper arguments are given to EzcaterFeatureFlag.active?"
|
24
24
|
Enabled: true
|
25
25
|
|
26
26
|
Ezcater/RspecDotNotSelfDot:
|
27
27
|
Description: 'Enforce ".<class method>" instead of "self.<class method>" for example group description.'
|
28
28
|
Enabled: true
|
29
29
|
Include:
|
30
|
-
-
|
30
|
+
- "**/*_spec.rb"
|
31
31
|
|
32
32
|
Ezcater/RspecRequireBrowserMock:
|
33
|
-
Description:
|
33
|
+
Description: "Enforce use of `mock_ezcater_app`, `mock_chrome_browser` & `mock_custom_browser` helpers instead of mocking `Browser` or `EzBrowser` directly."
|
34
34
|
Enabled: true
|
35
35
|
Include:
|
36
|
-
-
|
36
|
+
- "**/*_spec.rb"
|
37
37
|
|
38
38
|
Ezcater/RspecRequireFeatureFlagMock:
|
39
|
-
Description:
|
39
|
+
Description: "Enforce use of `mock_feature_flag` helpers instead of mocking `FeatureFlag.is_active?` directly."
|
40
40
|
Enabled: true
|
41
41
|
Include:
|
42
|
-
-
|
42
|
+
- "**/*_spec.rb"
|
43
43
|
|
44
44
|
Ezcater/RspecRequireHttpStatusMatcher:
|
45
|
-
Description:
|
45
|
+
Description: "Use the HTTP status code matcher, like `expect(response).to have_http_status :bad_request`, rather than `expect(response.code).to eq 400`"
|
46
46
|
Enabled: true
|
47
47
|
Include:
|
48
|
-
-
|
48
|
+
- "**/*_spec.rb"
|
49
49
|
|
50
50
|
Ezcater/RequireGqlErrorHelpers:
|
51
|
-
Description:
|
51
|
+
Description: "Use the helpers provided by `GQLErrors` instead of raising `GraphQL::ExecutionError` directly."
|
52
52
|
Enabled: true
|
53
53
|
|
54
54
|
Ezcater/StyleDig:
|
55
|
-
Description:
|
55
|
+
Description: "Recommend `dig` for deeply nested access."
|
56
56
|
Enabled: true
|
57
57
|
AutoCorrect: false
|
58
58
|
|
59
59
|
Ezcater/RubyTimeout:
|
60
|
-
Description:
|
60
|
+
Description: "Disallow use of `Timeout.timeout` because it is unsafe and can cause unexpected behavior."
|
61
61
|
Enabled: true
|
data/ezcater_rubocop.gemspec
CHANGED
@@ -52,7 +52,7 @@ Gem::Specification.new do |spec|
|
|
52
52
|
spec.add_development_dependency "simplecov", "< 0.18.0"
|
53
53
|
|
54
54
|
spec.add_runtime_dependency "parser", "!= 2.5.1.1"
|
55
|
-
spec.add_runtime_dependency "rubocop", "~>
|
56
|
-
spec.add_runtime_dependency "rubocop-rails", "~> 2.
|
57
|
-
spec.add_runtime_dependency "rubocop-rspec", "~>
|
55
|
+
spec.add_runtime_dependency "rubocop", "~> 1.16.0"
|
56
|
+
spec.add_runtime_dependency "rubocop-rails", "~> 2.10.1"
|
57
|
+
spec.add_runtime_dependency "rubocop-rspec", "~> 2.3.0"
|
58
58
|
end
|
@@ -10,22 +10,27 @@ module RuboCop
|
|
10
10
|
# # good
|
11
11
|
# EzFF.active?("FlagName", tracking_id: "user:12345")
|
12
12
|
# EzFF.active?("FlagName", identifiers: ["user:12345", "user:23456"])
|
13
|
+
# EzFF.active?(defined_flag_name_var, tracking_id: "brand:12345")
|
14
|
+
# EzFF.active?(@flag_name_ivar, tracking_id: "brand:12345")
|
13
15
|
#
|
14
16
|
# # bad
|
15
17
|
# EzFF.active?("FlagName")
|
18
|
+
# EzFF.active?(defined_flag_name_var)
|
19
|
+
# EzFF.active?(@flag_name_ivar)
|
16
20
|
|
17
21
|
class FeatureFlagActive < Cop
|
18
22
|
MSG = "`EzFF.active?` must be called with at least one of `tracking_id` or `identifiers`"
|
23
|
+
FIRST_PARAM_MSG = "The first argument to `EzFF.active?` must be a string or predefined variable"
|
19
24
|
|
20
25
|
def_node_matcher :ezff_active_one_arg, <<-PATTERN
|
21
26
|
(send
|
22
|
-
(_ _ {:EzFF :EzcaterFeatureFlag}) :active?
|
27
|
+
(_ _ {:EzFF :EzcaterFeatureFlag}) :active? ${str lvar ivar})
|
23
28
|
PATTERN
|
24
29
|
|
25
30
|
def_node_matcher :args_matcher, <<-PATTERN
|
26
31
|
(send
|
27
32
|
(_ _ {:EzFF :EzcaterFeatureFlag}) :active?
|
28
|
-
|
33
|
+
${str lvar ivar}
|
29
34
|
(_
|
30
35
|
(pair
|
31
36
|
(sym {:tracking_id :identifiers})
|
@@ -33,6 +38,11 @@ module RuboCop
|
|
33
38
|
...))
|
34
39
|
PATTERN
|
35
40
|
|
41
|
+
def_node_matcher :first_param_good, <<-PATTERN
|
42
|
+
(send
|
43
|
+
(_ _ {:EzFF :EzcaterFeatureFlag}) :active? ${str lvar ivar} ...)
|
44
|
+
PATTERN
|
45
|
+
|
36
46
|
def_node_matcher :method_call_matcher, <<-PATTERN
|
37
47
|
(send
|
38
48
|
(_ _ {:EzFF :EzcaterFeatureFlag}) :active? ...)
|
@@ -41,6 +51,10 @@ module RuboCop
|
|
41
51
|
def on_send(node)
|
42
52
|
return unless method_call_matcher(node)
|
43
53
|
|
54
|
+
if !first_param_good(node)
|
55
|
+
add_offense(node, location: :expression, message: FIRST_PARAM_MSG)
|
56
|
+
end
|
57
|
+
|
44
58
|
if ezff_active_one_arg(node) || !args_matcher(node)
|
45
59
|
add_offense(node, location: :expression, message: MSG)
|
46
60
|
end
|
@@ -40,7 +40,7 @@ module RuboCop
|
|
40
40
|
|
41
41
|
return if includes_camelize?(node)
|
42
42
|
|
43
|
-
check_name(node, first_arg.value, node.first_argument
|
43
|
+
check_name(node, first_arg.value, node.first_argument)
|
44
44
|
end
|
45
45
|
|
46
46
|
alias on_super on_send
|
@@ -66,7 +66,7 @@ module RuboCop
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def message(style)
|
69
|
-
format(MSG, style: style)
|
69
|
+
format(MSG, style: style) # Rubocop:disable Style/HashSyntax
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
@@ -24,29 +24,45 @@ module RuboCop
|
|
24
24
|
# end
|
25
25
|
|
26
26
|
class RspecDotNotSelfDot < Cop
|
27
|
-
|
28
|
-
|
27
|
+
include RuboCop::RSpec::Language
|
28
|
+
extend RuboCop::RSpec::Language::NodePattern
|
29
|
+
|
30
|
+
RSPEC_EXAMPLE_PREFIXES = ["", "x", "f"].freeze
|
31
|
+
EXAMPLE_GROUP_IDENTIFIERS = (RSPEC_EXAMPLE_PREFIXES.map do |prefix|
|
32
|
+
%w(describe context feature).map { |identifier| "#{prefix}#{identifier}" }
|
33
|
+
end.flatten + %w(example_group)).freeze
|
34
|
+
EXAMPLE_IDENTIFIERS = (RSPEC_EXAMPLE_PREFIXES.map do |prefix|
|
35
|
+
%w(it specify example scenario).map { |identifier| "#{prefix}#{identifier}" }
|
36
|
+
end.flatten + %w(its focus skip)).freeze
|
37
|
+
|
38
|
+
SELF_DOT_REGEXP = /\Aself\./.freeze
|
39
|
+
COLON_COLON_REGEXP = /\A(\:\:)/.freeze
|
29
40
|
|
30
41
|
SELF_DOT_MSG = 'Use ".<class method>" instead of "self.<class method>" for example group description.'
|
31
42
|
COLON_COLON_MSG = 'Use ".<class method>" instead of "::<class method>" for example group description.'
|
32
43
|
|
33
|
-
def_node_matcher :
|
34
|
-
(
|
44
|
+
def_node_matcher :example_group?, <<~PATTERN
|
45
|
+
(block
|
46
|
+
(send #rspec? {#{EXAMPLE_GROUP_IDENTIFIERS.map { |i| ":#{i}" }.join(' ')}}
|
47
|
+
(str ...) ...
|
48
|
+
) ...
|
49
|
+
)
|
35
50
|
PATTERN
|
36
51
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
52
|
+
def on_block(node)
|
53
|
+
return unless example_group?(node)
|
54
|
+
|
55
|
+
str_node = node.send_node.arguments[0]
|
56
|
+
if str_node.value.match?(SELF_DOT_REGEXP)
|
57
|
+
add_offense(str_node, location: :expression, message: SELF_DOT_MSG)
|
58
|
+
elsif str_node.value.match?(COLON_COLON_REGEXP)
|
59
|
+
add_offense(str_node, location: :expression, message: COLON_COLON_MSG)
|
44
60
|
end
|
45
61
|
end
|
46
62
|
|
47
63
|
def autocorrect(node)
|
48
64
|
lambda do |corrector|
|
49
|
-
experession_end = node.source.match?(
|
65
|
+
experession_end = node.source.match?("::") ? 3 : 6
|
50
66
|
corrector.replace(Parser::Source::Range.new(node.source_range.source_buffer,
|
51
67
|
node.source_range.begin_pos + 1,
|
52
68
|
node.source_range.begin_pos + experession_end), ".")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ezcater_rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ezCater, Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -114,42 +114,42 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 1.16.0
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 1.16.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rubocop-rails
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 2.
|
131
|
+
version: 2.10.1
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 2.
|
138
|
+
version: 2.10.1
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: rubocop-rspec
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
145
|
+
version: 2.3.0
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
152
|
+
version: 2.3.0
|
153
153
|
description: ezCater custom cops and shared configuration
|
154
154
|
email:
|
155
155
|
- engineering@ezcater.com
|
@@ -160,6 +160,7 @@ extra_rdoc_files: []
|
|
160
160
|
files:
|
161
161
|
- ".github/CODEOWNERS"
|
162
162
|
- ".github/PULL_REQUEST_TEMPLATE.md"
|
163
|
+
- ".tool-versions"
|
163
164
|
- CHANGELOG.md
|
164
165
|
- Gemfile
|
165
166
|
- LICENSE.txt
|
@@ -207,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
208
|
- !ruby/object:Gem::Version
|
208
209
|
version: '0'
|
209
210
|
requirements: []
|
210
|
-
rubygems_version: 3.
|
211
|
+
rubygems_version: 3.1.6
|
211
212
|
signing_key:
|
212
213
|
specification_version: 4
|
213
214
|
summary: ezCater custom cops and shared configuration
|