rubocop-sorbet 0.3.7 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +2 -0
  3. data/.github/probots.yml +1 -1
  4. data/.github/stale.yml +20 -0
  5. data/.gitignore +0 -2
  6. data/.rspec +3 -0
  7. data/.rubocop.yml +2 -12
  8. data/.travis.yml +3 -1
  9. data/Gemfile +6 -7
  10. data/Gemfile.lock +27 -42
  11. data/README.md +64 -6
  12. data/Rakefile +34 -5
  13. data/config/default.yml +143 -2
  14. data/lib/rubocop-sorbet.rb +9 -1
  15. data/lib/rubocop/cop/sorbet/binding_constants_without_type_alias.rb +24 -1
  16. data/lib/rubocop/cop/sorbet/forbid_extend_t_sig_helpers_in_shims.rb +53 -0
  17. data/lib/rubocop/cop/sorbet/forbid_include_const_literal.rb +0 -40
  18. data/lib/rubocop/cop/sorbet/forbid_superclass_const_literal.rb +0 -17
  19. data/lib/rubocop/cop/sorbet/forbid_untyped_struct_props.rb +58 -0
  20. data/lib/rubocop/cop/sorbet/one_ancestor_per_line.rb +75 -0
  21. data/lib/rubocop/cop/sorbet/sigils/enforce_sigil_order.rb +11 -1
  22. data/lib/rubocop/cop/sorbet/signatures/enforce_signatures.rb +19 -10
  23. data/lib/rubocop/cop/sorbet/signatures/parameters_ordering_in_signature.rb +14 -6
  24. data/lib/rubocop/cop/sorbet/signatures/signature_build_order.rb +22 -3
  25. data/lib/rubocop/cop/sorbet/single_line_rbi_class_module_definitions.rb +46 -0
  26. data/lib/rubocop/cop/sorbet_cops.rb +25 -0
  27. data/lib/rubocop/sorbet.rb +15 -0
  28. data/lib/rubocop/sorbet/inject.rb +20 -0
  29. data/lib/rubocop/sorbet/version.rb +6 -0
  30. data/manual/cops.md +32 -0
  31. data/manual/cops_sorbet.md +424 -0
  32. data/rubocop-sorbet.gemspec +18 -18
  33. data/service.yml +1 -1
  34. data/tasks/cops_documentation.rake +317 -0
  35. metadata +26 -12
  36. data/lib/rubocop_sorbet.rb +0 -22
@@ -55,9 +55,9 @@ module RuboCop
55
55
  return nil unless can_autocorrect?
56
56
 
57
57
  lambda do |corrector|
58
- nodes = call_chain(node).sort_by { |call| ORDER[call.method_name] }
59
- tree =
60
- nodes.reduce(nil) do |receiver, caller|
58
+ tree = call_chain(node_reparsed_with_modern_features(node))
59
+ .sort_by { |call| ORDER[call.method_name] }
60
+ .reduce(nil) do |receiver, caller|
61
61
  caller.updated(nil, [receiver] + caller.children.drop(1))
62
62
  end
63
63
 
@@ -68,8 +68,27 @@ module RuboCop
68
68
  end
69
69
  end
70
70
 
71
+ # Create a subclass of AST Builder that has modern features turned on
72
+ class ModernBuilder < RuboCop::AST::Builder
73
+ modernize
74
+ end
75
+ private_constant :ModernBuilder
76
+
71
77
  private
72
78
 
79
+ # This method exists to reparse the current node with modern features enabled.
80
+ # Modern features include "index send" emitting, which is necessary to unparse
81
+ # "index sends" (i.e. `[]` calls) back to index accessors (i.e. as `foo[bar]``).
82
+ # Otherwise, we would get the unparsed node as `foo.[](bar)`.
83
+ def node_reparsed_with_modern_features(node)
84
+ # Create a new parser with a modern builder class instance
85
+ parser = Parser::CurrentRuby.new(ModernBuilder.new)
86
+ # Create a new source buffer with the node source
87
+ buffer = Parser::Source::Buffer.new(processed_source.path, source: node.source)
88
+ # Re-parse the buffer
89
+ parser.parse(buffer)
90
+ end
91
+
73
92
  def can_autocorrect?
74
93
  defined?(::Unparser)
75
94
  end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Sorbet
6
+ # This cop ensures empty class/module definitions in RBI files are
7
+ # done on a single line rather than being split across multiple lines.
8
+ #
9
+ # @example
10
+ #
11
+ # # bad
12
+ # module SomeModule
13
+ # end
14
+ #
15
+ # # good
16
+ # module SomeModule; end
17
+ class SingleLineRbiClassModuleDefinitions < RuboCop::Cop::Cop
18
+ MSG = 'Empty class/module definitions in RBI files should be on a single line.'
19
+
20
+ def on_module(node)
21
+ process_node(node)
22
+ end
23
+
24
+ def on_class(node)
25
+ process_node(node)
26
+ end
27
+
28
+ def autocorrect(node)
29
+ -> (corrector) { corrector.replace(node, convert_newlines(node.source)) }
30
+ end
31
+
32
+ protected
33
+
34
+ def convert_newlines(source)
35
+ source.sub(/[\r\n]+\s*[\r\n]*/, "; ")
36
+ end
37
+
38
+ def process_node(node)
39
+ return if node.body
40
+ return if node.single_line?
41
+ add_offense(node)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+ require_relative 'sorbet/binding_constants_without_type_alias'
3
+ require_relative 'sorbet/constants_from_strings'
4
+ require_relative 'sorbet/forbid_extend_t_sig_helpers_in_shims'
5
+ require_relative 'sorbet/forbid_superclass_const_literal'
6
+ require_relative 'sorbet/forbid_include_const_literal'
7
+ require_relative 'sorbet/forbid_untyped_struct_props'
8
+ require_relative 'sorbet/single_line_rbi_class_module_definitions'
9
+ require_relative 'sorbet/one_ancestor_per_line'
10
+
11
+ require_relative 'sorbet/signatures/allow_incompatible_override'
12
+ require_relative 'sorbet/signatures/checked_true_in_signature'
13
+ require_relative 'sorbet/signatures/keyword_argument_ordering'
14
+ require_relative 'sorbet/signatures/parameters_ordering_in_signature'
15
+ require_relative 'sorbet/signatures/signature_build_order'
16
+ require_relative 'sorbet/signatures/enforce_signatures'
17
+
18
+ require_relative 'sorbet/sigils/valid_sigil'
19
+ require_relative 'sorbet/sigils/has_sigil'
20
+ require_relative 'sorbet/sigils/ignore_sigil'
21
+ require_relative 'sorbet/sigils/false_sigil'
22
+ require_relative 'sorbet/sigils/true_sigil'
23
+ require_relative 'sorbet/sigils/strict_sigil'
24
+ require_relative 'sorbet/sigils/strong_sigil'
25
+ require_relative 'sorbet/sigils/enforce_sigil_order'
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ require "rubocop/sorbet/version"
3
+ require "yaml"
4
+
5
+ module RuboCop
6
+ module Sorbet
7
+ class Error < StandardError; end
8
+
9
+ PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
10
+ CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze
11
+ CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze
12
+
13
+ private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The original code is from https://github.com/rubocop-hq/rubocop-rspec/blob/master/lib/rubocop/rspec/inject.rb
4
+ # See https://github.com/rubocop-hq/rubocop-rspec/blob/master/MIT-LICENSE.md
5
+ module RuboCop
6
+ module Sorbet
7
+ # Because RuboCop doesn't yet support plugins, we have to monkey patch in a
8
+ # bit of our configuration.
9
+ module Inject
10
+ def self.defaults!
11
+ path = CONFIG_DEFAULT.to_s
12
+ hash = ConfigLoader.send(:load_yaml_configuration, path)
13
+ config = Config.new(hash, path).tap(&:make_excludes_absolute)
14
+ puts "configuration from #{path}" if ConfigLoader.debug?
15
+ config = ConfigLoader.merge_with_default(config, path)
16
+ ConfigLoader.instance_variable_set(:@default_configuration, config)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ module RuboCop
3
+ module Sorbet
4
+ VERSION = "0.6.0"
5
+ end
6
+ end
data/manual/cops.md ADDED
@@ -0,0 +1,32 @@
1
+ ## Available cops
2
+
3
+ In the following section you find all available cops:
4
+
5
+ <!-- START_COP_LIST -->
6
+ #### Department [Sorbet](cops_sorbet.md)
7
+
8
+ * [Sorbet/AllowIncompatibleOverride](cops_sorbet.md#sorbetallowincompatibleoverride)
9
+ * [Sorbet/BindingConstantWithoutTypeAlias](cops_sorbet.md#sorbetbindingconstantwithouttypealias)
10
+ * [Sorbet/CheckedTrueInSignature](cops_sorbet.md#sorbetcheckedtrueinsignature)
11
+ * [Sorbet/ConstantsFromStrings](cops_sorbet.md#sorbetconstantsfromstrings)
12
+ * [Sorbet/EnforceSigilOrder](cops_sorbet.md#sorbetenforcesigilorder)
13
+ * [Sorbet/EnforceSignatures](cops_sorbet.md#sorbetenforcesignatures)
14
+ * [Sorbet/FalseSigil](cops_sorbet.md#sorbetfalsesigil)
15
+ * [Sorbet/ForbidExtendTSigHelpersInShims](cops_sorbet.md#sorbetforbidextendtsighelpersinshims)
16
+ * [Sorbet/ForbidIncludeConstLiteral](cops_sorbet.md#sorbetforbidincludeconstliteral)
17
+ * [Sorbet/ForbidSuperclassConstLiteral](cops_sorbet.md#sorbetforbidsuperclassconstliteral)
18
+ * [Sorbet/ForbidUntypedStructProps](cops_sorbet.md#sorbetforbiduntypedstructprops)
19
+ * [Sorbet/HasSigil](cops_sorbet.md#sorbethassigil)
20
+ * [Sorbet/IgnoreSigil](cops_sorbet.md#sorbetignoresigil)
21
+ * [Sorbet/KeywordArgumentOrdering](cops_sorbet.md#sorbetkeywordargumentordering)
22
+ * [Sorbet/OneAncestorPerLine](cops_sorbet.md#sorbetoneancestorperline)
23
+ * [Sorbet/ParametersOrderingInSignature](cops_sorbet.md#sorbetparametersorderinginsignature)
24
+ * [Sorbet/SignatureBuildOrder](cops_sorbet.md#sorbetsignaturebuildorder)
25
+ * [Sorbet/SignatureCop](cops_sorbet.md#sorbetsignaturecop)
26
+ * [Sorbet/SingleLineRbiClassModuleDefinitions](cops_sorbet.md#sorbetsinglelinerbiclassmoduledefinitions)
27
+ * [Sorbet/StrictSigil](cops_sorbet.md#sorbetstrictsigil)
28
+ * [Sorbet/StrongSigil](cops_sorbet.md#sorbetstrongsigil)
29
+ * [Sorbet/TrueSigil](cops_sorbet.md#sorbettruesigil)
30
+ * [Sorbet/ValidSigil](cops_sorbet.md#sorbetvalidsigil)
31
+
32
+ <!-- END_COP_LIST -->
@@ -0,0 +1,424 @@
1
+ # Sorbet
2
+
3
+ ## Sorbet/AllowIncompatibleOverride
4
+
5
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
6
+ --- | --- | --- | --- | ---
7
+ Enabled | Yes | No | 0.2.0 | -
8
+
9
+ This cop disallows using `.override(allow_incompatible: true)`.
10
+ Using `allow_incompatible` suggests a violation of the Liskov
11
+ Substitution Principle, meaning that a subclass is not a valid
12
+ subtype of it's superclass. This Cop prevents these design smells
13
+ from occurring.
14
+
15
+ ### Examples
16
+
17
+ ```ruby
18
+ # bad
19
+ sig.override(allow_incompatible: true)
20
+
21
+ # good
22
+ sig.override
23
+ ```
24
+
25
+ ## Sorbet/BindingConstantWithoutTypeAlias
26
+
27
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
28
+ --- | --- | --- | --- | ---
29
+ Enabled | Yes | Yes | 0.2.0 | -
30
+
31
+ This cop disallows binding the return value of `T.any`, `T.all`, `T.enum`
32
+ to a constant directly. To bind the value, one must use `T.type_alias`.
33
+
34
+ ### Examples
35
+
36
+ ```ruby
37
+ # bad
38
+ FooOrBar = T.any(Foo, Bar)
39
+
40
+ # good
41
+ FooOrBar = T.type_alias { T.any(Foo, Bar) }
42
+ ```
43
+
44
+ ## Sorbet/CheckedTrueInSignature
45
+
46
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
47
+ --- | --- | --- | --- | ---
48
+ Enabled | Yes | No | 0.2.0 | -
49
+
50
+ This cop disallows the usage of `checked(true)`. This usage could cause
51
+ confusion; it could lead some people to believe that a method would be checked
52
+ even if runtime checks have not been enabled on the class or globally.
53
+ Additionally, in the event where checks are enabled, `checked(true)` would
54
+ be redundant; only `checked(false)` or `soft` would change the behaviour.
55
+
56
+ ### Examples
57
+
58
+ ```ruby
59
+ # bad
60
+ sig { void.checked(true) }
61
+
62
+ # good
63
+ sig { void }
64
+ ```
65
+
66
+ ## Sorbet/ConstantsFromStrings
67
+
68
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
69
+ --- | --- | --- | --- | ---
70
+ Enabled | Yes | No | 0.2.0 | -
71
+
72
+ This cop disallows the calls that are used to get constants fom Strings
73
+ such as +constantize+, +const_get+, and +constants+.
74
+
75
+ The goal of this cop is to make the code easier to statically analyze,
76
+ more IDE-friendly, and more predictable. It leads to code that clearly
77
+ expresses which values the constant can have.
78
+
79
+ ### Examples
80
+
81
+ ```ruby
82
+ # bad
83
+ class_name.constantize
84
+
85
+ # bad
86
+ constants.detect { |c| c.name == "User" }
87
+
88
+ # bad
89
+ const_get(class_name)
90
+
91
+ # good
92
+ case class_name
93
+ when "User"
94
+ User
95
+ else
96
+ raise ArgumentError
97
+ end
98
+
99
+ # good
100
+ { "User" => User }.fetch(class_name)
101
+ ```
102
+
103
+ ## Sorbet/EnforceSigilOrder
104
+
105
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
106
+ --- | --- | --- | --- | ---
107
+ Enabled | Yes | Yes | 0.3.4 | -
108
+
109
+ This cop checks that the Sorbet sigil comes as the first magic comment in the file.
110
+
111
+ The expected order for magic comments is: typed, (en)?coding, warn_indent then frozen_string_literal.
112
+
113
+ For example, the following bad ordering:
114
+
115
+ ```ruby
116
+ # frozen_string_literal: true
117
+ # typed: true
118
+ class Foo; end
119
+ ```
120
+
121
+ Will be corrected as:
122
+
123
+ ```ruby
124
+ # typed: true
125
+ # frozen_string_literal: true
126
+ class Foo; end
127
+ ```
128
+
129
+ Only `typed`, `(en)?coding`, `warn_indent` and `frozen_string_literal` magic comments are considered,
130
+ other comments or magic comments are left in the same place.
131
+
132
+ ## Sorbet/EnforceSignatures
133
+
134
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
135
+ --- | --- | --- | --- | ---
136
+ Disabled | Yes | Yes | 0.3.4 | -
137
+
138
+ This cop checks that every method definition and attribute accessor has a Sorbet signature.
139
+
140
+ It also suggest an autocorrect with placeholders so the following code:
141
+
142
+ ```
143
+ def foo(a, b, c); end
144
+ ```
145
+
146
+ Will be corrected as:
147
+
148
+ ```
149
+ sig { params(a: T.untyped, b: T.untyped, c: T.untyped).returns(T.untyped)
150
+ def foo(a, b, c); end
151
+ ```
152
+
153
+ You can configure the placeholders used by changing the following options:
154
+
155
+ * `ParameterTypePlaceholder`: placeholders used for parameter types (default: 'T.untyped')
156
+ * `ReturnTypePlaceholder`: placeholders used for return types (default: 'T.untyped')
157
+
158
+ ## Sorbet/FalseSigil
159
+
160
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
161
+ --- | --- | --- | --- | ---
162
+ Enabled | Yes | Yes | 0.3.3 | -
163
+
164
+ This cop makes the Sorbet `false` sigil mandatory in all files.
165
+
166
+ ### Configurable attributes
167
+
168
+ Name | Default value | Configurable values
169
+ --- | --- | ---
170
+ SuggestedStrictness | `true` | Boolean
171
+ Include | `**/*.rb`, `**/*.rbi`, `**/*.rake`, `**/*.ru` | Array
172
+ Exclude | `bin/**/*`, `db/**/*.rb`, `script/**/*` | Array
173
+
174
+ ## Sorbet/ForbidExtendTSigHelpersInShims
175
+
176
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
177
+ --- | --- | --- | --- | ---
178
+ Enabled | Yes | Yes | 0.6.0 | -
179
+
180
+ This cop ensures RBI shims do not include a call to extend T::Sig
181
+ or to extend T::Helpers
182
+
183
+ ### Examples
184
+
185
+ ```ruby
186
+ # bad
187
+ module SomeModule
188
+ extend T::Sig
189
+ extend T::Helpers
190
+
191
+ sig { returns(String) }
192
+ def foo; end
193
+ end
194
+
195
+ # good
196
+ module SomeModule
197
+ sig { returns(String) }
198
+ def foo; end
199
+ end
200
+ ```
201
+
202
+ ### Configurable attributes
203
+
204
+ Name | Default value | Configurable values
205
+ --- | --- | ---
206
+ Include | `**/*.rbi` | Array
207
+
208
+ ## Sorbet/ForbidIncludeConstLiteral
209
+
210
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
211
+ --- | --- | --- | --- | ---
212
+ Disabled | Yes | No | 0.2.0 | 0.5.0
213
+
214
+ No documentation
215
+
216
+ ## Sorbet/ForbidSuperclassConstLiteral
217
+
218
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
219
+ --- | --- | --- | --- | ---
220
+ Disabled | Yes | No | 0.2.0 | 0.5.0
221
+
222
+ No documentation
223
+
224
+ ## Sorbet/ForbidUntypedStructProps
225
+
226
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
227
+ --- | --- | --- | --- | ---
228
+ Enabled | Yes | No | 0.4.0 | -
229
+
230
+ This cop disallows use of `T.untyped` or `T.nilable(T.untyped)`
231
+ as a prop type for `T::Struct`.
232
+
233
+ ### Examples
234
+
235
+ ```ruby
236
+ # bad
237
+ class SomeClass
238
+ const :foo, T.untyped
239
+ prop :bar, T.nilable(T.untyped)
240
+ end
241
+
242
+ # good
243
+ class SomeClass
244
+ const :foo, Integer
245
+ prop :bar, T.nilable(String)
246
+ end
247
+ ```
248
+
249
+ ## Sorbet/HasSigil
250
+
251
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
252
+ --- | --- | --- | --- | ---
253
+ Disabled | Yes | Yes | 0.3.3 | -
254
+
255
+ This cop makes the Sorbet typed sigil mandatory in all files.
256
+
257
+ Options:
258
+
259
+ * `SuggestedStrictness`: Sorbet strictness level suggested in offense messages (default: 'false')
260
+ * `MinimumStrictness`: If set, make offense if the strictness level in the file is below this one
261
+
262
+ If a `MinimumStrictness` level is specified, it will be used in offense messages and autocorrect.
263
+
264
+ ## Sorbet/IgnoreSigil
265
+
266
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
267
+ --- | --- | --- | --- | ---
268
+ Disabled | Yes | Yes | 0.3.3 | -
269
+
270
+ This cop makes the Sorbet `ignore` sigil mandatory in all files.
271
+
272
+ ## Sorbet/KeywordArgumentOrdering
273
+
274
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
275
+ --- | --- | --- | --- | ---
276
+ Enabled | Yes | No | 0.2.0 | -
277
+
278
+ This cop checks for the ordering of keyword arguments required by
279
+ sorbet-runtime. The ordering requires that all keyword arguments
280
+ are at the end of the parameters list, and all keyword arguments
281
+ with a default value must be after those without default values.
282
+
283
+ ### Examples
284
+
285
+ ```ruby
286
+ # bad
287
+ sig { params(a: Integer, b: String).void }
288
+ def foo(a: 1, b:); end
289
+
290
+ # good
291
+ sig { params(b: String, a: Integer).void }
292
+ def foo(b:, a: 1); end
293
+ ```
294
+
295
+ ## Sorbet/OneAncestorPerLine
296
+
297
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
298
+ --- | --- | --- | --- | ---
299
+ Enabled | Yes | Yes | - | -
300
+
301
+ This cop ensures one ancestor per requires_ancestor line
302
+ rather than chaining them as a comma-separated list.
303
+
304
+ ### Examples
305
+
306
+ ```ruby
307
+ # bad
308
+ module SomeModule
309
+ requires_ancestor Kernel, Minitest::Assertions
310
+ end
311
+
312
+ # good
313
+ module SomeModule
314
+ requires_ancestor Kernel
315
+ requires_ancestor Minitest::Assertions
316
+ end
317
+ ```
318
+
319
+ ## Sorbet/ParametersOrderingInSignature
320
+
321
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
322
+ --- | --- | --- | --- | ---
323
+ Enabled | Yes | No | 0.2.0 | -
324
+
325
+ This cop checks for inconsistent ordering of parameters between the
326
+ signature and the method definition. The sorbet-runtime gem raises
327
+ when such inconsistency occurs.
328
+
329
+ ### Examples
330
+
331
+ ```ruby
332
+ # bad
333
+ sig { params(a: Integer, b: String).void }
334
+ def foo(b:, a:); end
335
+
336
+ # good
337
+ sig { params(a: Integer, b: String).void }
338
+ def foo(a:, b:); end
339
+ ```
340
+
341
+ ## Sorbet/SignatureBuildOrder
342
+
343
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
344
+ --- | --- | --- | --- | ---
345
+ Enabled | Yes | Yes | 0.3.0 | -
346
+
347
+ No documentation
348
+
349
+ ## Sorbet/SignatureCop
350
+
351
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
352
+ --- | --- | --- | --- | ---
353
+ Enabled | Yes | No | - | -
354
+
355
+ Abstract cop specific to Sorbet signatures
356
+
357
+ You can subclass it to use the `on_signature` trigger and the `signature?` node matcher.
358
+
359
+ ## Sorbet/SingleLineRbiClassModuleDefinitions
360
+
361
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
362
+ --- | --- | --- | --- | ---
363
+ Disabled | Yes | Yes | 0.6.0 | -
364
+
365
+ This cop ensures empty class/module definitions in RBI files are
366
+ done on a single line rather than being split across multiple lines.
367
+
368
+ ### Examples
369
+
370
+ ```ruby
371
+ # bad
372
+ module SomeModule
373
+ end
374
+
375
+ # good
376
+ module SomeModule; end
377
+ ```
378
+
379
+ ### Configurable attributes
380
+
381
+ Name | Default value | Configurable values
382
+ --- | --- | ---
383
+ Include | `**/*.rbi` | Array
384
+
385
+ ## Sorbet/StrictSigil
386
+
387
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
388
+ --- | --- | --- | --- | ---
389
+ Disabled | Yes | Yes | 0.3.3 | -
390
+
391
+ This cop makes the Sorbet `strict` sigil mandatory in all files.
392
+
393
+ ## Sorbet/StrongSigil
394
+
395
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
396
+ --- | --- | --- | --- | ---
397
+ Disabled | Yes | Yes | 0.3.3 | -
398
+
399
+ This cop makes the Sorbet `strong` sigil mandatory in all files.
400
+
401
+ ## Sorbet/TrueSigil
402
+
403
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
404
+ --- | --- | --- | --- | ---
405
+ Disabled | Yes | Yes | 0.3.3 | -
406
+
407
+ This cop makes the Sorbet `true` sigil mandatory in all files.
408
+
409
+ ## Sorbet/ValidSigil
410
+
411
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
412
+ --- | --- | --- | --- | ---
413
+ Enabled | Yes | Yes | 0.3.3 | -
414
+
415
+ This cop checks that every Ruby file contains a valid Sorbet sigil.
416
+ Adapted from: https://gist.github.com/clarkdave/85aca4e16f33fd52aceb6a0a29936e52
417
+
418
+ Options:
419
+
420
+ * `RequireSigilOnAllFiles`: make offense if the Sorbet typed is not found in the file (default: false)
421
+ * `SuggestedStrictness`: Sorbet strictness level suggested in offense messages (default: 'false')
422
+ * `MinimumStrictness`: If set, make offense if the strictness level in the file is below this one
423
+
424
+ If a `MinimumStrictness` level is specified, it will be used in offense messages and autocorrect.