rubocop-sorbet 0.4.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,6 +41,37 @@ FooOrBar = T.any(Foo, Bar)
41
41
  FooOrBar = T.type_alias { T.any(Foo, Bar) }
42
42
  ```
43
43
 
44
+ ## Sorbet/CallbackConditionalsBinding
45
+
46
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
47
+ --- | --- | --- | --- | ---
48
+ Enabled | Yes | Yes | 0.7.0 | -
49
+
50
+ This cop ensures that callback conditionals are bound to the right type
51
+ so that they are type checked properly.
52
+
53
+ ### Examples
54
+
55
+ ```ruby
56
+ # bad
57
+ class Post < ApplicationRecord
58
+ before_create :do_it, if: -> { should_do_it? }
59
+
60
+ def should_do_it?
61
+ true
62
+ end
63
+ end
64
+
65
+ # good
66
+ class Post < ApplicationRecord
67
+ before_create :do_it, if: -> { T.bind(self, Post).should_do_it? }
68
+
69
+ def should_do_it?
70
+ true
71
+ end
72
+ end
73
+ ```
74
+
44
75
  ## Sorbet/CheckedTrueInSignature
45
76
 
46
77
  Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
@@ -167,31 +198,115 @@ This cop makes the Sorbet `false` sigil mandatory in all files.
167
198
 
168
199
  Name | Default value | Configurable values
169
200
  --- | --- | ---
170
- SuggestedStrictness | `true` | Boolean
201
+ SuggestedStrictness | `false` | String
171
202
  Include | `**/*.rb`, `**/*.rbi`, `**/*.rake`, `**/*.ru` | Array
172
203
  Exclude | `bin/**/*`, `db/**/*.rb`, `script/**/*` | Array
173
204
 
205
+ ## Sorbet/ForbidExtendTSigHelpersInShims
206
+
207
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
208
+ --- | --- | --- | --- | ---
209
+ Enabled | Yes | Yes | 0.6.0 | -
210
+
211
+ This cop ensures RBI shims do not include a call to extend T::Sig
212
+ or to extend T::Helpers
213
+
214
+ ### Examples
215
+
216
+ ```ruby
217
+ # bad
218
+ module SomeModule
219
+ extend T::Sig
220
+ extend T::Helpers
221
+
222
+ sig { returns(String) }
223
+ def foo; end
224
+ end
225
+
226
+ # good
227
+ module SomeModule
228
+ sig { returns(String) }
229
+ def foo; end
230
+ end
231
+ ```
232
+
233
+ ### Configurable attributes
234
+
235
+ Name | Default value | Configurable values
236
+ --- | --- | ---
237
+ Include | `**/*.rbi` | Array
238
+
174
239
  ## Sorbet/ForbidIncludeConstLiteral
175
240
 
176
241
  Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
177
242
  --- | --- | --- | --- | ---
178
- Enabled | Yes | Yes | 0.2.0 | -
243
+ Disabled | Yes | No | 0.2.0 | 0.5.0
179
244
 
180
245
  No documentation
181
246
 
247
+ ## Sorbet/ForbidRBIOutsideOfSorbetDir
248
+
249
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
250
+ --- | --- | --- | --- | ---
251
+ Enabled | Yes | No | 0.6.1 | -
252
+
253
+ This cop makes sure that RBI files are always located under sorbet/rbi/.
254
+
255
+ ### Examples
256
+
257
+ ```ruby
258
+ # bad
259
+ lib/some_file.rbi
260
+ other_file.rbi
261
+
262
+ # good
263
+ sorbet/rbi/some_file.rbi
264
+ sorbet/rbi/any/path/for/file.rbi
265
+ ```
266
+
267
+ ### Configurable attributes
268
+
269
+ Name | Default value | Configurable values
270
+ --- | --- | ---
271
+ Include | `**/*.rbi` | Array
272
+
182
273
  ## Sorbet/ForbidSuperclassConstLiteral
183
274
 
184
275
  Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
185
276
  --- | --- | --- | --- | ---
186
- Enabled | Yes | Yes | 0.2.0 | -
277
+ Disabled | Yes | No | 0.2.0 | 0.6.1
187
278
 
188
279
  No documentation
189
280
 
281
+ ### Configurable attributes
282
+
283
+ Name | Default value | Configurable values
284
+ --- | --- | ---
285
+ Exclude | `db/migrate/*.rb` | Array
286
+
287
+ ## Sorbet/ForbidTUnsafe
288
+
289
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
290
+ --- | --- | --- | --- | ---
291
+ Disabled | Yes | No | 0.7.0 | 0.7.0
292
+
293
+ This cop disallows using `T.unsafe` anywhere.
294
+
295
+ ### Examples
296
+
297
+ ```ruby
298
+ # bad
299
+ T.unsafe(foo)
300
+
301
+ # good
302
+ foo
303
+ ```
304
+
190
305
  ## Sorbet/ForbidUntypedStructProps
191
306
 
192
307
  Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
193
308
  --- | --- | --- | --- | ---
194
- Enabled | Yes | No | 0.3.8 | -
309
+ Enabled | Yes | No | 0.4.0 | -
195
310
 
196
311
  This cop disallows use of `T.untyped` or `T.nilable(T.untyped)`
197
312
  as a prop type for `T::Struct`.
@@ -227,6 +342,13 @@ Options:
227
342
 
228
343
  If a `MinimumStrictness` level is specified, it will be used in offense messages and autocorrect.
229
344
 
345
+ ### Configurable attributes
346
+
347
+ Name | Default value | Configurable values
348
+ --- | --- | ---
349
+ SuggestedStrictness | `false` | String
350
+ MinimumStrictness | `false` | String
351
+
230
352
  ## Sorbet/IgnoreSigil
231
353
 
232
354
  Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
@@ -235,6 +357,12 @@ Disabled | Yes | Yes | 0.3.3 | -
235
357
 
236
358
  This cop makes the Sorbet `ignore` sigil mandatory in all files.
237
359
 
360
+ ### Configurable attributes
361
+
362
+ Name | Default value | Configurable values
363
+ --- | --- | ---
364
+ SuggestedStrictness | `ignore` | String
365
+
238
366
  ## Sorbet/KeywordArgumentOrdering
239
367
 
240
368
  Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
@@ -258,6 +386,30 @@ sig { params(b: String, a: Integer).void }
258
386
  def foo(b:, a: 1); end
259
387
  ```
260
388
 
389
+ ## Sorbet/OneAncestorPerLine
390
+
391
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
392
+ --- | --- | --- | --- | ---
393
+ Disabled | Yes | Yes | 0.6.0 | -
394
+
395
+ This cop ensures one ancestor per requires_ancestor line
396
+ rather than chaining them as a comma-separated list.
397
+
398
+ ### Examples
399
+
400
+ ```ruby
401
+ # bad
402
+ module SomeModule
403
+ requires_ancestor Kernel, Minitest::Assertions
404
+ end
405
+
406
+ # good
407
+ module SomeModule
408
+ requires_ancestor Kernel
409
+ requires_ancestor Minitest::Assertions
410
+ end
411
+ ```
412
+
261
413
  ## Sorbet/ParametersOrderingInSignature
262
414
 
263
415
  Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
@@ -298,6 +450,32 @@ Abstract cop specific to Sorbet signatures
298
450
 
299
451
  You can subclass it to use the `on_signature` trigger and the `signature?` node matcher.
300
452
 
453
+ ## Sorbet/SingleLineRbiClassModuleDefinitions
454
+
455
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
456
+ --- | --- | --- | --- | ---
457
+ Disabled | Yes | Yes | 0.6.0 | -
458
+
459
+ This cop ensures empty class/module definitions in RBI files are
460
+ done on a single line rather than being split across multiple lines.
461
+
462
+ ### Examples
463
+
464
+ ```ruby
465
+ # bad
466
+ module SomeModule
467
+ end
468
+
469
+ # good
470
+ module SomeModule; end
471
+ ```
472
+
473
+ ### Configurable attributes
474
+
475
+ Name | Default value | Configurable values
476
+ --- | --- | ---
477
+ Include | `**/*.rbi` | Array
478
+
301
479
  ## Sorbet/StrictSigil
302
480
 
303
481
  Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
@@ -306,6 +484,12 @@ Disabled | Yes | Yes | 0.3.3 | -
306
484
 
307
485
  This cop makes the Sorbet `strict` sigil mandatory in all files.
308
486
 
487
+ ### Configurable attributes
488
+
489
+ Name | Default value | Configurable values
490
+ --- | --- | ---
491
+ SuggestedStrictness | `strict` | String
492
+
309
493
  ## Sorbet/StrongSigil
310
494
 
311
495
  Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
@@ -314,6 +498,12 @@ Disabled | Yes | Yes | 0.3.3 | -
314
498
 
315
499
  This cop makes the Sorbet `strong` sigil mandatory in all files.
316
500
 
501
+ ### Configurable attributes
502
+
503
+ Name | Default value | Configurable values
504
+ --- | --- | ---
505
+ SuggestedStrictness | `strong` | String
506
+
317
507
  ## Sorbet/TrueSigil
318
508
 
319
509
  Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
@@ -322,6 +512,12 @@ Disabled | Yes | Yes | 0.3.3 | -
322
512
 
323
513
  This cop makes the Sorbet `true` sigil mandatory in all files.
324
514
 
515
+ ### Configurable attributes
516
+
517
+ Name | Default value | Configurable values
518
+ --- | --- | ---
519
+ SuggestedStrictness | `true` | String
520
+
325
521
  ## Sorbet/ValidSigil
326
522
 
327
523
  Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
@@ -338,3 +534,11 @@ Options:
338
534
  * `MinimumStrictness`: If set, make offense if the strictness level in the file is below this one
339
535
 
340
536
  If a `MinimumStrictness` level is specified, it will be used in offense messages and autocorrect.
537
+
538
+ ### Configurable attributes
539
+
540
+ Name | Default value | Configurable values
541
+ --- | --- | ---
542
+ RequireSigilOnAllFiles | `false` | Boolean
543
+ SuggestedStrictness | `false` | String
544
+ MinimumStrictness | `false` | String
data/service.yml CHANGED
@@ -1,6 +1,3 @@
1
- # https://services.shopify.io/services/rubocop-sorbet/production
2
- owners:
3
- - Shopify/sorbet
4
1
  classification: library
5
2
  slack_channels:
6
- - help-ruby-typing
3
+ - help-ruby-typing
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-sorbet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ufuk Kayserilioglu
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2020-08-20 00:00:00.000000000 Z
14
+ date: 2021-06-04 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec
@@ -65,11 +65,10 @@ files:
65
65
  - ".github/CODEOWNERS"
66
66
  - ".github/probots.yml"
67
67
  - ".github/stale.yml"
68
+ - ".github/workflows/ci.yml"
68
69
  - ".gitignore"
69
70
  - ".rspec"
70
71
  - ".rubocop.yml"
71
- - ".shopify-build/VERSION"
72
- - ".shopify-build/rubocop-sorbet.yml"
73
72
  - ".travis.yml"
74
73
  - CODE_OF_CONDUCT.md
75
74
  - Gemfile
@@ -79,15 +78,22 @@ files:
79
78
  - Rakefile
80
79
  - bin/console
81
80
  - bin/rspec
81
+ - bin/rubocop
82
82
  - bin/setup
83
83
  - config/default.yml
84
84
  - dev.yml
85
85
  - lib/rubocop-sorbet.rb
86
86
  - lib/rubocop/cop/sorbet/binding_constants_without_type_alias.rb
87
+ - lib/rubocop/cop/sorbet/callback_conditionals_binding.rb
87
88
  - lib/rubocop/cop/sorbet/constants_from_strings.rb
88
89
  - lib/rubocop/cop/sorbet/forbid_include_const_literal.rb
89
90
  - lib/rubocop/cop/sorbet/forbid_superclass_const_literal.rb
91
+ - lib/rubocop/cop/sorbet/forbid_t_unsafe.rb
90
92
  - lib/rubocop/cop/sorbet/forbid_untyped_struct_props.rb
93
+ - lib/rubocop/cop/sorbet/one_ancestor_per_line.rb
94
+ - lib/rubocop/cop/sorbet/rbi/forbid_extend_t_sig_helpers_in_shims.rb
95
+ - lib/rubocop/cop/sorbet/rbi/forbid_rbi_outside_of_sorbet_dir.rb
96
+ - lib/rubocop/cop/sorbet/rbi/single_line_rbi_class_module_definitions.rb
91
97
  - lib/rubocop/cop/sorbet/sigils/enforce_sigil_order.rb
92
98
  - lib/rubocop/cop/sorbet/sigils/false_sigil.rb
93
99
  - lib/rubocop/cop/sorbet/sigils/has_sigil.rb
@@ -135,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
141
  - !ruby/object:Gem::Version
136
142
  version: '0'
137
143
  requirements: []
138
- rubygems_version: 3.0.3
144
+ rubygems_version: 3.2.17
139
145
  signing_key:
140
146
  specification_version: 4
141
147
  summary: Automatic Sorbet code style checking tool.
@@ -1 +0,0 @@
1
- v1
@@ -1,16 +0,0 @@
1
- containers:
2
- default:
3
- docker: "circleci/ruby:2.5.5"
4
-
5
- steps:
6
- - label: ":ruby: Specs"
7
- dependencies:
8
- - "bundler"
9
- timeout: "5m"
10
- run:
11
- - "bundle exec rspec"
12
- - label: "Rubocop"
13
- dependencies:
14
- - "bundler"
15
- timeout: "5m"
16
- run: "bundle exec rubocop"