ruby-lsp 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +6 -0
- data/.rubocop.yml +16 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile +8 -5
- data/Gemfile.lock +55 -10
- data/README.md +40 -0
- data/VERSION +1 -1
- data/bin/tapioca +29 -0
- data/dev.yml +3 -0
- data/exe/ruby-lsp +19 -4
- data/lib/internal.rb +7 -0
- data/lib/ruby-lsp.rb +1 -0
- data/lib/ruby_lsp/cli.rb +12 -5
- data/lib/ruby_lsp/document.rb +37 -14
- data/lib/ruby_lsp/handler.rb +78 -23
- data/lib/ruby_lsp/requests/base_request.rb +11 -0
- data/lib/ruby_lsp/requests/code_actions.rb +1 -0
- data/lib/ruby_lsp/requests/diagnostics.rb +1 -0
- data/lib/ruby_lsp/requests/document_highlight.rb +96 -0
- data/lib/ruby_lsp/requests/document_symbol.rb +1 -10
- data/lib/ruby_lsp/requests/folding_ranges.rb +3 -2
- data/lib/ruby_lsp/requests/formatting.rb +2 -1
- data/lib/ruby_lsp/requests/rubocop_request.rb +1 -0
- data/lib/ruby_lsp/requests/selection_ranges.rb +1 -0
- data/lib/ruby_lsp/requests/semantic_highlighting.rb +17 -3
- data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +1 -0
- data/lib/ruby_lsp/requests/support/selection_range.rb +1 -0
- data/lib/ruby_lsp/requests/support/semantic_token_encoder.rb +12 -1
- data/lib/ruby_lsp/requests/support/syntax_error_diagnostic.rb +1 -0
- data/lib/ruby_lsp/requests.rb +2 -0
- data/lib/ruby_lsp/store.rb +19 -3
- data/rakelib/check_docs.rake +4 -1
- data/ruby-lsp.gemspec +1 -0
- data/sorbet/config +4 -0
- data/sorbet/rbi/.rubocop.yml +8 -0
- data/sorbet/rbi/gems/ansi@1.5.0.rbi +338 -0
- data/sorbet/rbi/gems/ast@2.4.2.rbi +522 -0
- data/sorbet/rbi/gems/builder@3.2.4.rbi +418 -0
- data/sorbet/rbi/gems/coderay@1.1.3.rbi +8 -0
- data/sorbet/rbi/gems/debug@1.5.0.rbi +1273 -0
- data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +867 -0
- data/sorbet/rbi/gems/io-console@0.5.11.rbi +8 -0
- data/sorbet/rbi/gems/irb@1.4.1.rbi +376 -0
- data/sorbet/rbi/gems/language_server-protocol@3.16.0.3.rbi +7325 -0
- data/sorbet/rbi/gems/method_source@1.0.0.rbi +8 -0
- data/sorbet/rbi/gems/minitest-reporters@1.5.0.rbi +612 -0
- data/sorbet/rbi/gems/minitest@5.15.0.rbi +994 -0
- data/sorbet/rbi/gems/parallel@1.22.1.rbi +163 -0
- data/sorbet/rbi/gems/parser@3.1.2.0.rbi +3968 -0
- data/sorbet/rbi/gems/prettier_print@0.1.0.rbi +734 -0
- data/sorbet/rbi/gems/pry@0.14.1.rbi +8 -0
- data/sorbet/rbi/gems/rainbow@3.1.1.rbi +227 -0
- data/sorbet/rbi/gems/rake@13.0.6.rbi +1853 -0
- data/sorbet/rbi/gems/rbi@0.0.14.rbi +2337 -0
- data/sorbet/rbi/gems/regexp_parser@2.5.0.rbi +1854 -0
- data/sorbet/rbi/gems/reline@0.3.1.rbi +1274 -0
- data/sorbet/rbi/gems/rexml@3.2.5.rbi +3852 -0
- data/sorbet/rbi/gems/rubocop-ast@1.18.0.rbi +4180 -0
- data/sorbet/rbi/gems/rubocop-minitest@0.20.0.rbi +1369 -0
- data/sorbet/rbi/gems/rubocop-rake@0.6.0.rbi +246 -0
- data/sorbet/rbi/gems/rubocop-shopify@2.6.0.rbi +8 -0
- data/sorbet/rbi/gems/rubocop-sorbet@0.6.8.rbi +652 -0
- data/sorbet/rbi/gems/rubocop@1.30.0.rbi +36729 -0
- data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +732 -0
- data/sorbet/rbi/gems/spoom@1.1.11.rbi +1600 -0
- data/sorbet/rbi/gems/syntax_tree@2.7.1.rbi +6777 -0
- data/sorbet/rbi/gems/tapioca@0.8.1.rbi +1972 -0
- data/sorbet/rbi/gems/thor@1.2.1.rbi +2921 -0
- data/sorbet/rbi/gems/unicode-display_width@2.1.0.rbi +27 -0
- data/sorbet/rbi/gems/unparser@0.6.5.rbi +2789 -0
- data/sorbet/rbi/gems/webrick@1.7.0.rbi +1779 -0
- data/sorbet/rbi/gems/yard-sorbet@0.6.1.rbi +289 -0
- data/sorbet/rbi/gems/yard@0.9.27.rbi +13048 -0
- data/sorbet/rbi/shims/fiddle.rbi +4 -0
- data/sorbet/rbi/shims/hash.rbi +6 -0
- data/sorbet/rbi/shims/rdoc.rbi +4 -0
- data/sorbet/tapioca/config.yml +13 -0
- data/sorbet/tapioca/require.rb +7 -0
- metadata +64 -2
@@ -0,0 +1,652 @@
|
|
1
|
+
# typed: true
|
2
|
+
|
3
|
+
# DO NOT EDIT MANUALLY
|
4
|
+
# This is an autogenerated file for types exported from the `rubocop-sorbet` gem.
|
5
|
+
# Please instead update this file by running `bin/tapioca gem rubocop-sorbet`.
|
6
|
+
|
7
|
+
module RuboCop; end
|
8
|
+
module RuboCop::Cop; end
|
9
|
+
RuboCop::Cop::IgnoredPattern = RuboCop::Cop::AllowedPattern
|
10
|
+
module RuboCop::Cop::Sorbet; end
|
11
|
+
|
12
|
+
# This cop disallows using `.override(allow_incompatible: true)`.
|
13
|
+
# Using `allow_incompatible` suggests a violation of the Liskov
|
14
|
+
# Substitution Principle, meaning that a subclass is not a valid
|
15
|
+
# subtype of it's superclass. This Cop prevents these design smells
|
16
|
+
# from occurring.
|
17
|
+
#
|
18
|
+
# @example
|
19
|
+
#
|
20
|
+
# # bad
|
21
|
+
# sig.override(allow_incompatible: true)
|
22
|
+
#
|
23
|
+
# # good
|
24
|
+
# sig.override
|
25
|
+
class RuboCop::Cop::Sorbet::AllowIncompatibleOverride < ::RuboCop::Cop::Cop
|
26
|
+
def allow_incompatible?(param0); end
|
27
|
+
def allow_incompatible_override?(param0 = T.unsafe(nil)); end
|
28
|
+
|
29
|
+
# @return [Boolean]
|
30
|
+
def not_nil?(node); end
|
31
|
+
|
32
|
+
def on_send(node); end
|
33
|
+
def sig?(param0); end
|
34
|
+
end
|
35
|
+
|
36
|
+
# This cop disallows binding the return value of `T.any`, `T.all`, `T.enum`
|
37
|
+
# to a constant directly. To bind the value, one must use `T.type_alias`.
|
38
|
+
#
|
39
|
+
# @example
|
40
|
+
#
|
41
|
+
# # bad
|
42
|
+
# FooOrBar = T.any(Foo, Bar)
|
43
|
+
#
|
44
|
+
# # good
|
45
|
+
# FooOrBar = T.type_alias { T.any(Foo, Bar) }
|
46
|
+
class RuboCop::Cop::Sorbet::BindingConstantWithoutTypeAlias < ::RuboCop::Cop::Cop
|
47
|
+
def autocorrect(node); end
|
48
|
+
def binding_unaliased_type?(param0 = T.unsafe(nil)); end
|
49
|
+
def dynamic_type_creation_with_block?(param0 = T.unsafe(nil)); end
|
50
|
+
def generic_parameter_decl_block_call?(param0 = T.unsafe(nil)); end
|
51
|
+
def generic_parameter_decl_call?(param0 = T.unsafe(nil)); end
|
52
|
+
def method_needing_aliasing_on_t?(param0); end
|
53
|
+
|
54
|
+
# @return [Boolean]
|
55
|
+
def not_dynamic_type_creation_with_block?(node); end
|
56
|
+
|
57
|
+
# @return [Boolean]
|
58
|
+
def not_generic_parameter_decl?(node); end
|
59
|
+
|
60
|
+
# @return [Boolean]
|
61
|
+
def not_nil?(node); end
|
62
|
+
|
63
|
+
# @return [Boolean]
|
64
|
+
def not_t_let?(node); end
|
65
|
+
|
66
|
+
def on_casgn(node); end
|
67
|
+
def t_let?(param0 = T.unsafe(nil)); end
|
68
|
+
def using_deprecated_type_alias_syntax?(param0 = T.unsafe(nil)); end
|
69
|
+
def using_type_alias?(param0 = T.unsafe(nil)); end
|
70
|
+
end
|
71
|
+
|
72
|
+
# This cop ensures that callback conditionals are bound to the right type
|
73
|
+
# so that they are type checked properly.
|
74
|
+
#
|
75
|
+
# Auto-correction is unsafe because other libraries define similar style callbacks as Rails, but don't always need
|
76
|
+
# binding to the attached class. Auto-correcting those usages can lead to false positives and auto-correction
|
77
|
+
# introduces new typing errors.
|
78
|
+
#
|
79
|
+
# @example
|
80
|
+
#
|
81
|
+
# # bad
|
82
|
+
# class Post < ApplicationRecord
|
83
|
+
# before_create :do_it, if: -> { should_do_it? }
|
84
|
+
#
|
85
|
+
# def should_do_it?
|
86
|
+
# true
|
87
|
+
# end
|
88
|
+
# end
|
89
|
+
#
|
90
|
+
# # good
|
91
|
+
# class Post < ApplicationRecord
|
92
|
+
# before_create :do_it, if: -> {
|
93
|
+
# T.bind(self, Post)
|
94
|
+
# should_do_it?
|
95
|
+
# }
|
96
|
+
#
|
97
|
+
# def should_do_it?
|
98
|
+
# true
|
99
|
+
# end
|
100
|
+
# end
|
101
|
+
class RuboCop::Cop::Sorbet::CallbackConditionalsBinding < ::RuboCop::Cop::Cop
|
102
|
+
def autocorrect(node); end
|
103
|
+
def on_send(node); end
|
104
|
+
end
|
105
|
+
|
106
|
+
RuboCop::Cop::Sorbet::CallbackConditionalsBinding::CALLBACKS = T.let(T.unsafe(nil), Array)
|
107
|
+
|
108
|
+
# This cop disallows the usage of `checked(true)`. This usage could cause
|
109
|
+
# confusion; it could lead some people to believe that a method would be checked
|
110
|
+
# even if runtime checks have not been enabled on the class or globally.
|
111
|
+
# Additionally, in the event where checks are enabled, `checked(true)` would
|
112
|
+
# be redundant; only `checked(false)` or `soft` would change the behaviour.
|
113
|
+
#
|
114
|
+
# @example
|
115
|
+
#
|
116
|
+
# # bad
|
117
|
+
# sig { void.checked(true) }
|
118
|
+
#
|
119
|
+
# # good
|
120
|
+
# sig { void }
|
121
|
+
class RuboCop::Cop::Sorbet::CheckedTrueInSignature < ::RuboCop::Cop::Sorbet::SignatureCop
|
122
|
+
include ::RuboCop::Cop::RangeHelp
|
123
|
+
|
124
|
+
def offending_node(param0); end
|
125
|
+
def on_signature(node); end
|
126
|
+
end
|
127
|
+
|
128
|
+
RuboCop::Cop::Sorbet::CheckedTrueInSignature::MESSAGE = T.let(T.unsafe(nil), String)
|
129
|
+
|
130
|
+
# This cop disallows the calls that are used to get constants fom Strings
|
131
|
+
# such as +constantize+, +const_get+, and +constants+.
|
132
|
+
#
|
133
|
+
# The goal of this cop is to make the code easier to statically analyze,
|
134
|
+
# more IDE-friendly, and more predictable. It leads to code that clearly
|
135
|
+
# expresses which values the constant can have.
|
136
|
+
#
|
137
|
+
# @example
|
138
|
+
#
|
139
|
+
# # bad
|
140
|
+
# class_name.constantize
|
141
|
+
#
|
142
|
+
# # bad
|
143
|
+
# constants.detect { |c| c.name == "User" }
|
144
|
+
#
|
145
|
+
# # bad
|
146
|
+
# const_get(class_name)
|
147
|
+
#
|
148
|
+
# # good
|
149
|
+
# case class_name
|
150
|
+
# when "User"
|
151
|
+
# User
|
152
|
+
# else
|
153
|
+
# raise ArgumentError
|
154
|
+
# end
|
155
|
+
#
|
156
|
+
# # good
|
157
|
+
# { "User" => User }.fetch(class_name)
|
158
|
+
class RuboCop::Cop::Sorbet::ConstantsFromStrings < ::RuboCop::Cop::Cop
|
159
|
+
def constant_from_string?(param0 = T.unsafe(nil)); end
|
160
|
+
def on_send(node); end
|
161
|
+
end
|
162
|
+
|
163
|
+
# This cop checks that the Sorbet sigil comes as the first magic comment in the file.
|
164
|
+
#
|
165
|
+
# The expected order for magic comments is: typed, (en)?coding, warn_indent then frozen_string_literal.
|
166
|
+
#
|
167
|
+
# For example, the following bad ordering:
|
168
|
+
#
|
169
|
+
# ```ruby
|
170
|
+
# class Foo; end
|
171
|
+
# ```
|
172
|
+
#
|
173
|
+
# Will be corrected as:
|
174
|
+
#
|
175
|
+
# ```ruby
|
176
|
+
# class Foo; end
|
177
|
+
# ```
|
178
|
+
#
|
179
|
+
# Only `typed`, `(en)?coding`, `warn_indent` and `frozen_string_literal` magic comments are considered,
|
180
|
+
# other comments or magic comments are left in the same place.
|
181
|
+
class RuboCop::Cop::Sorbet::EnforceSigilOrder < ::RuboCop::Cop::Sorbet::ValidSigil
|
182
|
+
include ::RuboCop::Cop::RangeHelp
|
183
|
+
|
184
|
+
def autocorrect(_node); end
|
185
|
+
def investigate(processed_source); end
|
186
|
+
|
187
|
+
protected
|
188
|
+
|
189
|
+
# checks
|
190
|
+
def check_magic_comments_order(tokens); end
|
191
|
+
|
192
|
+
# Get all the tokens in `processed_source` that match `MAGIC_REGEX`
|
193
|
+
def extract_magic_comments(processed_source); end
|
194
|
+
end
|
195
|
+
|
196
|
+
RuboCop::Cop::Sorbet::EnforceSigilOrder::CODING_REGEX = T.let(T.unsafe(nil), Regexp)
|
197
|
+
RuboCop::Cop::Sorbet::EnforceSigilOrder::FROZEN_REGEX = T.let(T.unsafe(nil), Regexp)
|
198
|
+
RuboCop::Cop::Sorbet::EnforceSigilOrder::INDENT_REGEX = T.let(T.unsafe(nil), Regexp)
|
199
|
+
RuboCop::Cop::Sorbet::EnforceSigilOrder::MAGIC_REGEX = T.let(T.unsafe(nil), Regexp)
|
200
|
+
RuboCop::Cop::Sorbet::EnforceSigilOrder::PREFERRED_ORDER = T.let(T.unsafe(nil), Hash)
|
201
|
+
|
202
|
+
# This cop checks that every method definition and attribute accessor has a Sorbet signature.
|
203
|
+
#
|
204
|
+
# It also suggest an autocorrect with placeholders so the following code:
|
205
|
+
#
|
206
|
+
# ```
|
207
|
+
# def foo(a, b, c); end
|
208
|
+
# ```
|
209
|
+
#
|
210
|
+
# Will be corrected as:
|
211
|
+
#
|
212
|
+
# ```
|
213
|
+
# sig { params(a: T.untyped, b: T.untyped, c: T.untyped).returns(T.untyped)
|
214
|
+
# def foo(a, b, c); end
|
215
|
+
# ```
|
216
|
+
#
|
217
|
+
# You can configure the placeholders used by changing the following options:
|
218
|
+
#
|
219
|
+
# * `ParameterTypePlaceholder`: placeholders used for parameter types (default: 'T.untyped')
|
220
|
+
# * `ReturnTypePlaceholder`: placeholders used for return types (default: 'T.untyped')
|
221
|
+
class RuboCop::Cop::Sorbet::EnforceSignatures < ::RuboCop::Cop::Sorbet::SignatureCop
|
222
|
+
# @return [EnforceSignatures] a new instance of EnforceSignatures
|
223
|
+
def initialize(config = T.unsafe(nil), options = T.unsafe(nil)); end
|
224
|
+
|
225
|
+
def accessor?(param0 = T.unsafe(nil)); end
|
226
|
+
def autocorrect(node); end
|
227
|
+
def on_def(node); end
|
228
|
+
def on_defs(node); end
|
229
|
+
def on_send(node); end
|
230
|
+
def on_signature(node); end
|
231
|
+
def scope(node); end
|
232
|
+
|
233
|
+
private
|
234
|
+
|
235
|
+
def check_node(node); end
|
236
|
+
def param_type_placeholder; end
|
237
|
+
def return_type_placeholder; end
|
238
|
+
end
|
239
|
+
|
240
|
+
class RuboCop::Cop::Sorbet::EnforceSignatures::SigSuggestion
|
241
|
+
# @return [SigSuggestion] a new instance of SigSuggestion
|
242
|
+
def initialize(indent, param_placeholder, return_placeholder); end
|
243
|
+
|
244
|
+
# Returns the value of attribute params.
|
245
|
+
def params; end
|
246
|
+
|
247
|
+
# Sets the attribute params
|
248
|
+
#
|
249
|
+
# @param value the value to set the attribute params to.
|
250
|
+
def params=(_arg0); end
|
251
|
+
|
252
|
+
# Returns the value of attribute returns.
|
253
|
+
def returns; end
|
254
|
+
|
255
|
+
# Sets the attribute returns
|
256
|
+
#
|
257
|
+
# @param value the value to set the attribute returns to.
|
258
|
+
def returns=(_arg0); end
|
259
|
+
|
260
|
+
def to_autocorrect; end
|
261
|
+
|
262
|
+
private
|
263
|
+
|
264
|
+
def generate_params; end
|
265
|
+
def generate_return; end
|
266
|
+
end
|
267
|
+
|
268
|
+
# This cop checks that there is only one Sorbet sigil in a given file
|
269
|
+
#
|
270
|
+
# For example, the following class with two sigils
|
271
|
+
#
|
272
|
+
# ```ruby
|
273
|
+
# class Foo; end
|
274
|
+
# ```
|
275
|
+
#
|
276
|
+
# Will be corrected as:
|
277
|
+
#
|
278
|
+
# ```ruby
|
279
|
+
# class Foo; end
|
280
|
+
# ```
|
281
|
+
#
|
282
|
+
# Other comments or magic comments are left in place.
|
283
|
+
class RuboCop::Cop::Sorbet::EnforceSingleSigil < ::RuboCop::Cop::Sorbet::ValidSigil
|
284
|
+
include ::RuboCop::Cop::RangeHelp
|
285
|
+
|
286
|
+
def autocorrect(_node); end
|
287
|
+
def investigate(processed_source); end
|
288
|
+
|
289
|
+
protected
|
290
|
+
|
291
|
+
def extract_all_sigils(processed_source); end
|
292
|
+
end
|
293
|
+
|
294
|
+
# This cop makes the Sorbet `false` sigil mandatory in all files.
|
295
|
+
class RuboCop::Cop::Sorbet::FalseSigil < ::RuboCop::Cop::Sorbet::HasSigil
|
296
|
+
def minimum_strictness; end
|
297
|
+
end
|
298
|
+
|
299
|
+
# This cop ensures RBI shims do not include a call to extend T::Sig
|
300
|
+
# or to extend T::Helpers
|
301
|
+
#
|
302
|
+
# @example
|
303
|
+
#
|
304
|
+
# # bad
|
305
|
+
# module SomeModule
|
306
|
+
# extend T::Sig
|
307
|
+
# extend T::Helpers
|
308
|
+
#
|
309
|
+
# sig { returns(String) }
|
310
|
+
# def foo; end
|
311
|
+
# end
|
312
|
+
#
|
313
|
+
# # good
|
314
|
+
# module SomeModule
|
315
|
+
# sig { returns(String) }
|
316
|
+
# def foo; end
|
317
|
+
# end
|
318
|
+
class RuboCop::Cop::Sorbet::ForbidExtendTSigHelpersInShims < ::RuboCop::Cop::Cop
|
319
|
+
include ::RuboCop::Cop::RangeHelp
|
320
|
+
|
321
|
+
def autocorrect(node); end
|
322
|
+
def extend_t_helpers?(param0 = T.unsafe(nil)); end
|
323
|
+
def extend_t_sig?(param0 = T.unsafe(nil)); end
|
324
|
+
def on_send(node); end
|
325
|
+
end
|
326
|
+
|
327
|
+
RuboCop::Cop::Sorbet::ForbidExtendTSigHelpersInShims::MSG = T.let(T.unsafe(nil), String)
|
328
|
+
RuboCop::Cop::Sorbet::ForbidExtendTSigHelpersInShims::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
329
|
+
|
330
|
+
class RuboCop::Cop::Sorbet::ForbidIncludeConstLiteral < ::RuboCop::Cop::Cop
|
331
|
+
# @return [ForbidIncludeConstLiteral] a new instance of ForbidIncludeConstLiteral
|
332
|
+
def initialize(*_arg0); end
|
333
|
+
|
334
|
+
def autocorrect(node); end
|
335
|
+
def not_lit_const_include?(param0 = T.unsafe(nil)); end
|
336
|
+
def on_send(node); end
|
337
|
+
|
338
|
+
# Returns the value of attribute used_names.
|
339
|
+
def used_names; end
|
340
|
+
|
341
|
+
# Sets the attribute used_names
|
342
|
+
#
|
343
|
+
# @param value the value to set the attribute used_names to.
|
344
|
+
def used_names=(_arg0); end
|
345
|
+
end
|
346
|
+
|
347
|
+
RuboCop::Cop::Sorbet::ForbidIncludeConstLiteral::MSG = T.let(T.unsafe(nil), String)
|
348
|
+
|
349
|
+
# This cop makes sure that RBI files are always located under the defined allowed paths.
|
350
|
+
#
|
351
|
+
# Options:
|
352
|
+
#
|
353
|
+
# * `AllowedPaths`: A list of the paths where RBI files are allowed (default: ["sorbet/rbi/**"])
|
354
|
+
#
|
355
|
+
# @example
|
356
|
+
# # bad
|
357
|
+
# # lib/some_file.rbi
|
358
|
+
# # other_file.rbi
|
359
|
+
#
|
360
|
+
# # good
|
361
|
+
# # sorbet/rbi/some_file.rbi
|
362
|
+
# # sorbet/rbi/any/path/for/file.rbi
|
363
|
+
class RuboCop::Cop::Sorbet::ForbidRBIOutsideOfAllowedPaths < ::RuboCop::Cop::Cop
|
364
|
+
include ::RuboCop::Cop::RangeHelp
|
365
|
+
|
366
|
+
def investigate(processed_source); end
|
367
|
+
|
368
|
+
private
|
369
|
+
|
370
|
+
def allowed_paths; end
|
371
|
+
end
|
372
|
+
|
373
|
+
class RuboCop::Cop::Sorbet::ForbidSuperclassConstLiteral < ::RuboCop::Cop::Cop
|
374
|
+
def not_lit_const_superclass?(param0 = T.unsafe(nil)); end
|
375
|
+
def on_class(node); end
|
376
|
+
end
|
377
|
+
|
378
|
+
RuboCop::Cop::Sorbet::ForbidSuperclassConstLiteral::MSG = T.let(T.unsafe(nil), String)
|
379
|
+
|
380
|
+
# This cop disallows using `T.unsafe` anywhere.
|
381
|
+
#
|
382
|
+
# @example
|
383
|
+
#
|
384
|
+
# # bad
|
385
|
+
# T.unsafe(foo)
|
386
|
+
#
|
387
|
+
# # good
|
388
|
+
# foo
|
389
|
+
class RuboCop::Cop::Sorbet::ForbidTUnsafe < ::RuboCop::Cop::Cop
|
390
|
+
def on_send(node); end
|
391
|
+
def t_unsafe?(param0 = T.unsafe(nil)); end
|
392
|
+
end
|
393
|
+
|
394
|
+
# This cop disallows use of `T.untyped` or `T.nilable(T.untyped)`
|
395
|
+
# as a prop type for `T::Struct`.
|
396
|
+
#
|
397
|
+
# @example
|
398
|
+
#
|
399
|
+
# # bad
|
400
|
+
# class SomeClass
|
401
|
+
# const :foo, T.untyped
|
402
|
+
# prop :bar, T.nilable(T.untyped)
|
403
|
+
# end
|
404
|
+
#
|
405
|
+
# # good
|
406
|
+
# class SomeClass
|
407
|
+
# const :foo, Integer
|
408
|
+
# prop :bar, T.nilable(String)
|
409
|
+
# end
|
410
|
+
class RuboCop::Cop::Sorbet::ForbidUntypedStructProps < ::RuboCop::Cop::Cop
|
411
|
+
def on_class(node); end
|
412
|
+
def subclass_of_t_struct?(param0 = T.unsafe(nil)); end
|
413
|
+
def t_nilable_untyped(param0 = T.unsafe(nil)); end
|
414
|
+
def t_struct(param0 = T.unsafe(nil)); end
|
415
|
+
def t_untyped(param0 = T.unsafe(nil)); end
|
416
|
+
def untyped_props(param0); end
|
417
|
+
end
|
418
|
+
|
419
|
+
RuboCop::Cop::Sorbet::ForbidUntypedStructProps::MSG = T.let(T.unsafe(nil), String)
|
420
|
+
|
421
|
+
# This cop makes the Sorbet typed sigil mandatory in all files.
|
422
|
+
#
|
423
|
+
# Options:
|
424
|
+
#
|
425
|
+
# * `SuggestedStrictness`: Sorbet strictness level suggested in offense messages (default: 'false')
|
426
|
+
# * `MinimumStrictness`: If set, make offense if the strictness level in the file is below this one
|
427
|
+
#
|
428
|
+
# If a `MinimumStrictness` level is specified, it will be used in offense messages and autocorrect.
|
429
|
+
class RuboCop::Cop::Sorbet::HasSigil < ::RuboCop::Cop::Sorbet::ValidSigil
|
430
|
+
# @return [Boolean]
|
431
|
+
def require_sigil_on_all_files?; end
|
432
|
+
end
|
433
|
+
|
434
|
+
# This cop makes the Sorbet `ignore` sigil mandatory in all files.
|
435
|
+
class RuboCop::Cop::Sorbet::IgnoreSigil < ::RuboCop::Cop::Sorbet::HasSigil
|
436
|
+
def minimum_strictness; end
|
437
|
+
end
|
438
|
+
|
439
|
+
# This cop checks for the ordering of keyword arguments required by
|
440
|
+
# sorbet-runtime. The ordering requires that all keyword arguments
|
441
|
+
# are at the end of the parameters list, and all keyword arguments
|
442
|
+
# with a default value must be after those without default values.
|
443
|
+
#
|
444
|
+
# @example
|
445
|
+
#
|
446
|
+
# # bad
|
447
|
+
# sig { params(a: Integer, b: String).void }
|
448
|
+
# def foo(a: 1, b:); end
|
449
|
+
#
|
450
|
+
# # good
|
451
|
+
# sig { params(b: String, a: Integer).void }
|
452
|
+
# def foo(b:, a: 1); end
|
453
|
+
class RuboCop::Cop::Sorbet::KeywordArgumentOrdering < ::RuboCop::Cop::Sorbet::SignatureCop
|
454
|
+
def on_signature(node); end
|
455
|
+
|
456
|
+
private
|
457
|
+
|
458
|
+
def check_order_for_kwoptargs(parameters); end
|
459
|
+
end
|
460
|
+
|
461
|
+
module RuboCop::Cop::Sorbet::MutableConstantSorbetAwareBehaviour
|
462
|
+
def on_assignment(value); end
|
463
|
+
|
464
|
+
class << self
|
465
|
+
def prepended(base); end
|
466
|
+
end
|
467
|
+
end
|
468
|
+
|
469
|
+
# This cop ensures one ancestor per requires_ancestor line
|
470
|
+
# rather than chaining them as a comma-separated list.
|
471
|
+
#
|
472
|
+
# @example
|
473
|
+
#
|
474
|
+
# # bad
|
475
|
+
# module SomeModule
|
476
|
+
# requires_ancestor Kernel, Minitest::Assertions
|
477
|
+
# end
|
478
|
+
#
|
479
|
+
# # good
|
480
|
+
# module SomeModule
|
481
|
+
# requires_ancestor Kernel
|
482
|
+
# requires_ancestor Minitest::Assertions
|
483
|
+
# end
|
484
|
+
class RuboCop::Cop::Sorbet::OneAncestorPerLine < ::RuboCop::Cop::Cop
|
485
|
+
def abstract?(param0); end
|
486
|
+
def autocorrect(node); end
|
487
|
+
def more_than_one_ancestor(param0 = T.unsafe(nil)); end
|
488
|
+
def on_class(node); end
|
489
|
+
def on_module(node); end
|
490
|
+
def requires_ancestors(param0); end
|
491
|
+
|
492
|
+
private
|
493
|
+
|
494
|
+
def new_ra_line(indent_count); end
|
495
|
+
def process_node(node); end
|
496
|
+
end
|
497
|
+
|
498
|
+
RuboCop::Cop::Sorbet::OneAncestorPerLine::MSG = T.let(T.unsafe(nil), String)
|
499
|
+
|
500
|
+
class RuboCop::Cop::Sorbet::SignatureBuildOrder < ::RuboCop::Cop::Sorbet::SignatureCop
|
501
|
+
def autocorrect(node); end
|
502
|
+
def on_signature(node); end
|
503
|
+
def root_call(param0); end
|
504
|
+
|
505
|
+
private
|
506
|
+
|
507
|
+
def call_chain(sig_child_node); end
|
508
|
+
|
509
|
+
# @return [Boolean]
|
510
|
+
def can_autocorrect?; end
|
511
|
+
|
512
|
+
# This method exists to reparse the current node with modern features enabled.
|
513
|
+
# Modern features include "index send" emitting, which is necessary to unparse
|
514
|
+
# "index sends" (i.e. `[]` calls) back to index accessors (i.e. as `foo[bar]``).
|
515
|
+
# Otherwise, we would get the unparsed node as `foo.[](bar)`.
|
516
|
+
def node_reparsed_with_modern_features(node); end
|
517
|
+
end
|
518
|
+
|
519
|
+
# Create a subclass of AST Builder that has modern features turned on
|
520
|
+
class RuboCop::Cop::Sorbet::SignatureBuildOrder::ModernBuilder < ::RuboCop::AST::Builder; end
|
521
|
+
|
522
|
+
RuboCop::Cop::Sorbet::SignatureBuildOrder::ORDER = T.let(T.unsafe(nil), Hash)
|
523
|
+
|
524
|
+
# Abstract cop specific to Sorbet signatures
|
525
|
+
#
|
526
|
+
# You can subclass it to use the `on_signature` trigger and the `signature?` node matcher.
|
527
|
+
class RuboCop::Cop::Sorbet::SignatureCop < ::RuboCop::Cop::Cop
|
528
|
+
def allowed_recv(recv); end
|
529
|
+
def on_block(node); end
|
530
|
+
def on_signature(_); end
|
531
|
+
def signature?(param0 = T.unsafe(nil)); end
|
532
|
+
def with_runtime?(param0 = T.unsafe(nil)); end
|
533
|
+
def without_runtime?(param0 = T.unsafe(nil)); end
|
534
|
+
end
|
535
|
+
|
536
|
+
# This cop ensures empty class/module definitions in RBI files are
|
537
|
+
# done on a single line rather than being split across multiple lines.
|
538
|
+
#
|
539
|
+
# @example
|
540
|
+
#
|
541
|
+
# # bad
|
542
|
+
# module SomeModule
|
543
|
+
# end
|
544
|
+
#
|
545
|
+
# # good
|
546
|
+
# module SomeModule; end
|
547
|
+
class RuboCop::Cop::Sorbet::SingleLineRbiClassModuleDefinitions < ::RuboCop::Cop::Cop
|
548
|
+
def autocorrect(node); end
|
549
|
+
def on_class(node); end
|
550
|
+
def on_module(node); end
|
551
|
+
|
552
|
+
protected
|
553
|
+
|
554
|
+
def convert_newlines(source); end
|
555
|
+
def process_node(node); end
|
556
|
+
end
|
557
|
+
|
558
|
+
RuboCop::Cop::Sorbet::SingleLineRbiClassModuleDefinitions::MSG = T.let(T.unsafe(nil), String)
|
559
|
+
|
560
|
+
# This cop makes the Sorbet `strict` sigil mandatory in all files.
|
561
|
+
class RuboCop::Cop::Sorbet::StrictSigil < ::RuboCop::Cop::Sorbet::HasSigil
|
562
|
+
def minimum_strictness; end
|
563
|
+
end
|
564
|
+
|
565
|
+
# This cop makes the Sorbet `strong` sigil mandatory in all files.
|
566
|
+
class RuboCop::Cop::Sorbet::StrongSigil < ::RuboCop::Cop::Sorbet::HasSigil
|
567
|
+
def minimum_strictness; end
|
568
|
+
end
|
569
|
+
|
570
|
+
# This cop makes the Sorbet `true` sigil mandatory in all files.
|
571
|
+
class RuboCop::Cop::Sorbet::TrueSigil < ::RuboCop::Cop::Sorbet::HasSigil
|
572
|
+
def minimum_strictness; end
|
573
|
+
end
|
574
|
+
|
575
|
+
# This cop ensures all constants used as `T.type_alias` are using CamelCase.
|
576
|
+
#
|
577
|
+
# @example
|
578
|
+
#
|
579
|
+
# # bad
|
580
|
+
# FOO_OR_BAR = T.type_alias { T.any(Foo, Bar) }
|
581
|
+
#
|
582
|
+
# # good
|
583
|
+
# FooOrBar = T.type_alias { T.any(Foo, Bar) }
|
584
|
+
class RuboCop::Cop::Sorbet::TypeAliasName < ::RuboCop::Cop::Cop
|
585
|
+
def casgn_type_alias?(param0 = T.unsafe(nil)); end
|
586
|
+
def on_casgn(node); end
|
587
|
+
end
|
588
|
+
|
589
|
+
RuboCop::Cop::Sorbet::TypeAliasName::MSG = T.let(T.unsafe(nil), String)
|
590
|
+
|
591
|
+
# This cop checks that every Ruby file contains a valid Sorbet sigil.
|
592
|
+
# Adapted from: https://gist.github.com/clarkdave/85aca4e16f33fd52aceb6a0a29936e52
|
593
|
+
#
|
594
|
+
# Options:
|
595
|
+
#
|
596
|
+
# * `RequireSigilOnAllFiles`: make offense if the Sorbet typed is not found in the file (default: false)
|
597
|
+
# * `SuggestedStrictness`: Sorbet strictness level suggested in offense messages (default: 'false')
|
598
|
+
# * `MinimumStrictness`: If set, make offense if the strictness level in the file is below this one
|
599
|
+
#
|
600
|
+
# If a `MinimumStrictness` level is specified, it will be used in offense messages and autocorrect.
|
601
|
+
class RuboCop::Cop::Sorbet::ValidSigil < ::RuboCop::Cop::Cop
|
602
|
+
def autocorrect(_node); end
|
603
|
+
def investigate(processed_source); end
|
604
|
+
|
605
|
+
protected
|
606
|
+
|
607
|
+
# checks
|
608
|
+
def check_sigil_present(sigil); end
|
609
|
+
|
610
|
+
def check_strictness_level(sigil, strictness); end
|
611
|
+
def check_strictness_not_empty(sigil, strictness); end
|
612
|
+
def check_strictness_valid(sigil, strictness); end
|
613
|
+
|
614
|
+
# extraction
|
615
|
+
def extract_sigil(processed_source); end
|
616
|
+
|
617
|
+
def extract_strictness(sigil); end
|
618
|
+
|
619
|
+
# Default is `nil`
|
620
|
+
def minimum_strictness; end
|
621
|
+
|
622
|
+
# Default is `false`
|
623
|
+
#
|
624
|
+
# @return [Boolean]
|
625
|
+
def require_sigil_on_all_files?; end
|
626
|
+
|
627
|
+
# Default is `'false'`
|
628
|
+
def suggested_strictness; end
|
629
|
+
|
630
|
+
def suggested_strictness_level(minimum_strictness, suggested_strictness); end
|
631
|
+
end
|
632
|
+
|
633
|
+
RuboCop::Cop::Sorbet::ValidSigil::SIGIL_REGEX = T.let(T.unsafe(nil), Regexp)
|
634
|
+
RuboCop::Cop::Sorbet::ValidSigil::STRICTNESS_LEVELS = T.let(T.unsafe(nil), Array)
|
635
|
+
RuboCop::NodePattern = RuboCop::AST::NodePattern
|
636
|
+
RuboCop::ProcessedSource = RuboCop::AST::ProcessedSource
|
637
|
+
module RuboCop::Sorbet; end
|
638
|
+
RuboCop::Sorbet::CONFIG = T.let(T.unsafe(nil), Hash)
|
639
|
+
RuboCop::Sorbet::CONFIG_DEFAULT = T.let(T.unsafe(nil), Pathname)
|
640
|
+
class RuboCop::Sorbet::Error < ::StandardError; end
|
641
|
+
|
642
|
+
# Because RuboCop doesn't yet support plugins, we have to monkey patch in a
|
643
|
+
# bit of our configuration.
|
644
|
+
module RuboCop::Sorbet::Inject
|
645
|
+
class << self
|
646
|
+
def defaults!; end
|
647
|
+
end
|
648
|
+
end
|
649
|
+
|
650
|
+
RuboCop::Sorbet::PROJECT_ROOT = T.let(T.unsafe(nil), Pathname)
|
651
|
+
RuboCop::Sorbet::VERSION = T.let(T.unsafe(nil), String)
|
652
|
+
RuboCop::Token = RuboCop::AST::Token
|