ruby-lsp 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +9 -1
  3. data/.github/workflows/publish_docs.yml +32 -0
  4. data/.rubocop.yml +25 -0
  5. data/CHANGELOG.md +23 -0
  6. data/Gemfile +8 -4
  7. data/Gemfile.lock +64 -13
  8. data/README.md +58 -1
  9. data/Rakefile +5 -0
  10. data/VERSION +1 -1
  11. data/bin/tapioca +29 -0
  12. data/dev.yml +3 -0
  13. data/exe/ruby-lsp +19 -3
  14. data/lib/ruby-lsp.rb +2 -0
  15. data/lib/ruby_lsp/cli.rb +23 -7
  16. data/lib/ruby_lsp/document.rb +98 -6
  17. data/lib/ruby_lsp/handler.rb +119 -18
  18. data/lib/ruby_lsp/internal.rb +7 -0
  19. data/lib/ruby_lsp/requests/base_request.rb +19 -5
  20. data/lib/ruby_lsp/requests/code_actions.rb +30 -9
  21. data/lib/ruby_lsp/requests/diagnostics.rb +29 -77
  22. data/lib/ruby_lsp/requests/document_highlight.rb +111 -0
  23. data/lib/ruby_lsp/requests/document_symbol.rb +75 -16
  24. data/lib/ruby_lsp/requests/folding_ranges.rb +63 -19
  25. data/lib/ruby_lsp/requests/formatting.rb +19 -2
  26. data/lib/ruby_lsp/requests/rubocop_request.rb +21 -8
  27. data/lib/ruby_lsp/requests/selection_ranges.rb +114 -0
  28. data/lib/ruby_lsp/requests/semantic_highlighting.rb +132 -61
  29. data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +100 -0
  30. data/lib/ruby_lsp/requests/support/selection_range.rb +20 -0
  31. data/lib/ruby_lsp/requests/support/semantic_token_encoder.rb +70 -0
  32. data/lib/ruby_lsp/requests/support/syntax_error_diagnostic.rb +32 -0
  33. data/lib/ruby_lsp/requests.rb +10 -0
  34. data/lib/ruby_lsp/store.rb +23 -2
  35. data/rakelib/check_docs.rake +57 -0
  36. data/ruby-lsp.gemspec +2 -1
  37. data/sorbet/config +4 -0
  38. data/sorbet/rbi/.rubocop.yml +8 -0
  39. data/sorbet/rbi/gems/ansi@1.5.0.rbi +338 -0
  40. data/sorbet/rbi/gems/ast@2.4.2.rbi +522 -0
  41. data/sorbet/rbi/gems/builder@3.2.4.rbi +418 -0
  42. data/sorbet/rbi/gems/coderay@1.1.3.rbi +8 -0
  43. data/sorbet/rbi/gems/debug@1.5.0.rbi +1273 -0
  44. data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +867 -0
  45. data/sorbet/rbi/gems/io-console@0.5.11.rbi +8 -0
  46. data/sorbet/rbi/gems/irb@1.4.1.rbi +376 -0
  47. data/sorbet/rbi/gems/language_server-protocol@3.16.0.3.rbi +7325 -0
  48. data/sorbet/rbi/gems/method_source@1.0.0.rbi +8 -0
  49. data/sorbet/rbi/gems/minitest-reporters@1.5.0.rbi +612 -0
  50. data/sorbet/rbi/gems/minitest@5.15.0.rbi +994 -0
  51. data/sorbet/rbi/gems/parallel@1.22.1.rbi +163 -0
  52. data/sorbet/rbi/gems/parser@3.1.2.0.rbi +3968 -0
  53. data/sorbet/rbi/gems/prettier_print@0.1.0.rbi +734 -0
  54. data/sorbet/rbi/gems/pry@0.14.1.rbi +8 -0
  55. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +227 -0
  56. data/sorbet/rbi/gems/rake@13.0.6.rbi +1853 -0
  57. data/sorbet/rbi/gems/rbi@0.0.14.rbi +2337 -0
  58. data/sorbet/rbi/gems/regexp_parser@2.5.0.rbi +1854 -0
  59. data/sorbet/rbi/gems/reline@0.3.1.rbi +1274 -0
  60. data/sorbet/rbi/gems/rexml@3.2.5.rbi +3852 -0
  61. data/sorbet/rbi/gems/rubocop-ast@1.18.0.rbi +4180 -0
  62. data/sorbet/rbi/gems/rubocop-minitest@0.20.0.rbi +1369 -0
  63. data/sorbet/rbi/gems/rubocop-rake@0.6.0.rbi +246 -0
  64. data/sorbet/rbi/gems/rubocop-shopify@2.6.0.rbi +8 -0
  65. data/sorbet/rbi/gems/rubocop-sorbet@0.6.8.rbi +652 -0
  66. data/sorbet/rbi/gems/rubocop@1.30.0.rbi +36729 -0
  67. data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +732 -0
  68. data/sorbet/rbi/gems/spoom@1.1.11.rbi +1600 -0
  69. data/sorbet/rbi/gems/syntax_tree@2.7.1.rbi +6777 -0
  70. data/sorbet/rbi/gems/tapioca@0.8.1.rbi +1972 -0
  71. data/sorbet/rbi/gems/thor@1.2.1.rbi +2921 -0
  72. data/sorbet/rbi/gems/unicode-display_width@2.1.0.rbi +27 -0
  73. data/sorbet/rbi/gems/unparser@0.6.5.rbi +2789 -0
  74. data/sorbet/rbi/gems/webrick@1.7.0.rbi +1779 -0
  75. data/sorbet/rbi/gems/yard-sorbet@0.6.1.rbi +289 -0
  76. data/sorbet/rbi/gems/yard@0.9.27.rbi +13048 -0
  77. data/sorbet/rbi/shims/fiddle.rbi +4 -0
  78. data/sorbet/rbi/shims/hash.rbi +6 -0
  79. data/sorbet/rbi/shims/rdoc.rbi +4 -0
  80. data/sorbet/tapioca/config.yml +13 -0
  81. data/sorbet/tapioca/require.rb +7 -0
  82. metadata +74 -6
  83. data/shipit.production.yml +0 -1
@@ -0,0 +1,1369 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `rubocop-minitest` gem.
5
+ # Please instead update this file by running `bin/tapioca gem rubocop-minitest`.
6
+
7
+ module RuboCop; end
8
+ module RuboCop::Cop; end
9
+
10
+ # Methods that calculate and return `Parser::Source::Ranges`.
11
+ module RuboCop::Cop::ArgumentRangeHelper
12
+ include ::RuboCop::Cop::RangeHelp
13
+
14
+ private
15
+
16
+ def all_arguments_range(node); end
17
+ def first_and_second_arguments_range(node); end
18
+ def first_argument_range(node); end
19
+ end
20
+
21
+ RuboCop::Cop::IgnoredPattern = RuboCop::Cop::AllowedPattern
22
+
23
+ # Common functionality for `AssertInDelta` and `RefuteInDelta` cops.
24
+ module RuboCop::Cop::InDeltaMixin
25
+ def on_send(node); end
26
+
27
+ private
28
+
29
+ def assertion_method; end
30
+ def build_good_method(expected, actual, message); end
31
+ end
32
+
33
+ RuboCop::Cop::InDeltaMixin::MSG = T.let(T.unsafe(nil), String)
34
+ module RuboCop::Cop::Minitest; end
35
+
36
+ # Enforces the test to use `assert_empty` instead of using `assert(object.empty?)`.
37
+ #
38
+ # @example
39
+ # # bad
40
+ # assert(object.empty?)
41
+ # assert(object.empty?, 'message')
42
+ #
43
+ # # good
44
+ # assert_empty(object)
45
+ # assert_empty(object, 'message')
46
+ class RuboCop::Cop::Minitest::AssertEmpty < ::RuboCop::Cop::Base
47
+ include ::RuboCop::Cop::RangeHelp
48
+ include ::RuboCop::Cop::ArgumentRangeHelper
49
+ extend ::RuboCop::Cop::MinitestCopRule
50
+ extend ::RuboCop::Cop::AutoCorrector
51
+
52
+ def autocorrect(corrector, node, arguments); end
53
+ def on_send(node); end
54
+
55
+ private
56
+
57
+ def correct_receiver(receiver); end
58
+ def enclosed_in_redundant_parentheses?(node); end
59
+ def new_arguments(arguments); end
60
+ def offense_message(arguments); end
61
+ def peel_redundant_parentheses_from(arguments); end
62
+ end
63
+
64
+ RuboCop::Cop::Minitest::AssertEmpty::MSG = T.let(T.unsafe(nil), String)
65
+ RuboCop::Cop::Minitest::AssertEmpty::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
66
+
67
+ # Enforces the test to use `assert_empty`
68
+ # instead of using `assert_equal([], object)` or `assert_equal({}, object)`.
69
+ #
70
+ # @example
71
+ # # bad
72
+ # assert_equal([], object)
73
+ # assert_equal({}, object)
74
+ #
75
+ # # good
76
+ # assert_empty(object)
77
+ class RuboCop::Cop::Minitest::AssertEmptyLiteral < ::RuboCop::Cop::Base
78
+ include ::RuboCop::Cop::RangeHelp
79
+ include ::RuboCop::Cop::ArgumentRangeHelper
80
+ extend ::RuboCop::Cop::AutoCorrector
81
+
82
+ def assert_equal_with_empty_literal(param0 = T.unsafe(nil)); end
83
+ def on_send(node); end
84
+ end
85
+
86
+ RuboCop::Cop::Minitest::AssertEmptyLiteral::MSG = T.let(T.unsafe(nil), String)
87
+ RuboCop::Cop::Minitest::AssertEmptyLiteral::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
88
+
89
+ # Enforces the use of `assert_equal(expected, actual)`
90
+ # over `assert(expected == actual)`.
91
+ #
92
+ # @example
93
+ # # bad
94
+ # assert("rubocop-minitest" == actual)
95
+ #
96
+ # # good
97
+ # assert_equal("rubocop-minitest", actual)
98
+ class RuboCop::Cop::Minitest::AssertEqual < ::RuboCop::Cop::Base
99
+ include ::RuboCop::Cop::RangeHelp
100
+ include ::RuboCop::Cop::ArgumentRangeHelper
101
+ extend ::RuboCop::Cop::MinitestCopRule
102
+ extend ::RuboCop::Cop::AutoCorrector
103
+
104
+ def autocorrect(corrector, node, arguments); end
105
+ def on_send(node); end
106
+
107
+ private
108
+
109
+ def correct_receiver(receiver); end
110
+ def enclosed_in_redundant_parentheses?(node); end
111
+ def new_arguments(arguments); end
112
+ def offense_message(arguments); end
113
+ def peel_redundant_parentheses_from(arguments); end
114
+ end
115
+
116
+ RuboCop::Cop::Minitest::AssertEqual::MSG = T.let(T.unsafe(nil), String)
117
+ RuboCop::Cop::Minitest::AssertEqual::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
118
+
119
+ # Enforces the test to use `assert_in_delta`
120
+ # instead of using `assert_equal` to compare floats.
121
+ #
122
+ # @example
123
+ # # bad
124
+ # assert_equal(0.2, actual)
125
+ # assert_equal(0.2, actual, 'message')
126
+ #
127
+ # # good
128
+ # assert_in_delta(0.2, actual)
129
+ # assert_in_delta(0.2, actual, 0.001, 'message')
130
+ class RuboCop::Cop::Minitest::AssertInDelta < ::RuboCop::Cop::Base
131
+ include ::RuboCop::Cop::InDeltaMixin
132
+ extend ::RuboCop::Cop::AutoCorrector
133
+
134
+ def equal_floats_call(param0 = T.unsafe(nil)); end
135
+ end
136
+
137
+ RuboCop::Cop::Minitest::AssertInDelta::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
138
+
139
+ # Enforces the test to use `assert_includes`
140
+ # instead of using `assert(collection.include?(object))`.
141
+ #
142
+ # @example
143
+ # # bad
144
+ # assert(collection.include?(object))
145
+ # assert(collection.include?(object), 'message')
146
+ #
147
+ # # good
148
+ # assert_includes(collection, object)
149
+ # assert_includes(collection, object, 'message')
150
+ class RuboCop::Cop::Minitest::AssertIncludes < ::RuboCop::Cop::Base
151
+ include ::RuboCop::Cop::RangeHelp
152
+ include ::RuboCop::Cop::ArgumentRangeHelper
153
+ extend ::RuboCop::Cop::MinitestCopRule
154
+ extend ::RuboCop::Cop::AutoCorrector
155
+
156
+ def autocorrect(corrector, node, arguments); end
157
+ def on_send(node); end
158
+
159
+ private
160
+
161
+ def correct_receiver(receiver); end
162
+ def enclosed_in_redundant_parentheses?(node); end
163
+ def new_arguments(arguments); end
164
+ def offense_message(arguments); end
165
+ def peel_redundant_parentheses_from(arguments); end
166
+ end
167
+
168
+ RuboCop::Cop::Minitest::AssertIncludes::MSG = T.let(T.unsafe(nil), String)
169
+ RuboCop::Cop::Minitest::AssertIncludes::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
170
+
171
+ # Enforces the test to use `assert_instance_of(Class, object)`
172
+ # over `assert(object.instance_of?(Class))`.
173
+ #
174
+ # @example
175
+ # # bad
176
+ # assert(object.instance_of?(Class))
177
+ # assert(object.instance_of?(Class), 'message')
178
+ #
179
+ # # good
180
+ # assert_instance_of(Class, object)
181
+ # assert_instance_of(Class, object, 'message')
182
+ class RuboCop::Cop::Minitest::AssertInstanceOf < ::RuboCop::Cop::Base
183
+ include ::RuboCop::Cop::RangeHelp
184
+ include ::RuboCop::Cop::ArgumentRangeHelper
185
+ extend ::RuboCop::Cop::MinitestCopRule
186
+ extend ::RuboCop::Cop::AutoCorrector
187
+
188
+ def autocorrect(corrector, node, arguments); end
189
+ def on_send(node); end
190
+
191
+ private
192
+
193
+ def correct_receiver(receiver); end
194
+ def enclosed_in_redundant_parentheses?(node); end
195
+ def new_arguments(arguments); end
196
+ def offense_message(arguments); end
197
+ def peel_redundant_parentheses_from(arguments); end
198
+ end
199
+
200
+ RuboCop::Cop::Minitest::AssertInstanceOf::MSG = T.let(T.unsafe(nil), String)
201
+ RuboCop::Cop::Minitest::AssertInstanceOf::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
202
+
203
+ # Enforces the test to use `assert_kind_of(Class, object)`
204
+ # over `assert(object.kind_of?(Class))`.
205
+ #
206
+ # @example
207
+ # # bad
208
+ # assert(object.kind_of?(Class))
209
+ # assert(object.kind_of?(Class), 'message')
210
+ #
211
+ # # good
212
+ # assert_kind_of(Class, object)
213
+ # assert_kind_of(Class, object, 'message')
214
+ class RuboCop::Cop::Minitest::AssertKindOf < ::RuboCop::Cop::Base
215
+ include ::RuboCop::Cop::RangeHelp
216
+ include ::RuboCop::Cop::ArgumentRangeHelper
217
+ extend ::RuboCop::Cop::MinitestCopRule
218
+ extend ::RuboCop::Cop::AutoCorrector
219
+
220
+ def autocorrect(corrector, node, arguments); end
221
+ def on_send(node); end
222
+
223
+ private
224
+
225
+ def correct_receiver(receiver); end
226
+ def enclosed_in_redundant_parentheses?(node); end
227
+ def new_arguments(arguments); end
228
+ def offense_message(arguments); end
229
+ def peel_redundant_parentheses_from(arguments); end
230
+ end
231
+
232
+ RuboCop::Cop::Minitest::AssertKindOf::MSG = T.let(T.unsafe(nil), String)
233
+ RuboCop::Cop::Minitest::AssertKindOf::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
234
+
235
+ # Enforces the test to use `assert_match`
236
+ # instead of using `assert(matcher.match(string))`.
237
+ #
238
+ # @example
239
+ # # bad
240
+ # assert(matcher.match(string))
241
+ # assert(matcher.match(string), 'message')
242
+ #
243
+ # # good
244
+ # assert_match(regex, string)
245
+ # assert_match(matcher, string, 'message')
246
+ class RuboCop::Cop::Minitest::AssertMatch < ::RuboCop::Cop::Base
247
+ include ::RuboCop::Cop::RangeHelp
248
+ include ::RuboCop::Cop::ArgumentRangeHelper
249
+ extend ::RuboCop::Cop::MinitestCopRule
250
+ extend ::RuboCop::Cop::AutoCorrector
251
+
252
+ def autocorrect(corrector, node, arguments); end
253
+ def on_send(node); end
254
+
255
+ private
256
+
257
+ def correct_receiver(receiver); end
258
+ def enclosed_in_redundant_parentheses?(node); end
259
+ def new_arguments(arguments); end
260
+ def offense_message(arguments); end
261
+ def peel_redundant_parentheses_from(arguments); end
262
+ end
263
+
264
+ RuboCop::Cop::Minitest::AssertMatch::MSG = T.let(T.unsafe(nil), String)
265
+ RuboCop::Cop::Minitest::AssertMatch::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
266
+
267
+ # Enforces the test to use `assert_nil` instead of using
268
+ # `assert_equal(nil, something)`, `assert(something.nil?)`, or `assert_predicate(something, :nil?)`.
269
+ #
270
+ # @example
271
+ # # bad
272
+ # assert_equal(nil, actual)
273
+ # assert_equal(nil, actual, 'message')
274
+ # assert(object.nil?)
275
+ # assert(object.nil?, 'message')
276
+ # assert_predicate(object, :nil?)
277
+ # assert_predicate(object, :nil?, 'message')
278
+ #
279
+ # # good
280
+ # assert_nil(actual)
281
+ # assert_nil(actual, 'message')
282
+ class RuboCop::Cop::Minitest::AssertNil < ::RuboCop::Cop::Base
283
+ include ::RuboCop::Cop::RangeHelp
284
+ include ::RuboCop::Cop::ArgumentRangeHelper
285
+ include ::RuboCop::Cop::Minitest::NilAssertionHandleable
286
+ extend ::RuboCop::Cop::AutoCorrector
287
+
288
+ def nil_assertion(param0 = T.unsafe(nil)); end
289
+ def on_send(node); end
290
+
291
+ private
292
+
293
+ def assertion_type; end
294
+ end
295
+
296
+ RuboCop::Cop::Minitest::AssertNil::ASSERTION_TYPE = T.let(T.unsafe(nil), String)
297
+ RuboCop::Cop::Minitest::AssertNil::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
298
+
299
+ # Checks for opportunities to use `assert_output`.
300
+ #
301
+ # @example
302
+ # # bad
303
+ # $stdout = StringIO.new
304
+ # puts object.method
305
+ # $stdout.rewind
306
+ # assert_match expected, $stdout.read
307
+ #
308
+ # # good
309
+ # assert_output(expected) { puts object.method }
310
+ class RuboCop::Cop::Minitest::AssertOutput < ::RuboCop::Cop::Base
311
+ include ::RuboCop::Cop::MinitestExplorationHelpers
312
+
313
+ def on_gvasgn(node); end
314
+
315
+ private
316
+
317
+ def find_test_case(node); end
318
+
319
+ # @return [Boolean]
320
+ def references_gvar?(assertion, gvar_name); end
321
+ end
322
+
323
+ RuboCop::Cop::Minitest::AssertOutput::MSG = T.let(T.unsafe(nil), String)
324
+ RuboCop::Cop::Minitest::AssertOutput::OUTPUT_GLOBAL_VARIABLES = T.let(T.unsafe(nil), Array)
325
+
326
+ # Enforces the test to use `assert_path_exists` instead of using `assert(File.exist?(path))`.
327
+ #
328
+ # @example
329
+ # # bad
330
+ # assert(File.exist?(path))
331
+ # assert(File.exist?(path), 'message')
332
+ #
333
+ # # good
334
+ # assert_path_exists(path)
335
+ # assert_path_exists(path, 'message')
336
+ class RuboCop::Cop::Minitest::AssertPathExists < ::RuboCop::Cop::Base
337
+ extend ::RuboCop::Cop::AutoCorrector
338
+
339
+ def assert_file_exists(param0 = T.unsafe(nil)); end
340
+ def on_send(node); end
341
+
342
+ private
343
+
344
+ def build_good_method(path, message); end
345
+ end
346
+
347
+ RuboCop::Cop::Minitest::AssertPathExists::MSG = T.let(T.unsafe(nil), String)
348
+ RuboCop::Cop::Minitest::AssertPathExists::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
349
+
350
+ # Enforces the test to use `assert_predicate`
351
+ # instead of using `assert(obj.a_predicate_method?)`.
352
+ #
353
+ # @example
354
+ # # bad
355
+ # assert(obj.one?)
356
+ # assert(obj.one?, 'message')
357
+ #
358
+ # # good
359
+ # assert_predicate(obj, :one?)
360
+ # assert_predicate(obj, :one?, 'message')
361
+ class RuboCop::Cop::Minitest::AssertPredicate < ::RuboCop::Cop::Base
362
+ include ::RuboCop::Cop::RangeHelp
363
+ include ::RuboCop::Cop::ArgumentRangeHelper
364
+ include ::RuboCop::Cop::Minitest::PredicateAssertionHandleable
365
+ extend ::RuboCop::Cop::AutoCorrector
366
+
367
+ private
368
+
369
+ def assertion_type; end
370
+ end
371
+
372
+ RuboCop::Cop::Minitest::AssertPredicate::MSG = T.let(T.unsafe(nil), String)
373
+ RuboCop::Cop::Minitest::AssertPredicate::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
374
+
375
+ # Enforces the use of `assert_respond_to(object, :do_something)`
376
+ # over `assert(object.respond_to?(:do_something))`.
377
+ #
378
+ # @example
379
+ # # bad
380
+ # assert(object.respond_to?(:do_something))
381
+ # assert(object.respond_to?(:do_something), 'message')
382
+ # assert(respond_to?(:do_something))
383
+ #
384
+ # # good
385
+ # assert_respond_to(object, :do_something)
386
+ # assert_respond_to(object, :do_something, 'message')
387
+ # assert_respond_to(self, :do_something)
388
+ class RuboCop::Cop::Minitest::AssertRespondTo < ::RuboCop::Cop::Base
389
+ include ::RuboCop::Cop::RangeHelp
390
+ include ::RuboCop::Cop::ArgumentRangeHelper
391
+ extend ::RuboCop::Cop::MinitestCopRule
392
+ extend ::RuboCop::Cop::AutoCorrector
393
+
394
+ def autocorrect(corrector, node, arguments); end
395
+ def on_send(node); end
396
+
397
+ private
398
+
399
+ def correct_receiver(receiver); end
400
+ def enclosed_in_redundant_parentheses?(node); end
401
+ def new_arguments(arguments); end
402
+ def offense_message(arguments); end
403
+ def peel_redundant_parentheses_from(arguments); end
404
+ end
405
+
406
+ RuboCop::Cop::Minitest::AssertRespondTo::MSG = T.let(T.unsafe(nil), String)
407
+ RuboCop::Cop::Minitest::AssertRespondTo::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
408
+
409
+ # Enforces the test to use `assert_silent { ... }`
410
+ # instead of using `assert_output('', '') { ... }`.
411
+ #
412
+ # @example
413
+ # # bad
414
+ # assert_output('', '') { puts object.do_something }
415
+ #
416
+ # # good
417
+ # assert_silent { puts object.do_something }
418
+ class RuboCop::Cop::Minitest::AssertSilent < ::RuboCop::Cop::Base
419
+ extend ::RuboCop::Cop::AutoCorrector
420
+
421
+ def assert_silent_candidate?(param0 = T.unsafe(nil)); end
422
+ def on_block(node); end
423
+
424
+ private
425
+
426
+ # @return [Boolean]
427
+ def empty_string?(node); end
428
+ end
429
+
430
+ RuboCop::Cop::Minitest::AssertSilent::MSG = T.let(T.unsafe(nil), String)
431
+
432
+ # Enforces the test to use `assert(actual)` instead of using `assert_equal(true, actual)`.
433
+ #
434
+ # @example
435
+ # # bad
436
+ # assert_equal(true, actual)
437
+ # assert_equal(true, actual, 'message')
438
+ #
439
+ # # good
440
+ # assert(actual)
441
+ # assert(actual, 'message')
442
+ class RuboCop::Cop::Minitest::AssertTruthy < ::RuboCop::Cop::Base
443
+ include ::RuboCop::Cop::RangeHelp
444
+ include ::RuboCop::Cop::ArgumentRangeHelper
445
+ extend ::RuboCop::Cop::AutoCorrector
446
+
447
+ def assert_equal_with_truthy(param0 = T.unsafe(nil)); end
448
+ def on_send(node); end
449
+ end
450
+
451
+ RuboCop::Cop::Minitest::AssertTruthy::MSG = T.let(T.unsafe(nil), String)
452
+ RuboCop::Cop::Minitest::AssertTruthy::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
453
+
454
+ # Tries to detect when a user accidentally used
455
+ # `assert` when they meant to use `assert_equal`.
456
+ #
457
+ # @example
458
+ # # bad
459
+ # assert(3, my_list.length)
460
+ # assert(expected, actual)
461
+ #
462
+ # # good
463
+ # assert_equal(3, my_list.length)
464
+ # assert_equal(expected, actual)
465
+ # assert(foo, 'message')
466
+ class RuboCop::Cop::Minitest::AssertWithExpectedArgument < ::RuboCop::Cop::Base
467
+ def assert_with_two_arguments?(param0 = T.unsafe(nil)); end
468
+ def on_send(node); end
469
+ end
470
+
471
+ RuboCop::Cop::Minitest::AssertWithExpectedArgument::MSG = T.let(T.unsafe(nil), String)
472
+ RuboCop::Cop::Minitest::AssertWithExpectedArgument::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
473
+
474
+ # Checks for usage of assertions in lifecycle hooks.
475
+ #
476
+ # @example
477
+ # # bad
478
+ # class FooTest < Minitest::Test
479
+ # def setup
480
+ # assert_equal(foo, bar)
481
+ # end
482
+ # end
483
+ #
484
+ # # good
485
+ # class FooTest < Minitest::Test
486
+ # def test_something
487
+ # assert_equal(foo, bar)
488
+ # end
489
+ # end
490
+ class RuboCop::Cop::Minitest::AssertionInLifecycleHook < ::RuboCop::Cop::Base
491
+ include ::RuboCop::Cop::MinitestExplorationHelpers
492
+
493
+ def on_class(class_node); end
494
+ end
495
+
496
+ RuboCop::Cop::Minitest::AssertionInLifecycleHook::MSG = T.let(T.unsafe(nil), String)
497
+
498
+ # If a Minitest class inherits from another class,
499
+ # it will also inherit its methods causing Minitest to run the parent's tests methods twice.
500
+ #
501
+ # This cop detects when there are two tests classes, one inherits from the other, and both have tests methods.
502
+ # This cop will add an offense to the Child class in such a case.
503
+ #
504
+ # @example
505
+ # # bad
506
+ # class ParentTest < Minitest::Test
507
+ # def test_parent # it will run this test twice.
508
+ # end
509
+ # end
510
+ #
511
+ # class ChildTest < ParentTest
512
+ # def test_child
513
+ # end
514
+ # end
515
+ #
516
+ # # good
517
+ # class ParentTest < Minitest::Test
518
+ # def test_parent
519
+ # end
520
+ # end
521
+ #
522
+ # class ChildTest < Minitest::Test
523
+ # def test_child
524
+ # end
525
+ # end
526
+ #
527
+ # # good
528
+ # class ParentTest < Minitest::Test
529
+ # end
530
+ #
531
+ # class ChildTest
532
+ # def test_child
533
+ # end
534
+ #
535
+ # def test_parent
536
+ # end
537
+ # end
538
+ class RuboCop::Cop::Minitest::DuplicateTestRun < ::RuboCop::Cop::Base
539
+ include ::RuboCop::Cop::MinitestExplorationHelpers
540
+
541
+ def on_class(class_node); end
542
+
543
+ private
544
+
545
+ # @return [Boolean]
546
+ def parent_class_has_test_methods?(class_node); end
547
+
548
+ # @return [Boolean]
549
+ def test_methods?(class_node); end
550
+ end
551
+
552
+ RuboCop::Cop::Minitest::DuplicateTestRun::MSG = T.let(T.unsafe(nil), String)
553
+
554
+ # Checks for deprecated global expectations
555
+ # and autocorrects them to use expect format.
556
+ #
557
+ # @example EnforcedStyle: _
558
+ # # bad
559
+ # musts.must_equal expected_musts
560
+ # wonts.wont_match expected_wonts
561
+ # musts.must_raise TypeError
562
+ #
563
+ # expect(musts).must_equal expected_musts
564
+ # expect(wonts).wont_match expected_wonts
565
+ # expect { musts }.must_raise TypeError
566
+ #
567
+ # value(musts).must_equal expected_musts
568
+ # value(wonts).wont_match expected_wonts
569
+ # value { musts }.must_raise TypeError
570
+ #
571
+ # # good
572
+ # _(musts).must_equal expected_musts
573
+ # _(wonts).wont_match expected_wonts
574
+ # _ { musts }.must_raise TypeError
575
+ # @example EnforcedStyle: any (default)
576
+ # # bad
577
+ # musts.must_equal expected_musts
578
+ # wonts.wont_match expected_wonts
579
+ # musts.must_raise TypeError
580
+ #
581
+ # # good
582
+ # _(musts).must_equal expected_musts
583
+ # _(wonts).wont_match expected_wonts
584
+ # _ { musts }.must_raise TypeError
585
+ #
586
+ # expect(musts).must_equal expected_musts
587
+ # expect(wonts).wont_match expected_wonts
588
+ # expect { musts }.must_raise TypeError
589
+ #
590
+ # value(musts).must_equal expected_musts
591
+ # value(wonts).wont_match expected_wonts
592
+ # value { musts }.must_raise TypeError
593
+ # @example EnforcedStyle: expect
594
+ # # bad
595
+ # musts.must_equal expected_musts
596
+ # wonts.wont_match expected_wonts
597
+ # musts.must_raise TypeError
598
+ #
599
+ # _(musts).must_equal expected_musts
600
+ # _(wonts).wont_match expected_wonts
601
+ # _ { musts }.must_raise TypeError
602
+ #
603
+ # value(musts).must_equal expected_musts
604
+ # value(wonts).wont_match expected_wonts
605
+ # value { musts }.must_raise TypeError
606
+ #
607
+ # # good
608
+ # expect(musts).must_equal expected_musts
609
+ # expect(wonts).wont_match expected_wonts
610
+ # expect { musts }.must_raise TypeError
611
+ # @example EnforcedStyle: value
612
+ # # bad
613
+ # musts.must_equal expected_musts
614
+ # wonts.wont_match expected_wonts
615
+ # musts.must_raise TypeError
616
+ #
617
+ # _(musts).must_equal expected_musts
618
+ # _(wonts).wont_match expected_wonts
619
+ # _ { musts }.must_raise TypeError
620
+ #
621
+ # expect(musts).must_equal expected_musts
622
+ # expect(wonts).wont_match expected_wonts
623
+ # expect { musts }.must_raise TypeError
624
+ #
625
+ # # good
626
+ # value(musts).must_equal expected_musts
627
+ # value(wonts).wont_match expected_wonts
628
+ # value { musts }.must_raise TypeError
629
+ class RuboCop::Cop::Minitest::GlobalExpectations < ::RuboCop::Cop::Base
630
+ include ::RuboCop::Cop::ConfigurableEnforcedStyle
631
+ extend ::RuboCop::Cop::AutoCorrector
632
+
633
+ def block_receiver?(param0 = T.unsafe(nil)); end
634
+ def on_send(node); end
635
+ def value_receiver?(param0 = T.unsafe(nil)); end
636
+
637
+ private
638
+
639
+ # @return [Boolean]
640
+ def method_allowed?(method); end
641
+
642
+ def preferred_method; end
643
+ def preferred_receiver(node); end
644
+ def register_offense(node, method); end
645
+ end
646
+
647
+ RuboCop::Cop::Minitest::GlobalExpectations::BLOCK_MATCHERS = T.let(T.unsafe(nil), Array)
648
+
649
+ # There are aliases for the `_` method - `expect` and `value`
650
+ RuboCop::Cop::Minitest::GlobalExpectations::DSL_METHODS = T.let(T.unsafe(nil), Array)
651
+
652
+ RuboCop::Cop::Minitest::GlobalExpectations::MSG = T.let(T.unsafe(nil), String)
653
+ RuboCop::Cop::Minitest::GlobalExpectations::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
654
+ RuboCop::Cop::Minitest::GlobalExpectations::VALUE_MATCHERS = T.let(T.unsafe(nil), Array)
655
+
656
+ # Enforces correct order of expected and
657
+ # actual arguments for `assert_equal`.
658
+ #
659
+ # @example
660
+ # # bad
661
+ # assert_equal foo, 2
662
+ # assert_equal foo, [1, 2]
663
+ # assert_equal foo, [1, 2], 'message'
664
+ #
665
+ # # good
666
+ # assert_equal 2, foo
667
+ # assert_equal [1, 2], foo
668
+ # assert_equal [1, 2], foo, 'message'
669
+ class RuboCop::Cop::Minitest::LiteralAsActualArgument < ::RuboCop::Cop::Base
670
+ include ::RuboCop::Cop::RangeHelp
671
+ include ::RuboCop::Cop::ArgumentRangeHelper
672
+ extend ::RuboCop::Cop::AutoCorrector
673
+
674
+ def autocorrect(corrector, node, expected, actual, message); end
675
+ def on_send(node); end
676
+ end
677
+
678
+ RuboCop::Cop::Minitest::LiteralAsActualArgument::MSG = T.let(T.unsafe(nil), String)
679
+ RuboCop::Cop::Minitest::LiteralAsActualArgument::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
680
+
681
+ # Checks if test cases contain too many assertion calls.
682
+ # The maximum allowed assertion calls is configurable.
683
+ #
684
+ # @example Max: 1
685
+ # # bad
686
+ # class FooTest < Minitest::Test
687
+ # def test_asserts_twice
688
+ # assert_equal(42, do_something)
689
+ # assert_empty(array)
690
+ # end
691
+ # end
692
+ #
693
+ # # good
694
+ # class FooTest < Minitest::Test
695
+ # def test_asserts_once
696
+ # assert_equal(42, do_something)
697
+ # end
698
+ #
699
+ # def test_another_asserts_once
700
+ # assert_empty(array)
701
+ # end
702
+ # end
703
+ class RuboCop::Cop::Minitest::MultipleAssertions < ::RuboCop::Cop::Base
704
+ include ::RuboCop::Cop::ConfigurableMax
705
+ include ::RuboCop::Cop::MinitestExplorationHelpers
706
+
707
+ def on_class(class_node); end
708
+
709
+ private
710
+
711
+ def assertions_count(node); end
712
+ def max_assertions; end
713
+ end
714
+
715
+ RuboCop::Cop::Minitest::MultipleAssertions::MSG = T.let(T.unsafe(nil), String)
716
+
717
+ # Common functionality for `AssertNil` and `RefuteNil` cops.
718
+ module RuboCop::Cop::Minitest::NilAssertionHandleable
719
+ private
720
+
721
+ def autocorrect(corrector, node, actual); end
722
+ def build_message(node, actual, message); end
723
+
724
+ # @return [Boolean]
725
+ def comparison_or_predicate_assertion_method?(node); end
726
+
727
+ def register_offense(node, actual, message); end
728
+ end
729
+
730
+ RuboCop::Cop::Minitest::NilAssertionHandleable::MSG = T.let(T.unsafe(nil), String)
731
+
732
+ # Checks if test cases contain any assertion calls.
733
+ #
734
+ # @example
735
+ # # bad
736
+ # class FooTest < Minitest::Test
737
+ # def test_the_truth
738
+ # end
739
+ # end
740
+ #
741
+ # # good
742
+ # class FooTest < Minitest::Test
743
+ # def test_the_truth
744
+ # assert true
745
+ # end
746
+ # end
747
+ class RuboCop::Cop::Minitest::NoAssertions < ::RuboCop::Cop::Base
748
+ include ::RuboCop::Cop::MinitestExplorationHelpers
749
+
750
+ def on_class(class_node); end
751
+
752
+ private
753
+
754
+ def assertions_count(node); end
755
+ end
756
+
757
+ RuboCop::Cop::Minitest::NoAssertions::MSG = T.let(T.unsafe(nil), String)
758
+
759
+ # Common functionality for `Minitest/AssertPredicate` and `Minitest/RefutePredicate` cops.
760
+ module RuboCop::Cop::Minitest::PredicateAssertionHandleable
761
+ def autocorrect(corrector, node, arguments); end
762
+ def on_send(node); end
763
+
764
+ private
765
+
766
+ def correct_receiver(receiver); end
767
+ def new_arguments(arguments); end
768
+ def offense_message(arguments); end
769
+ def peel_redundant_parentheses_from(arguments); end
770
+ end
771
+
772
+ RuboCop::Cop::Minitest::PredicateAssertionHandleable::MSG = T.let(T.unsafe(nil), String)
773
+ RuboCop::Cop::Minitest::PredicateAssertionHandleable::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
774
+
775
+ # Enforces to use `refute_empty` instead of using `refute(object.empty?)`.
776
+ #
777
+ # @example
778
+ # # bad
779
+ # refute(object.empty?)
780
+ # refute(object.empty?, 'message')
781
+ #
782
+ # # good
783
+ # refute_empty(object)
784
+ # refute_empty(object, 'message')
785
+ class RuboCop::Cop::Minitest::RefuteEmpty < ::RuboCop::Cop::Base
786
+ include ::RuboCop::Cop::RangeHelp
787
+ include ::RuboCop::Cop::ArgumentRangeHelper
788
+ extend ::RuboCop::Cop::MinitestCopRule
789
+ extend ::RuboCop::Cop::AutoCorrector
790
+
791
+ def autocorrect(corrector, node, arguments); end
792
+ def on_send(node); end
793
+
794
+ private
795
+
796
+ def correct_receiver(receiver); end
797
+ def enclosed_in_redundant_parentheses?(node); end
798
+ def new_arguments(arguments); end
799
+ def offense_message(arguments); end
800
+ def peel_redundant_parentheses_from(arguments); end
801
+ end
802
+
803
+ RuboCop::Cop::Minitest::RefuteEmpty::MSG = T.let(T.unsafe(nil), String)
804
+ RuboCop::Cop::Minitest::RefuteEmpty::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
805
+
806
+ # Enforces the use of `refute_equal(expected, object)`
807
+ # over `assert(expected != actual)` or `assert(! expected == actual)`.
808
+ #
809
+ # @example
810
+ # # bad
811
+ # assert("rubocop-minitest" != actual)
812
+ # assert(! "rubocop-minitest" == actual)
813
+ #
814
+ # # good
815
+ # refute_equal("rubocop-minitest", actual)
816
+ class RuboCop::Cop::Minitest::RefuteEqual < ::RuboCop::Cop::Base
817
+ include ::RuboCop::Cop::RangeHelp
818
+ include ::RuboCop::Cop::ArgumentRangeHelper
819
+ extend ::RuboCop::Cop::AutoCorrector
820
+
821
+ def assert_not_equal(param0 = T.unsafe(nil)); end
822
+ def on_send(node); end
823
+
824
+ private
825
+
826
+ def original_usage(first_part, custom_message); end
827
+ def preferred_usage(first_arg, second_arg, custom_message = T.unsafe(nil)); end
828
+ def process_not_equal(node); end
829
+ end
830
+
831
+ RuboCop::Cop::Minitest::RefuteEqual::MSG = T.let(T.unsafe(nil), String)
832
+ RuboCop::Cop::Minitest::RefuteEqual::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
833
+
834
+ # Enforces the use of `refute(object)` over `assert_equal(false, object)`.
835
+ #
836
+ # @example
837
+ # # bad
838
+ # assert_equal(false, actual)
839
+ # assert_equal(false, actual, 'message')
840
+ #
841
+ # assert(!test)
842
+ # assert(!test, 'message')
843
+ #
844
+ # # good
845
+ # refute(actual)
846
+ # refute(actual, 'message')
847
+ class RuboCop::Cop::Minitest::RefuteFalse < ::RuboCop::Cop::Base
848
+ include ::RuboCop::Cop::RangeHelp
849
+ include ::RuboCop::Cop::ArgumentRangeHelper
850
+ extend ::RuboCop::Cop::AutoCorrector
851
+
852
+ def assert_equal_with_false(param0 = T.unsafe(nil)); end
853
+ def assert_with_bang_argument(param0 = T.unsafe(nil)); end
854
+ def on_send(node); end
855
+
856
+ private
857
+
858
+ def autocorrect(corrector, node, actual); end
859
+ end
860
+
861
+ RuboCop::Cop::Minitest::RefuteFalse::MSG_FOR_ASSERT = T.let(T.unsafe(nil), String)
862
+ RuboCop::Cop::Minitest::RefuteFalse::MSG_FOR_ASSERT_EQUAL = T.let(T.unsafe(nil), String)
863
+ RuboCop::Cop::Minitest::RefuteFalse::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
864
+
865
+ # Enforces the test to use `refute_in_delta`
866
+ # instead of using `refute_equal` to compare floats.
867
+ #
868
+ # @example
869
+ # # bad
870
+ # refute_equal(0.2, actual)
871
+ # refute_equal(0.2, actual, 'message')
872
+ #
873
+ # # good
874
+ # refute_in_delta(0.2, actual)
875
+ # refute_in_delta(0.2, actual, 0.001, 'message')
876
+ class RuboCop::Cop::Minitest::RefuteInDelta < ::RuboCop::Cop::Base
877
+ include ::RuboCop::Cop::InDeltaMixin
878
+ extend ::RuboCop::Cop::AutoCorrector
879
+
880
+ def equal_floats_call(param0 = T.unsafe(nil)); end
881
+ end
882
+
883
+ RuboCop::Cop::Minitest::RefuteInDelta::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
884
+
885
+ # Enforces the test to use `refute_includes`
886
+ # instead of using `refute(collection.include?(object))`.
887
+ #
888
+ # @example
889
+ # # bad
890
+ # refute(collection.include?(object))
891
+ # refute(collection.include?(object), 'message')
892
+ #
893
+ # # good
894
+ # refute_includes(collection, object)
895
+ # refute_includes(collection, object, 'message')
896
+ class RuboCop::Cop::Minitest::RefuteIncludes < ::RuboCop::Cop::Base
897
+ include ::RuboCop::Cop::RangeHelp
898
+ include ::RuboCop::Cop::ArgumentRangeHelper
899
+ extend ::RuboCop::Cop::MinitestCopRule
900
+ extend ::RuboCop::Cop::AutoCorrector
901
+
902
+ def autocorrect(corrector, node, arguments); end
903
+ def on_send(node); end
904
+
905
+ private
906
+
907
+ def correct_receiver(receiver); end
908
+ def enclosed_in_redundant_parentheses?(node); end
909
+ def new_arguments(arguments); end
910
+ def offense_message(arguments); end
911
+ def peel_redundant_parentheses_from(arguments); end
912
+ end
913
+
914
+ RuboCop::Cop::Minitest::RefuteIncludes::MSG = T.let(T.unsafe(nil), String)
915
+ RuboCop::Cop::Minitest::RefuteIncludes::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
916
+
917
+ # Enforces the use of `refute_instance_of(Class, object)`
918
+ # over `refute(object.instance_of?(Class))`.
919
+ #
920
+ # @example
921
+ # # bad
922
+ # refute(object.instance_of?(Class))
923
+ # refute(object.instance_of?(Class), 'message')
924
+ #
925
+ # # good
926
+ # refute_instance_of(Class, object)
927
+ # refute_instance_of(Class, object, 'message')
928
+ class RuboCop::Cop::Minitest::RefuteInstanceOf < ::RuboCop::Cop::Base
929
+ include ::RuboCop::Cop::RangeHelp
930
+ include ::RuboCop::Cop::ArgumentRangeHelper
931
+ extend ::RuboCop::Cop::MinitestCopRule
932
+ extend ::RuboCop::Cop::AutoCorrector
933
+
934
+ def autocorrect(corrector, node, arguments); end
935
+ def on_send(node); end
936
+
937
+ private
938
+
939
+ def correct_receiver(receiver); end
940
+ def enclosed_in_redundant_parentheses?(node); end
941
+ def new_arguments(arguments); end
942
+ def offense_message(arguments); end
943
+ def peel_redundant_parentheses_from(arguments); end
944
+ end
945
+
946
+ RuboCop::Cop::Minitest::RefuteInstanceOf::MSG = T.let(T.unsafe(nil), String)
947
+ RuboCop::Cop::Minitest::RefuteInstanceOf::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
948
+
949
+ # Enforces the use of `refute_kind_of(Class, object)`
950
+ # over `refute(object.kind_of?(Class))`.
951
+ #
952
+ # @example
953
+ # # bad
954
+ # refute(object.kind_of?(Class))
955
+ # refute(object.kind_of?(Class), 'message')
956
+ #
957
+ # # good
958
+ # refute_kind_of(Class, object)
959
+ # refute_kind_of(Class, object, 'message')
960
+ class RuboCop::Cop::Minitest::RefuteKindOf < ::RuboCop::Cop::Base
961
+ include ::RuboCop::Cop::RangeHelp
962
+ include ::RuboCop::Cop::ArgumentRangeHelper
963
+ extend ::RuboCop::Cop::MinitestCopRule
964
+ extend ::RuboCop::Cop::AutoCorrector
965
+
966
+ def autocorrect(corrector, node, arguments); end
967
+ def on_send(node); end
968
+
969
+ private
970
+
971
+ def correct_receiver(receiver); end
972
+ def enclosed_in_redundant_parentheses?(node); end
973
+ def new_arguments(arguments); end
974
+ def offense_message(arguments); end
975
+ def peel_redundant_parentheses_from(arguments); end
976
+ end
977
+
978
+ RuboCop::Cop::Minitest::RefuteKindOf::MSG = T.let(T.unsafe(nil), String)
979
+ RuboCop::Cop::Minitest::RefuteKindOf::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
980
+
981
+ # Enforces the test to use `refute_match`
982
+ # instead of using `refute(matcher.match(string))`.
983
+ #
984
+ # @example
985
+ # # bad
986
+ # refute(matcher.match(string))
987
+ # refute(matcher.match(string), 'message')
988
+ #
989
+ # # good
990
+ # refute_match(matcher, string)
991
+ # refute_match(matcher, string, 'message')
992
+ class RuboCop::Cop::Minitest::RefuteMatch < ::RuboCop::Cop::Base
993
+ include ::RuboCop::Cop::RangeHelp
994
+ include ::RuboCop::Cop::ArgumentRangeHelper
995
+ extend ::RuboCop::Cop::MinitestCopRule
996
+ extend ::RuboCop::Cop::AutoCorrector
997
+
998
+ def autocorrect(corrector, node, arguments); end
999
+ def on_send(node); end
1000
+
1001
+ private
1002
+
1003
+ def correct_receiver(receiver); end
1004
+ def enclosed_in_redundant_parentheses?(node); end
1005
+ def new_arguments(arguments); end
1006
+ def offense_message(arguments); end
1007
+ def peel_redundant_parentheses_from(arguments); end
1008
+ end
1009
+
1010
+ RuboCop::Cop::Minitest::RefuteMatch::MSG = T.let(T.unsafe(nil), String)
1011
+ RuboCop::Cop::Minitest::RefuteMatch::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1012
+
1013
+ # Enforces the test to use `refute_nil` instead of using
1014
+ # `refute_equal(nil, something)`, `refute(something.nil?)`, or `refute_predicate(something, :nil?)`.
1015
+ #
1016
+ # @example
1017
+ # # bad
1018
+ # refute_equal(nil, actual)
1019
+ # refute_equal(nil, actual, 'message')
1020
+ # refute(actual.nil?)
1021
+ # refute(actual.nil?, 'message')
1022
+ # refute_predicate(object, :nil?)
1023
+ # refute_predicate(object, :nil?, 'message')
1024
+ #
1025
+ # # good
1026
+ # refute_nil(actual)
1027
+ # refute_nil(actual, 'message')
1028
+ class RuboCop::Cop::Minitest::RefuteNil < ::RuboCop::Cop::Base
1029
+ include ::RuboCop::Cop::RangeHelp
1030
+ include ::RuboCop::Cop::ArgumentRangeHelper
1031
+ include ::RuboCop::Cop::Minitest::NilAssertionHandleable
1032
+ extend ::RuboCop::Cop::AutoCorrector
1033
+
1034
+ def nil_refutation(param0 = T.unsafe(nil)); end
1035
+ def on_send(node); end
1036
+
1037
+ private
1038
+
1039
+ def assertion_type; end
1040
+ end
1041
+
1042
+ RuboCop::Cop::Minitest::RefuteNil::ASSERTION_TYPE = T.let(T.unsafe(nil), String)
1043
+ RuboCop::Cop::Minitest::RefuteNil::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1044
+
1045
+ # Enforces the test to use `refute_path_exists` instead of using `refute(File.exist?(path))`.
1046
+ #
1047
+ # @example
1048
+ # # bad
1049
+ # refute(File.exist?(path))
1050
+ # refute(File.exist?(path), 'message')
1051
+ #
1052
+ # # good
1053
+ # refute_path_exists(path)
1054
+ # refute_path_exists(path, 'message')
1055
+ class RuboCop::Cop::Minitest::RefutePathExists < ::RuboCop::Cop::Base
1056
+ extend ::RuboCop::Cop::AutoCorrector
1057
+
1058
+ def on_send(node); end
1059
+ def refute_file_exists(param0 = T.unsafe(nil)); end
1060
+
1061
+ private
1062
+
1063
+ def build_good_method(path, message); end
1064
+ end
1065
+
1066
+ RuboCop::Cop::Minitest::RefutePathExists::MSG = T.let(T.unsafe(nil), String)
1067
+ RuboCop::Cop::Minitest::RefutePathExists::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1068
+
1069
+ # Enforces the test to use `refute_predicate`
1070
+ # instead of using `refute(obj.a_predicate_method?)`.
1071
+ #
1072
+ # @example
1073
+ # # bad
1074
+ # refute(obj.one?)
1075
+ # refute(obj.one?, 'message')
1076
+ #
1077
+ # # good
1078
+ # refute_predicate(obj, :one?)
1079
+ # refute_predicate(obj, :one?, 'message')
1080
+ class RuboCop::Cop::Minitest::RefutePredicate < ::RuboCop::Cop::Base
1081
+ include ::RuboCop::Cop::RangeHelp
1082
+ include ::RuboCop::Cop::ArgumentRangeHelper
1083
+ include ::RuboCop::Cop::Minitest::PredicateAssertionHandleable
1084
+ extend ::RuboCop::Cop::AutoCorrector
1085
+
1086
+ private
1087
+
1088
+ def assertion_type; end
1089
+ end
1090
+
1091
+ RuboCop::Cop::Minitest::RefutePredicate::MSG = T.let(T.unsafe(nil), String)
1092
+ RuboCop::Cop::Minitest::RefutePredicate::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1093
+
1094
+ # Enforces the test to use `refute_respond_to(object, :do_something)`
1095
+ # over `refute(object.respond_to?(:do_something))`.
1096
+ #
1097
+ # @example
1098
+ # # bad
1099
+ # refute(object.respond_to?(:do_something))
1100
+ # refute(object.respond_to?(:do_something), 'message')
1101
+ # refute(respond_to?(:do_something))
1102
+ #
1103
+ # # good
1104
+ # refute_respond_to(object, :do_something)
1105
+ # refute_respond_to(object, :do_something, 'message')
1106
+ # refute_respond_to(self, :do_something)
1107
+ class RuboCop::Cop::Minitest::RefuteRespondTo < ::RuboCop::Cop::Base
1108
+ include ::RuboCop::Cop::RangeHelp
1109
+ include ::RuboCop::Cop::ArgumentRangeHelper
1110
+ extend ::RuboCop::Cop::MinitestCopRule
1111
+ extend ::RuboCop::Cop::AutoCorrector
1112
+
1113
+ def autocorrect(corrector, node, arguments); end
1114
+ def on_send(node); end
1115
+
1116
+ private
1117
+
1118
+ def correct_receiver(receiver); end
1119
+ def enclosed_in_redundant_parentheses?(node); end
1120
+ def new_arguments(arguments); end
1121
+ def offense_message(arguments); end
1122
+ def peel_redundant_parentheses_from(arguments); end
1123
+ end
1124
+
1125
+ RuboCop::Cop::Minitest::RefuteRespondTo::MSG = T.let(T.unsafe(nil), String)
1126
+ RuboCop::Cop::Minitest::RefuteRespondTo::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1127
+
1128
+ # Checks that `ensure` call even if `skip`. It is unexpected that `ensure` will be called when skipping test.
1129
+ # If conditional `skip` is used, it checks that `ensure` is also called conditionally.
1130
+ #
1131
+ # On the other hand, it accepts `skip` used in `rescue` because `ensure` may be teardown process to `begin`
1132
+ # setup process.
1133
+ #
1134
+ # @example
1135
+ #
1136
+ # # bad
1137
+ # def test_skip
1138
+ # skip 'This test is skipped.'
1139
+ #
1140
+ # assert 'foo'.present?
1141
+ # ensure
1142
+ # do_something
1143
+ # end
1144
+ #
1145
+ # # bad
1146
+ # def test_conditional_skip
1147
+ # skip 'This test is skipped.' if condition
1148
+ #
1149
+ # assert do_something
1150
+ # ensure
1151
+ # do_teardown
1152
+ # end
1153
+ #
1154
+ # # good
1155
+ # def test_skip
1156
+ # skip 'This test is skipped.'
1157
+ #
1158
+ # begin
1159
+ # assert 'foo'.present?
1160
+ # ensure
1161
+ # do_something
1162
+ # end
1163
+ # end
1164
+ #
1165
+ # # good
1166
+ # def test_conditional_skip
1167
+ # skip 'This test is skipped.' if condition
1168
+ #
1169
+ # assert do_something
1170
+ # ensure
1171
+ # if condition
1172
+ # do_teardown
1173
+ # end
1174
+ # end
1175
+ #
1176
+ # # good
1177
+ # def test_skip_is_used_in_rescue
1178
+ # do_setup
1179
+ # assert do_something
1180
+ # rescue
1181
+ # skip 'This test is skipped.'
1182
+ # ensure
1183
+ # do_teardown
1184
+ # end
1185
+ class RuboCop::Cop::Minitest::SkipEnsure < ::RuboCop::Cop::Base
1186
+ def on_ensure(node); end
1187
+
1188
+ private
1189
+
1190
+ def find_skip(node); end
1191
+
1192
+ # @return [Boolean]
1193
+ def use_skip_in_rescue?(skip_method); end
1194
+
1195
+ # @return [Boolean]
1196
+ def valid_conditional_skip?(skip_method, ensure_node); end
1197
+ end
1198
+
1199
+ RuboCop::Cop::Minitest::SkipEnsure::MSG = T.let(T.unsafe(nil), String)
1200
+
1201
+ # Enforces that test method names start with `test_` prefix.
1202
+ # It aims to prevent tests that aren't executed by forgetting to start test method name with `test_`.
1203
+ #
1204
+ # @example
1205
+ # # bad
1206
+ # class FooTest < Minitest::Test
1207
+ # def does_something
1208
+ # assert_equal 42, do_something
1209
+ # end
1210
+ # end
1211
+ #
1212
+ # # good
1213
+ # class FooTest < Minitest::Test
1214
+ # def test_does_something
1215
+ # assert_equal 42, do_something
1216
+ # end
1217
+ # end
1218
+ #
1219
+ # # good
1220
+ # class FooTest < Minitest::Test
1221
+ # def helper_method(argument)
1222
+ # end
1223
+ # end
1224
+ class RuboCop::Cop::Minitest::TestMethodName < ::RuboCop::Cop::Base
1225
+ include ::RuboCop::Cop::MinitestExplorationHelpers
1226
+ include ::RuboCop::Cop::DefNode
1227
+ extend ::RuboCop::Cop::AutoCorrector
1228
+
1229
+ def on_class(class_node); end
1230
+
1231
+ private
1232
+
1233
+ def class_elements(class_node); end
1234
+
1235
+ # @return [Boolean]
1236
+ def offense?(node); end
1237
+
1238
+ # @return [Boolean]
1239
+ def public?(node); end
1240
+
1241
+ # @return [Boolean]
1242
+ def test_method_name?(node); end
1243
+ end
1244
+
1245
+ RuboCop::Cop::Minitest::TestMethodName::MSG = T.let(T.unsafe(nil), String)
1246
+
1247
+ # Checks for `assert_raises` has an assertion method at
1248
+ # the bottom of block because the assertion will be never reached.
1249
+ #
1250
+ # @example
1251
+ #
1252
+ # # bad
1253
+ # assert_raises FooError do
1254
+ # obj.occur_error
1255
+ # assert_equal('foo', obj.bar) # Never asserted.
1256
+ # end
1257
+ #
1258
+ # # good
1259
+ # assert_raises FooError do
1260
+ # obj.occur_error
1261
+ # end
1262
+ # assert_equal('foo', obj.bar)
1263
+ class RuboCop::Cop::Minitest::UnreachableAssertion < ::RuboCop::Cop::Base
1264
+ include ::RuboCop::Cop::MinitestExplorationHelpers
1265
+
1266
+ def on_block(node); end
1267
+ end
1268
+
1269
+ RuboCop::Cop::Minitest::UnreachableAssertion::MSG = T.let(T.unsafe(nil), String)
1270
+
1271
+ # Checks for a specified error in `assert_raises`.
1272
+ #
1273
+ # @example
1274
+ # # bad
1275
+ # assert_raises { raise FooException }
1276
+ # assert_raises('This should have raised') { raise FooException }
1277
+ #
1278
+ # # good
1279
+ # assert_raises(FooException) { raise FooException }
1280
+ # assert_raises(FooException, 'This should have raised') { raise FooException }
1281
+ class RuboCop::Cop::Minitest::UnspecifiedException < ::RuboCop::Cop::Base
1282
+ def on_block(block_node); end
1283
+
1284
+ private
1285
+
1286
+ # @return [Boolean]
1287
+ def unspecified_exception?(node); end
1288
+ end
1289
+
1290
+ RuboCop::Cop::Minitest::UnspecifiedException::MSG = T.let(T.unsafe(nil), String)
1291
+
1292
+ # Provide a method to define offense rule for Minitest cops.
1293
+ module RuboCop::Cop::MinitestCopRule
1294
+ # Define offense rule for Minitest cops.
1295
+ #
1296
+ # @example
1297
+ # define_rule :assert, target_method: :match
1298
+ # define_rule :refute, target_method: :match
1299
+ # define_rule :assert, target_method: :include?, preferred_method: :assert_includes
1300
+ # define_rule :assert, target_method: :instance_of?, inverse: true
1301
+ # @param assertion_method [Symbol] Assertion method like `assert` or `refute`.
1302
+ # @param target_method [Symbol] Method name offensed by assertion method arguments.
1303
+ # @param preferred_method [Symbol] An optional param. Custom method name replaced by
1304
+ # autocorrection. The preferred method name that connects
1305
+ # `assertion_method` and `target_method` with `_` is
1306
+ # the default name.
1307
+ # @param inverse [Boolean] An optional param. Order of arguments replaced by autocorrection.
1308
+ def define_rule(assertion_method, target_method:, preferred_method: T.unsafe(nil), inverse: T.unsafe(nil)); end
1309
+ end
1310
+
1311
+ # Helper methods for different explorations against test files and test cases.
1312
+ module RuboCop::Cop::MinitestExplorationHelpers
1313
+ extend ::RuboCop::AST::NodePattern::Macros
1314
+
1315
+ private
1316
+
1317
+ # @return [Boolean]
1318
+ def assertion_method?(node); end
1319
+
1320
+ def assertions(def_node); end
1321
+ def class_def_nodes(class_node); end
1322
+
1323
+ # @return [Boolean]
1324
+ def lifecycle_hook_method?(node); end
1325
+
1326
+ def lifecycle_hooks(class_node); end
1327
+
1328
+ # @return [Boolean]
1329
+ def test_case?(node); end
1330
+
1331
+ # @return [Boolean]
1332
+ def test_case_name?(name); end
1333
+
1334
+ def test_cases(class_node); end
1335
+
1336
+ # @return [Boolean]
1337
+ def test_class?(class_node); end
1338
+ end
1339
+
1340
+ RuboCop::Cop::MinitestExplorationHelpers::ASSERTION_PREFIXES = T.let(T.unsafe(nil), Array)
1341
+ RuboCop::Cop::MinitestExplorationHelpers::LIFECYCLE_HOOK_METHODS = T.let(T.unsafe(nil), Set)
1342
+
1343
+ # RuboCop minitest project namespace
1344
+ module RuboCop::Minitest; end
1345
+
1346
+ RuboCop::Minitest::CONFIG = T.let(T.unsafe(nil), Hash)
1347
+ RuboCop::Minitest::CONFIG_DEFAULT = T.let(T.unsafe(nil), Pathname)
1348
+
1349
+ # Because RuboCop doesn't yet support plugins, we have to monkey patch in a
1350
+ # bit of our configuration.
1351
+ module RuboCop::Minitest::Inject
1352
+ class << self
1353
+ def defaults!; end
1354
+ end
1355
+ end
1356
+
1357
+ RuboCop::Minitest::PROJECT_ROOT = T.let(T.unsafe(nil), Pathname)
1358
+
1359
+ # This module holds the RuboCop Minitest version information.
1360
+ module RuboCop::Minitest::Version
1361
+ class << self
1362
+ def document_version; end
1363
+ end
1364
+ end
1365
+
1366
+ RuboCop::Minitest::Version::STRING = T.let(T.unsafe(nil), String)
1367
+ RuboCop::NodePattern = RuboCop::AST::NodePattern
1368
+ RuboCop::ProcessedSource = RuboCop::AST::ProcessedSource
1369
+ RuboCop::Token = RuboCop::AST::Token