ezcater_rubocop 3.0.0 → 4.0.0
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 +74 -3
- data/README.md +11 -12
- data/bin/circle_rubocop.rb +4 -4
- data/conf/rubocop.yml +19 -18
- data/conf/rubocop_rails.yml +1 -0
- data/config/default.yml +26 -23
- data/ezcater_rubocop.gemspec +9 -8
- data/lib/ezcater_rubocop/version.rb +1 -1
- data/lib/ezcater_rubocop.rb +1 -1
- data/lib/rubocop/cop/ezcater/rspec_dot_not_self_dot.rb +28 -10
- metadata +64 -26
- data/lib/rubocop/cop/ezcater/graphql_fields_naming.rb +0 -74
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e4ab0e968f3876d0ce517e56e4f4d4f85d4a512148d76eddc3b90afb27b030e
|
4
|
+
data.tar.gz: 1222c65a574b4aeab13b5372a4e2fc0c4c3af89e6f611dcfd82a41879343e198
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 173c89e6a3c9eb6b022b90ccc0d28c49b44331d42617e082d5fcd1380e0c2b2ad834250608a87556c9dd5e664d770009d1499a77fa002ad4270740b1069f2b44
|
7
|
+
data.tar.gz: 924a0d9ed141df769723ed76ab30aae9625da0f1890ab75125c94f74ca1fa9e0cb6c31b0b4f8c74d0418031890c07f6f4dad1eadedbc1424e314fff32c16bc0f
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.1.1
|
data/CHANGELOG.md
CHANGED
@@ -6,11 +6,27 @@ 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
|
+
## 4.0.0
|
10
|
+
|
11
|
+
- Add the [rubcop-graphql](https://github.com/DmitryTsepelev/rubocop-graphql) helpers and enable
|
12
|
+
them by default
|
13
|
+
- Remove `Ezcater/GraphqlFieldsNaming` cop. The same rule exists in `rubocop-graphql`.
|
14
|
+
|
15
|
+
## v3.0.2
|
16
|
+
|
17
|
+
- Loosen restrictions to allow for Ruby 3.1 and latest dependency gems
|
18
|
+
|
19
|
+
## v3.0.1
|
20
|
+
|
21
|
+
- Fix the RspecDotNotSelfDot cop to work with rubocop-rspec
|
22
|
+
- Exclude appraisal generated gemfiles for possible embedded gems in rails apps
|
23
|
+
|
9
24
|
## v3.0.0
|
10
|
-
|
25
|
+
|
26
|
+
- Upgrade rubocop: 1.16.0
|
11
27
|
- Upgrade rubocop-rails: 2.10.1
|
12
28
|
- Upgrade rubocop-rspec: 2.3.0
|
13
|
-
- This is a major upgrade because a large number of cops have been introduced, tweaked, or renamed.
|
29
|
+
- 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
|
14
30
|
- RuboCop assumes that Cop classes do not define new `on_<type>` methods at runtime (e.g. via `extend` in `initialize`).
|
15
31
|
- Enable all pending cops for RuboCop 1.0.
|
16
32
|
- 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`).
|
@@ -32,101 +48,128 @@ Prior to v1.0.0 this gem was versioned based on the `MAJOR`.`MINOR` version of R
|
|
32
48
|
- Enabled pending cop (`RSpec/StubbedMock`).
|
33
49
|
|
34
50
|
## v2.4.0
|
51
|
+
|
35
52
|
- Fix `FeatureFlagActive` cop so that it allows feature flag names to be variables in addition to strings.
|
36
53
|
- Add check to `FeatureFlagActive` that the first parameter is a string or a variable, and use the appropriate messaging.
|
37
54
|
|
38
55
|
## v2.3.0
|
56
|
+
|
39
57
|
- Add `FeatureFlagActive` cop. This provides confidence that upgrading to `ezcater_feature_flag-client` v2.0.0, which
|
40
|
-
|
58
|
+
contains breaking API changes, can be done safely.
|
41
59
|
|
42
60
|
## v2.2.0
|
61
|
+
|
43
62
|
- Require Ruby 2.6 or later.
|
44
63
|
- Set `TargetRubyVersion` to 2.6 in `rubocop_gem` configuration.
|
45
64
|
|
46
65
|
## v2.1.0
|
66
|
+
|
47
67
|
- Enable `Rails/SaveBang` with `AllowImplicitReturn: false`, and with autocorrection disabled.
|
48
68
|
|
49
69
|
## v2.0.0
|
70
|
+
|
50
71
|
- Update to `rubocop` v0.81.0, `rubocop-rspec` v1.38.1 and `rubocop-rails` v2.5.2.
|
51
72
|
- This is being released as a major update because cops have been renamed so this is unlikely to be
|
52
73
|
a drop-in replacement.
|
53
74
|
- This is the first release to support Ruby 2.7.
|
54
75
|
|
55
76
|
## v1.4.1
|
77
|
+
|
56
78
|
- Correct a matching syntax issue with `Ezcater/RubyTimeout` so that it applies in the expected cases.
|
57
79
|
|
58
80
|
## v1.4.0
|
81
|
+
|
59
82
|
- Add `Ezcater/RubyTimeout` cop.
|
60
83
|
|
61
84
|
## v1.3.0
|
85
|
+
|
62
86
|
- Add `Ezcater/GraphqlFieldsNaming` cop.
|
63
87
|
|
64
88
|
## v1.2.0
|
89
|
+
|
65
90
|
- Add `Ezcater/RailsTopLevelSqlExecute` to replace `ActiveRecord::Base.connection.execute` with `execute` in `db/migrate/`.
|
66
91
|
|
67
92
|
## v1.1.1
|
93
|
+
|
68
94
|
- Exclude `lib/tasks/` for `Ezcater/RailsEnv` and `Ezcater/DirectEnvCheck`.
|
69
95
|
|
70
96
|
## v1.1.0
|
97
|
+
|
71
98
|
- Add `Ezcater/RailsEnv` cop.
|
72
99
|
- Add `Ezcater/DirectEnvCheck` cop.
|
73
100
|
|
74
101
|
## v1.0.2
|
102
|
+
|
75
103
|
- Exclude bootsnap cache directory (`tmp/cache`).
|
76
104
|
|
77
105
|
## v1.0.1
|
106
|
+
|
78
107
|
- Disable `Rails/HasAndBelongsToMany` cop.
|
79
108
|
- Disable `Style/DoubleNegation` cop.
|
80
109
|
|
81
110
|
## v1.0.0
|
111
|
+
|
82
112
|
- Begin using Semantic Versioning
|
83
113
|
- Delete `Ezcater/PrivateAttr`
|
84
114
|
|
85
115
|
## v0.61.1
|
116
|
+
|
86
117
|
- `Layout/IndentHash` enforces consistent style
|
87
118
|
- `Layout/IndentArray` enforces consistent style
|
88
119
|
|
89
120
|
## v0.61.0
|
121
|
+
|
90
122
|
- Update to `rubocop` v0.61.1.
|
91
123
|
- Update to `rubocop-rspec` v1.30.1
|
92
124
|
|
93
125
|
## v0.59.0
|
126
|
+
|
94
127
|
- Disable `Style/NegatedIf`.
|
95
128
|
|
96
129
|
## v0.58.4
|
130
|
+
|
97
131
|
- Update `Metrics/BlockLength` to exclude `app/graphql/**/*.rb`
|
98
132
|
- Move `Metrics/BlockLength` exclusions for `lib/tasks/**/*.rake` and
|
99
133
|
`config/environments/*.rb` into rubocop_rails.yml
|
100
134
|
|
101
135
|
## v0.58.3
|
136
|
+
|
102
137
|
- Updated `Layout/MultilineMethodCallIndentation` to `indented`.
|
103
138
|
|
104
139
|
## v0.58.2
|
140
|
+
|
105
141
|
- Updated `Ezcater/RspecDotNotSelfDot` to flag offenses for `::class_method`.
|
106
142
|
|
107
143
|
## v0.58.1
|
144
|
+
|
108
145
|
- Update to `rubocop-rspec` v1.28.0.
|
109
146
|
- Remove configuration for removed `FactoryBot/DynamicAttributeDefinedStatically` cop.
|
110
147
|
|
111
148
|
## v0.58.0
|
149
|
+
|
112
150
|
- Update to rubocop v0.58.1.
|
113
151
|
- Enable `Naming/MemoizedInstanceVariableName` with required leading
|
114
152
|
underscore.
|
115
153
|
|
116
154
|
## v0.57.4
|
155
|
+
|
117
156
|
- Configure `Rspec/MessageExpectation` with the `allow` style.
|
118
157
|
|
119
158
|
## v0.57.3
|
159
|
+
|
120
160
|
- Do not use broken parser v2.5.1.1.
|
121
161
|
|
122
162
|
## v0.57.2
|
163
|
+
|
123
164
|
- Fix `Ezcater/RspecRequireHttpStatusMatcher` cop.
|
124
165
|
|
125
166
|
## v0.57.1
|
167
|
+
|
126
168
|
- Add `Ezcater/RspecRequireHttpStatusMatcher` cop.
|
127
169
|
- Enable `Rails/HttpStatus` cop and enforce symbols.
|
128
170
|
|
129
171
|
## v0.57.0
|
172
|
+
|
130
173
|
- Update to rubocop v0.57.2 and rubocop-rspec v1.27.0.
|
131
174
|
- Disable new cop `Naming/MemoizedInstanceVariableName` until configuration
|
132
175
|
options are available.
|
@@ -137,100 +180,128 @@ Prior to v1.0.0 this gem was versioned based on the `MAJOR`.`MINOR` version of R
|
|
137
180
|
- Exclude appraisal generated gemfiles for gems.
|
138
181
|
|
139
182
|
## v0.52.8
|
183
|
+
|
140
184
|
- Add new configuration `rubocop_gem` for use with gems.
|
141
185
|
|
142
186
|
## v0.52.7
|
187
|
+
|
143
188
|
- Enable `Style/FrozenStringLiteralComment` with the `when_needed` style.
|
144
189
|
|
145
190
|
## v0.52.6
|
191
|
+
|
146
192
|
- Configure `Style/TrailingCommaInLiteral` with `consistent_comma` style.
|
147
193
|
|
148
194
|
## v0.52.5
|
195
|
+
|
149
196
|
- Add `Ezcater/RspecMatchOrderedArray` cop.
|
150
197
|
- Fix array equality matcher violations in specs.
|
151
198
|
|
152
199
|
## v0.52.4
|
200
|
+
|
153
201
|
- Configure `Style/RegexpLiteral` cop with the `AllowInnerSlashes: true` option.
|
154
202
|
|
155
203
|
## v0.52.3
|
204
|
+
|
156
205
|
- Disable `Style/GuardClause` cop.
|
157
206
|
- Exclude `spec/integrations` for `RSpec/DescribeClass`.
|
158
207
|
|
159
208
|
## v0.52.2
|
209
|
+
|
160
210
|
- Disable `Style/IfUnlessModifier` cop.
|
161
211
|
|
162
212
|
## v0.52.1
|
213
|
+
|
163
214
|
- Allow staging as a rails environment for the Rails/UnknownEnv cop.
|
164
215
|
|
165
216
|
## v0.52.0
|
217
|
+
|
166
218
|
- Update to rubocop v0.52.1 and rubocop-rspec v1.22.2.
|
167
219
|
|
168
220
|
## v0.51.8
|
221
|
+
|
169
222
|
- Disable `RSpec/LetSetup` cop.
|
170
223
|
|
171
224
|
## v0.51.7
|
225
|
+
|
172
226
|
- Rename `Ezcater/RspecRequireGqlErrorHelpers` cop to `Ezcater/RequireGqlErrorHelpers`.
|
173
227
|
|
174
228
|
## v0.51.6
|
229
|
+
|
175
230
|
- Add `Ezcater/RailsConfiguration` cop.
|
176
231
|
- Exclude `config/environments/*.rb` for the `Metrics/BlockLength` cop.
|
177
232
|
|
178
233
|
## v0.51.5
|
234
|
+
|
179
235
|
- Add `Ezcater/RspecRequireGqlErrorHelpers` cop.
|
180
236
|
|
181
237
|
## v0.51.4
|
238
|
+
|
182
239
|
- Exclude `Gemfile` for the `Metrics/LineLength` cop.
|
183
240
|
- Add `system` to the excluded spec directories for `RSpec/DescribeClass`.
|
184
241
|
|
185
242
|
## v0.51.3
|
243
|
+
|
186
244
|
- Configure `RSpec/DescribeClass` to exclude the spec directories which
|
187
245
|
are excluded by explicit metadata.
|
188
246
|
- Exclude `lib/tasks` for the `Metrics/BlockLength` cop.
|
189
247
|
|
190
248
|
## v0.51.2
|
249
|
+
|
191
250
|
- Configure `Style/RaiseArgs` to use the `compact` style.
|
192
251
|
|
193
252
|
## v0.51.1
|
253
|
+
|
194
254
|
- Disable `Rails/FilePath` cop.
|
195
255
|
- Disable `Style/EmptyLiteral` cop.
|
196
256
|
|
197
257
|
## v0.51.0
|
258
|
+
|
198
259
|
- Update to rubocop v0.51.0 and rubocop-rspec v1.20.0.
|
199
260
|
- Disable new cop `RSpec/ContextWording`.
|
200
261
|
- Disable `Style/StderrPuts` for `bin/yarn`.
|
201
262
|
|
202
263
|
## v0.50.5
|
264
|
+
|
203
265
|
- Configure `RSpec/NestedGroups` with a `Max` value of 5.
|
204
266
|
|
205
267
|
## v0.50.4
|
268
|
+
|
206
269
|
- Configure `Style/PercentLiteralDelimiters` to prefer parentheses.
|
207
270
|
|
208
271
|
## v0.50.3
|
272
|
+
|
209
273
|
- Configure `RSpec/MultipleExpectations` with a `Max` value of 5.
|
210
274
|
|
211
275
|
## v0.50.2
|
276
|
+
|
212
277
|
- Add `Ezcater/PrivateAttr` custom cop.
|
213
278
|
- Configure `RSpec/ExampleLength` with a `Max` value of 25.
|
214
279
|
- Add `circle_rubocop.rb` script.
|
215
280
|
|
216
281
|
## v0.50.1
|
282
|
+
|
217
283
|
- Add shared configuration.
|
218
284
|
- Do not apply `Ezcater/StyleDig` to access using a range.
|
219
285
|
|
220
286
|
## v0.50.0
|
287
|
+
|
221
288
|
- Update to rubocop v0.50.0 and rubocop-rspec v1.18.0.
|
222
289
|
- Do not apply `Ezcater/StyleDig` to assignments with nested access.
|
223
290
|
|
224
291
|
# v0.49.3
|
292
|
+
|
225
293
|
- Do not apply `Ezcater/StyleDig` to access using a range.
|
226
294
|
|
227
295
|
# v0.49.2
|
296
|
+
|
228
297
|
- Do not apply `Ezcater/StyleDig` to assignments to with nested access.
|
229
298
|
|
230
299
|
## v0.49.1
|
300
|
+
|
231
301
|
- Add `Ezcater/RspecRequireBrowserMock` cop.
|
232
302
|
|
233
303
|
## v0.49.0
|
304
|
+
|
234
305
|
- Initial release.
|
235
306
|
- Add `Ezcater/RspecRequireFeatureFlagMock` cop.
|
236
307
|
- Add `Ezcater/RspecDotNotSelfDot` cop.
|
data/README.md
CHANGED
@@ -61,11 +61,11 @@ configuration for existing offenses and auto-correction.
|
|
61
61
|
|
62
62
|
This gem contains a script, `circle_rubocop.rb`, that can be used to run RuboCop in CI.
|
63
63
|
|
64
|
-
The behavior of the script is that all files are checked on
|
65
|
-
configuration has changed. On non-
|
64
|
+
The behavior of the script is that all files are checked on main or if the rubocop
|
65
|
+
configuration has changed. On non-main branches, only the files added or changed on
|
66
66
|
the branch are checked.
|
67
67
|
|
68
|
-
For non-
|
68
|
+
For non-main branches, `[rubocop skip]` can be included in the commit message to skip
|
69
69
|
running rubocop.
|
70
70
|
|
71
71
|
## Versioning
|
@@ -74,15 +74,14 @@ This gem is using [Semantic Versioning](https://semver.org/). All version bumps
|
|
74
74
|
|
75
75
|
## Custom Cops
|
76
76
|
|
77
|
-
1. [RailsConfiguration](https://github.com/ezcater/ezcater_rubocop/blob/
|
78
|
-
1. [RequireGqlErrorHelpers](https://github.com/ezcater/ezcater_rubocop/blob/
|
79
|
-
1. [RspecDotNotSelfDot](https://github.com/ezcater/ezcater_rubocop/blob/
|
80
|
-
1. [RspecMatchOrderedArray](https://github.com/ezcater/ezcater_rubocop/blob/
|
81
|
-
1. [RspecRequireBrowserMock](https://github.com/ezcater/ezcater_rubocop/blob/
|
82
|
-
1. [RspecRequireFeatureFlagMock](https://github.com/ezcater/ezcater_rubocop/blob/
|
83
|
-
1. [RspecRequireHttpStatusMatcher](https://github.com/ezcater/ezcater_rubocop/blob/
|
84
|
-
1. [StyleDig](https://github.com/ezcater/ezcater_rubocop/blob/
|
85
|
-
1. [GraphqlFieldsNaming](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/graphql_fields_naming.rb) - Enforce the configured style when naming graphQL fields and arguments.
|
77
|
+
1. [RailsConfiguration](https://github.com/ezcater/ezcater_rubocop/blob/main/lib/rubocop/cop/ezcater/rails_configuration.rb) - Enforce use of `Rails.configuration` instead of `Rails.application.config`.
|
78
|
+
1. [RequireGqlErrorHelpers](https://github.com/ezcater/ezcater_rubocop/blob/main/lib/rubocop/cop/ezcater/require_gql_error_helpers.rb) - Use the helpers provided by `GQLErrors` instead of raising `GraphQL::ExecutionError` directly.
|
79
|
+
1. [RspecDotNotSelfDot](https://github.com/ezcater/ezcater_rubocop/blob/main/lib/rubocop/cop/ezcater/rspec_dot_not_self_dot.rb) - Enforce ".<class method>" instead of "self.<class method>" and "::<class method>" for example group description.
|
80
|
+
1. [RspecMatchOrderedArray](https://github.com/ezcater/ezcater_rubocop/blob/main/lib/rubocop/cop/ezcater/rspec_match_ordered_array.rb) - Enforce use of `match_ordered_array` matcher instead of `eq` matcher. This matcher comes from the [ezcater_matchers](https://github.com/ezcater/ezcater_matchers) gem.
|
81
|
+
1. [RspecRequireBrowserMock](https://github.com/ezcater/ezcater_rubocop/blob/main/lib/rubocop/cop/ezcater/rspec_require_browser_mock.rb) - Enforce use of `mock_ezcater_app`, `mock_chrome_browser` & `mock_custom_browser` helpers instead of mocking `Browser` or `EzBrowser` directly.
|
82
|
+
1. [RspecRequireFeatureFlagMock](https://github.com/ezcater/ezcater_rubocop/blob/main/lib/rubocop/cop/ezcater/rspec_require_feature_flag_mock.rb) - Enforce use of `mock_feature_flag` helper instead of mocking `FeatureFlag.is_active?` directly.
|
83
|
+
1. [RspecRequireHttpStatusMatcher](https://github.com/ezcater/ezcater_rubocop/blob/main/lib/rubocop/cop/ezcater/rspec_require_http_status_matcher.rb) - Use the HTTP status code matcher, like `expect(response).to have_http_status :bad_request`, rather than `expect(response.code).to eq 400`
|
84
|
+
1. [StyleDig](https://github.com/ezcater/ezcater_rubocop/blob/main/lib/rubocop/cop/ezcater/style_dig.rb) - Recommend `dig` for deeply nested access.
|
86
85
|
|
87
86
|
## Development
|
88
87
|
|
data/bin/circle_rubocop.rb
CHANGED
@@ -4,10 +4,10 @@
|
|
4
4
|
require "English"
|
5
5
|
|
6
6
|
# This script is used to run Rubocop in CircleCI so that on branches only
|
7
|
-
# the changed files are checked and on
|
7
|
+
# the changed files are checked and on main all files are checked.
|
8
8
|
#
|
9
9
|
# Additionally if rubocop configuration is changed, all files are checked, and
|
10
|
-
# if the commit description on a non-
|
10
|
+
# if the commit description on a non-main branch includes [rubocop skip]
|
11
11
|
# then rubocop is skipped.
|
12
12
|
|
13
13
|
def run(command)
|
@@ -20,7 +20,7 @@ def rubocop_everything
|
|
20
20
|
end
|
21
21
|
|
22
22
|
begin
|
23
|
-
if ENV["CIRCLE_BRANCH"] == "
|
23
|
+
if ENV["CIRCLE_BRANCH"] == "main"
|
24
24
|
rubocop_everything
|
25
25
|
else
|
26
26
|
git_commit_desc = `git log --format=%B -n 1 $CIRCLE_SHA1`
|
@@ -30,7 +30,7 @@ begin
|
|
30
30
|
exit 0
|
31
31
|
end
|
32
32
|
|
33
|
-
changed_files = `git diff --diff-filter=d --name-only origin/
|
33
|
+
changed_files = `git diff --diff-filter=d --name-only origin/main...$CIRCLE_BRANCH`.split("\n").join(" ")
|
34
34
|
raise "Failed to identify changed files" unless $CHILD_STATUS.success?
|
35
35
|
|
36
36
|
if changed_files.strip.empty? || changed_files.include?(".rubocop")
|
data/conf/rubocop.yml
CHANGED
@@ -3,6 +3,7 @@ require: ezcater_rubocop
|
|
3
3
|
AllCops:
|
4
4
|
DisplayCopNames: true
|
5
5
|
NewCops: disable
|
6
|
+
SuggestExtensions: false
|
6
7
|
|
7
8
|
Layout/FirstHashElementIndentation:
|
8
9
|
EnforcedStyle: consistent
|
@@ -21,8 +22,8 @@ Metrics/AbcSize:
|
|
21
22
|
|
22
23
|
Metrics/BlockLength:
|
23
24
|
Exclude:
|
24
|
-
|
25
|
-
|
25
|
+
- "*.gemspec"
|
26
|
+
- "spec/**/*.rb"
|
26
27
|
|
27
28
|
Metrics/CyclomaticComplexity:
|
28
29
|
Enabled: false
|
@@ -30,7 +31,7 @@ Metrics/CyclomaticComplexity:
|
|
30
31
|
Layout/LineLength:
|
31
32
|
Max: 120
|
32
33
|
Exclude:
|
33
|
-
|
34
|
+
- "Gemfile"
|
34
35
|
|
35
36
|
Metrics/MethodLength:
|
36
37
|
Enabled: true
|
@@ -45,9 +46,9 @@ Naming/MemoizedInstanceVariableName:
|
|
45
46
|
|
46
47
|
Naming/MethodParameterName:
|
47
48
|
AllowedNames:
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
- e
|
50
|
+
- ex
|
51
|
+
- id
|
51
52
|
|
52
53
|
Naming/VariableNumber:
|
53
54
|
Enabled: false
|
@@ -60,12 +61,12 @@ RSpec/ContextWording:
|
|
60
61
|
|
61
62
|
RSpec/DescribeClass:
|
62
63
|
Exclude:
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
- "spec/requests/**/*.rb"
|
65
|
+
- "spec/features/**/*.rb"
|
66
|
+
- "spec/routing/**/*.rb"
|
67
|
+
- "spec/views/**/*.rb"
|
68
|
+
- "spec/system/**/*.rb"
|
69
|
+
- "spec/integrations/**/*.rb"
|
69
70
|
|
70
71
|
RSpec/ExampleLength:
|
71
72
|
Max: 25
|
@@ -113,12 +114,12 @@ Style/NumericLiterals:
|
|
113
114
|
|
114
115
|
Style/PercentLiteralDelimiters:
|
115
116
|
PreferredDelimiters:
|
116
|
-
default:
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
117
|
+
default: "()"
|
118
|
+
"%i": "()"
|
119
|
+
"%I": "()"
|
120
|
+
"%r": "{}"
|
121
|
+
"%w": "()"
|
122
|
+
"%W": "()"
|
122
123
|
|
123
124
|
Style/RaiseArgs:
|
124
125
|
EnforcedStyle: compact
|
data/conf/rubocop_rails.yml
CHANGED
data/config/default.yml
CHANGED
@@ -1,61 +1,64 @@
|
|
1
|
-
Ezcater/GraphqlFieldsNaming:
|
2
|
-
EnforcedStyle: snake_case
|
3
|
-
Enabled: true
|
4
|
-
SupportedStyles:
|
5
|
-
- snake_case
|
6
|
-
- camelCase
|
7
|
-
Include:
|
8
|
-
- 'app/graphql/**/*.rb'
|
9
|
-
|
10
1
|
Ezcater/RailsConfiguration:
|
11
|
-
Description:
|
2
|
+
Description: "Enforce the use of `Rails.configuration` instead of `Rails.application.config`."
|
12
3
|
Enabled: true
|
13
4
|
|
14
5
|
Ezcater/RailsEnv:
|
15
|
-
Description:
|
6
|
+
Description: "Enforce the use of `Rails.configuration.x.<foo>` instead of checking `Rails.env`."
|
16
7
|
Enabled: false
|
17
8
|
|
18
9
|
Ezcater/DirectEnvCheck:
|
19
|
-
Description:
|
10
|
+
Description: "Enforce the use of `Rails.configuration.x.<foo>` instead of checking `ENV`."
|
20
11
|
Enabled: false
|
21
12
|
|
22
13
|
Ezcater/FeatureFlagActive:
|
23
|
-
Description:
|
14
|
+
Description: "Enforce the proper arguments are given to EzcaterFeatureFlag.active?"
|
24
15
|
Enabled: true
|
25
16
|
|
26
17
|
Ezcater/RspecDotNotSelfDot:
|
27
18
|
Description: 'Enforce ".<class method>" instead of "self.<class method>" for example group description.'
|
28
19
|
Enabled: true
|
29
20
|
Include:
|
30
|
-
-
|
21
|
+
- "**/*_spec.rb"
|
31
22
|
|
32
23
|
Ezcater/RspecRequireBrowserMock:
|
33
|
-
Description:
|
24
|
+
Description: "Enforce use of `mock_ezcater_app`, `mock_chrome_browser` & `mock_custom_browser` helpers instead of mocking `Browser` or `EzBrowser` directly."
|
34
25
|
Enabled: true
|
35
26
|
Include:
|
36
|
-
-
|
27
|
+
- "**/*_spec.rb"
|
37
28
|
|
38
29
|
Ezcater/RspecRequireFeatureFlagMock:
|
39
|
-
Description:
|
30
|
+
Description: "Enforce use of `mock_feature_flag` helpers instead of mocking `FeatureFlag.is_active?` directly."
|
40
31
|
Enabled: true
|
41
32
|
Include:
|
42
|
-
-
|
33
|
+
- "**/*_spec.rb"
|
43
34
|
|
44
35
|
Ezcater/RspecRequireHttpStatusMatcher:
|
45
|
-
Description:
|
36
|
+
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
37
|
Enabled: true
|
47
38
|
Include:
|
48
|
-
-
|
39
|
+
- "**/*_spec.rb"
|
49
40
|
|
50
41
|
Ezcater/RequireGqlErrorHelpers:
|
51
|
-
Description:
|
42
|
+
Description: "Use the helpers provided by `GQLErrors` instead of raising `GraphQL::ExecutionError` directly."
|
52
43
|
Enabled: true
|
53
44
|
|
54
45
|
Ezcater/StyleDig:
|
55
|
-
Description:
|
46
|
+
Description: "Recommend `dig` for deeply nested access."
|
56
47
|
Enabled: true
|
57
48
|
AutoCorrect: false
|
58
49
|
|
59
50
|
Ezcater/RubyTimeout:
|
60
|
-
Description:
|
51
|
+
Description: "Disallow use of `Timeout.timeout` because it is unsafe and can cause unexpected behavior."
|
61
52
|
Enabled: true
|
53
|
+
|
54
|
+
GraphQL/FieldDescription:
|
55
|
+
Enabled: false
|
56
|
+
GraphQL/ArgumentDescription:
|
57
|
+
Enabled: false
|
58
|
+
GraphQL/ObjectDescription:
|
59
|
+
Include:
|
60
|
+
- "**/types/**/*.rb"
|
61
|
+
- "**/mutations/**/*.rb"
|
62
|
+
GraphQL/ExtractInputType:
|
63
|
+
Exclude:
|
64
|
+
- "**/input_objects/**/*.rb"
|
data/ezcater_rubocop.gemspec
CHANGED
@@ -44,15 +44,16 @@ Gem::Specification.new do |spec|
|
|
44
44
|
|
45
45
|
spec.required_ruby_version = ">= 2.6"
|
46
46
|
|
47
|
-
spec.add_development_dependency "bundler"
|
47
|
+
spec.add_development_dependency "bundler"
|
48
48
|
spec.add_development_dependency "pry-byebug"
|
49
|
-
spec.add_development_dependency "rake", "~>
|
50
|
-
spec.add_development_dependency "rspec", "~> 3.
|
49
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
50
|
+
spec.add_development_dependency "rspec", "~> 3.11"
|
51
51
|
spec.add_development_dependency "rspec_junit_formatter"
|
52
|
-
spec.add_development_dependency "simplecov"
|
52
|
+
spec.add_development_dependency "simplecov"
|
53
53
|
|
54
|
-
spec.add_runtime_dependency "parser", "
|
55
|
-
spec.add_runtime_dependency "rubocop", "
|
56
|
-
spec.add_runtime_dependency "rubocop-
|
57
|
-
spec.add_runtime_dependency "rubocop-
|
54
|
+
spec.add_runtime_dependency "parser", ">= 2.6"
|
55
|
+
spec.add_runtime_dependency "rubocop", ">= 1.16.0", "< 2.0"
|
56
|
+
spec.add_runtime_dependency "rubocop-graphql", ">= 0.14.0", "< 1.0"
|
57
|
+
spec.add_runtime_dependency "rubocop-rails", ">= 2.10.1", "< 3.0"
|
58
|
+
spec.add_runtime_dependency "rubocop-rspec", ">= 2.3.0", "< 3.0"
|
58
59
|
end
|
data/lib/ezcater_rubocop.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "ezcater_rubocop/version"
|
4
|
+
require "rubocop-graphql"
|
4
5
|
require "rubocop-rails"
|
5
6
|
require "rubocop-rspec"
|
6
7
|
|
@@ -17,7 +18,6 @@ RuboCop::ConfigLoader.instance_variable_set(:@default_configuration, config)
|
|
17
18
|
|
18
19
|
require "rubocop/cop/ezcater/direct_env_check"
|
19
20
|
require "rubocop/cop/ezcater/feature_flag_active"
|
20
|
-
require "rubocop/cop/ezcater/graphql_fields_naming"
|
21
21
|
require "rubocop/cop/ezcater/rails_configuration"
|
22
22
|
require "rubocop/cop/ezcater/rails_env"
|
23
23
|
require "rubocop/cop/ezcater/ruby_timeout"
|
@@ -25,26 +25,44 @@ module RuboCop
|
|
25
25
|
|
26
26
|
class RspecDotNotSelfDot < Cop
|
27
27
|
include RuboCop::RSpec::Language
|
28
|
+
extend RuboCop::RSpec::Language::NodePattern
|
28
29
|
|
29
|
-
|
30
|
-
|
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 # rubocop:disable Style/RedundantFreeze
|
39
|
+
COLON_COLON_REGEXP = /\A(\:\:)/.freeze # rubocop:disable Style/RedundantFreeze
|
31
40
|
|
32
41
|
SELF_DOT_MSG = 'Use ".<class method>" instead of "self.<class method>" for example group description.'
|
33
42
|
COLON_COLON_MSG = 'Use ".<class method>" instead of "::<class method>" for example group description.'
|
34
43
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
44
|
+
def_node_matcher :example_group?, <<~PATTERN
|
45
|
+
(block
|
46
|
+
(send #rspec? {#{EXAMPLE_GROUP_IDENTIFIERS.map { |i| ":#{i}" }.join(' ')}}
|
47
|
+
(str ...) ...
|
48
|
+
) ...
|
49
|
+
)
|
50
|
+
PATTERN
|
51
|
+
|
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)
|
42
60
|
end
|
43
61
|
end
|
44
62
|
|
45
63
|
def autocorrect(node)
|
46
64
|
lambda do |corrector|
|
47
|
-
experession_end = node.source.match?(
|
65
|
+
experession_end = node.source.match?("::") ? 3 : 6
|
48
66
|
corrector.replace(Parser::Source::Range.new(node.source_range.source_buffer,
|
49
67
|
node.source_range.begin_pos + 1,
|
50
68
|
node.source_range.begin_pos + experession_end), ".")
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ezcater_rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
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-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
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: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pry-byebug
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,28 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '13.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '13.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
61
|
+
version: '3.11'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '3.
|
68
|
+
version: '3.11'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec_junit_formatter
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,72 +84,110 @@ dependencies:
|
|
84
84
|
name: simplecov
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0
|
89
|
+
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0
|
96
|
+
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: parser
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 2.
|
103
|
+
version: '2.6'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 2.
|
110
|
+
version: '2.6'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rubocop
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: 1.16.0
|
118
|
+
- - "<"
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '2.0'
|
118
121
|
type: :runtime
|
119
122
|
prerelease: false
|
120
123
|
version_requirements: !ruby/object:Gem::Requirement
|
121
124
|
requirements:
|
122
|
-
- - "
|
125
|
+
- - ">="
|
123
126
|
- !ruby/object:Gem::Version
|
124
127
|
version: 1.16.0
|
128
|
+
- - "<"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '2.0'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: rubocop-graphql
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 0.14.0
|
138
|
+
- - "<"
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '1.0'
|
141
|
+
type: :runtime
|
142
|
+
prerelease: false
|
143
|
+
version_requirements: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: 0.14.0
|
148
|
+
- - "<"
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '1.0'
|
125
151
|
- !ruby/object:Gem::Dependency
|
126
152
|
name: rubocop-rails
|
127
153
|
requirement: !ruby/object:Gem::Requirement
|
128
154
|
requirements:
|
129
|
-
- - "
|
155
|
+
- - ">="
|
130
156
|
- !ruby/object:Gem::Version
|
131
157
|
version: 2.10.1
|
158
|
+
- - "<"
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '3.0'
|
132
161
|
type: :runtime
|
133
162
|
prerelease: false
|
134
163
|
version_requirements: !ruby/object:Gem::Requirement
|
135
164
|
requirements:
|
136
|
-
- - "
|
165
|
+
- - ">="
|
137
166
|
- !ruby/object:Gem::Version
|
138
167
|
version: 2.10.1
|
168
|
+
- - "<"
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '3.0'
|
139
171
|
- !ruby/object:Gem::Dependency
|
140
172
|
name: rubocop-rspec
|
141
173
|
requirement: !ruby/object:Gem::Requirement
|
142
174
|
requirements:
|
143
|
-
- - "
|
175
|
+
- - ">="
|
144
176
|
- !ruby/object:Gem::Version
|
145
177
|
version: 2.3.0
|
178
|
+
- - "<"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '3.0'
|
146
181
|
type: :runtime
|
147
182
|
prerelease: false
|
148
183
|
version_requirements: !ruby/object:Gem::Requirement
|
149
184
|
requirements:
|
150
|
-
- - "
|
185
|
+
- - ">="
|
151
186
|
- !ruby/object:Gem::Version
|
152
187
|
version: 2.3.0
|
188
|
+
- - "<"
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '3.0'
|
153
191
|
description: ezCater custom cops and shared configuration
|
154
192
|
email:
|
155
193
|
- engineering@ezcater.com
|
@@ -160,6 +198,7 @@ extra_rdoc_files: []
|
|
160
198
|
files:
|
161
199
|
- ".github/CODEOWNERS"
|
162
200
|
- ".github/PULL_REQUEST_TEMPLATE.md"
|
201
|
+
- ".tool-versions"
|
163
202
|
- CHANGELOG.md
|
164
203
|
- Gemfile
|
165
204
|
- LICENSE.txt
|
@@ -174,7 +213,6 @@ files:
|
|
174
213
|
- lib/ezcater_rubocop/version.rb
|
175
214
|
- lib/rubocop/cop/ezcater/direct_env_check.rb
|
176
215
|
- lib/rubocop/cop/ezcater/feature_flag_active.rb
|
177
|
-
- lib/rubocop/cop/ezcater/graphql_fields_naming.rb
|
178
216
|
- lib/rubocop/cop/ezcater/rails_configuration.rb
|
179
217
|
- lib/rubocop/cop/ezcater/rails_env.rb
|
180
218
|
- lib/rubocop/cop/ezcater/rails_top_level_sql_execute.rb
|
@@ -207,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
245
|
- !ruby/object:Gem::Version
|
208
246
|
version: '0'
|
209
247
|
requirements: []
|
210
|
-
rubygems_version: 3.
|
248
|
+
rubygems_version: 3.3.7
|
211
249
|
signing_key:
|
212
250
|
specification_version: 4
|
213
251
|
summary: ezCater custom cops and shared configuration
|
@@ -1,74 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
module Ezcater
|
6
|
-
# This cop makes sure that GraphQL fields & arguments match the supported style
|
7
|
-
# https://git.io/JeofW
|
8
|
-
#
|
9
|
-
# The cop also ignores when users provide a :camelize option, because
|
10
|
-
# the user is manually requesting to override the value
|
11
|
-
#
|
12
|
-
# @example
|
13
|
-
# # bad
|
14
|
-
# field :fooBar, ID, null: false
|
15
|
-
# argument :barBaz, ID, required: true
|
16
|
-
#
|
17
|
-
# # good
|
18
|
-
# field :foo_bar, ID, null: true
|
19
|
-
# field :foo_bar, ID, null: true do
|
20
|
-
# argument :bar_baz, ID, required: true
|
21
|
-
# end
|
22
|
-
#
|
23
|
-
# field :fooBar, ID, null: true, camelize: true
|
24
|
-
#
|
25
|
-
class GraphqlFieldsNaming < Cop
|
26
|
-
include ConfigurableNaming
|
27
|
-
|
28
|
-
MSG = "Use %<style>s for GraphQL fields & arguments names. " \
|
29
|
-
"See https://git.io/JeofW for our guide. " \
|
30
|
-
"This can be overridden with camelize."
|
31
|
-
FIELD_ADDING_METHODS = %i(field argument).freeze
|
32
|
-
PROCESSABLE_TYPES = %i(sym string).freeze
|
33
|
-
|
34
|
-
def on_send(node)
|
35
|
-
method = method_name(node)
|
36
|
-
first_arg = node.first_argument
|
37
|
-
|
38
|
-
return unless FIELD_ADDING_METHODS.include? method
|
39
|
-
return unless PROCESSABLE_TYPES.include?(first_arg&.type)
|
40
|
-
|
41
|
-
return if includes_camelize?(node)
|
42
|
-
|
43
|
-
check_name(node, first_arg.value, node.first_argument)
|
44
|
-
end
|
45
|
-
|
46
|
-
alias on_super on_send
|
47
|
-
alias on_yield on_send
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def includes_camelize?(node)
|
52
|
-
results = []
|
53
|
-
node.last_argument.each_child_node { |arg| results << args_include_camelize?(arg) }
|
54
|
-
results.any?
|
55
|
-
end
|
56
|
-
|
57
|
-
def args_include_camelize?(arg_pair)
|
58
|
-
key_node = arg_pair.key
|
59
|
-
_value_node = arg_pair.value
|
60
|
-
|
61
|
-
key_node.value.match?(/camelize/)
|
62
|
-
end
|
63
|
-
|
64
|
-
def method_name(node)
|
65
|
-
node.children[1]
|
66
|
-
end
|
67
|
-
|
68
|
-
def message(style)
|
69
|
-
format(MSG, style: style)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|