tsumanne 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +32 -0
  4. data/.ruby-version +1 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +31 -0
  7. data/Rakefile +45 -0
  8. data/lib/tsumanne/version.rb +7 -0
  9. data/lib/tsumanne.rb +128 -0
  10. data/sorbet/config +4 -0
  11. data/sorbet/rbi/annotations/rainbow.rbi +269 -0
  12. data/sorbet/rbi/gems/ast@2.4.2.rbi +584 -0
  13. data/sorbet/rbi/gems/base64@0.1.1.rbi +172 -0
  14. data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +1083 -0
  15. data/sorbet/rbi/gems/erubi@1.12.0.rbi +145 -0
  16. data/sorbet/rbi/gems/ffi-compiler@1.0.1.rbi +206 -0
  17. data/sorbet/rbi/gems/ffi@1.15.5.rbi +1994 -0
  18. data/sorbet/rbi/gems/http-parser@1.2.3.rbi +422 -0
  19. data/sorbet/rbi/gems/json@2.6.3.rbi +1533 -0
  20. data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +14237 -0
  21. data/sorbet/rbi/gems/mhtml@0.1.6.rbi +353 -0
  22. data/sorbet/rbi/gems/netrc@0.11.0.rbi +158 -0
  23. data/sorbet/rbi/gems/parallel@1.23.0.rbi +273 -0
  24. data/sorbet/rbi/gems/parser@3.2.2.3.rbi +7253 -0
  25. data/sorbet/rbi/gems/prettier_print@1.2.1.rbi +951 -0
  26. data/sorbet/rbi/gems/racc@1.7.1.rbi +161 -0
  27. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +402 -0
  28. data/sorbet/rbi/gems/rake@13.0.6.rbi +3024 -0
  29. data/sorbet/rbi/gems/rbi@0.0.17.rbi +2967 -0
  30. data/sorbet/rbi/gems/regexp_parser@2.8.1.rbi +3749 -0
  31. data/sorbet/rbi/gems/rexml@3.2.6.rbi +4781 -0
  32. data/sorbet/rbi/gems/rspec-core@3.12.2.rbi +10805 -0
  33. data/sorbet/rbi/gems/rspec-expectations@3.12.3.rbi +8100 -0
  34. data/sorbet/rbi/gems/rspec-mocks@3.12.6.rbi +5310 -0
  35. data/sorbet/rbi/gems/rspec-support@3.12.1.rbi +1609 -0
  36. data/sorbet/rbi/gems/rspec@3.12.0.rbi +82 -0
  37. data/sorbet/rbi/gems/rubocop-ast@1.29.0.rbi +7144 -0
  38. data/sorbet/rbi/gems/rubocop-capybara@2.18.0.rbi +827 -0
  39. data/sorbet/rbi/gems/rubocop-factory_bot@2.23.1.rbi +812 -0
  40. data/sorbet/rbi/gems/rubocop-performance@1.19.0.rbi +3157 -0
  41. data/sorbet/rbi/gems/rubocop-rake@0.6.0.rbi +328 -0
  42. data/sorbet/rbi/gems/rubocop-rspec@2.23.2.rbi +7691 -0
  43. data/sorbet/rbi/gems/rubocop-sorbet@0.7.3.rbi +1226 -0
  44. data/sorbet/rbi/gems/rubocop@1.56.2.rbi +56541 -0
  45. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1317 -0
  46. data/sorbet/rbi/gems/spoom@1.2.3.rbi +3199 -0
  47. data/sorbet/rbi/gems/syntax_tree@6.1.1.rbi +22855 -0
  48. data/sorbet/rbi/gems/tapioca@0.11.8.rbi +3329 -0
  49. data/sorbet/rbi/gems/thor@1.2.2.rbi +3965 -0
  50. data/sorbet/rbi/gems/unicode-display_width@2.4.2.rbi +65 -0
  51. data/sorbet/rbi/gems/unparser@0.6.8.rbi +4525 -0
  52. data/sorbet/rbi/gems/yard-sorbet@0.8.1.rbi +425 -0
  53. data/sorbet/rbi/gems/yard@0.9.34.rbi +18219 -0
  54. data/sorbet/tapioca/config.yml +13 -0
  55. data/sorbet/tapioca/require.rb +4 -0
  56. metadata +254 -0
@@ -0,0 +1,3157 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `rubocop-performance` gem.
5
+ # Please instead update this file by running `bin/tapioca gem rubocop-performance`.
6
+
7
+ # source://rubocop-performance//lib/rubocop/performance.rb#3
8
+ module RuboCop; end
9
+
10
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#4
11
+ module RuboCop::Cop; end
12
+
13
+ # source://rubocop-performance//lib/rubocop/cop/performance/ancestors_include.rb#5
14
+ module RuboCop::Cop::Performance; end
15
+
16
+ # Identifies usages of `ancestors.include?` and change them to use `<=` instead.
17
+ #
18
+ # @example
19
+ # # bad
20
+ # A.ancestors.include?(B)
21
+ #
22
+ # # good
23
+ # A <= B
24
+ #
25
+ # source://rubocop-performance//lib/rubocop/cop/performance/ancestors_include.rb#19
26
+ class RuboCop::Cop::Performance::AncestorsInclude < ::RuboCop::Cop::Base
27
+ include ::RuboCop::Cop::RangeHelp
28
+ extend ::RuboCop::Cop::AutoCorrector
29
+
30
+ # source://rubocop-performance//lib/rubocop/cop/performance/ancestors_include.rb#26
31
+ def ancestors_include_candidate?(param0 = T.unsafe(nil)); end
32
+
33
+ # source://rubocop-performance//lib/rubocop/cop/performance/ancestors_include.rb#30
34
+ def on_send(node); end
35
+
36
+ private
37
+
38
+ # source://rubocop-performance//lib/rubocop/cop/performance/ancestors_include.rb#43
39
+ def range(node); end
40
+ end
41
+
42
+ # source://rubocop-performance//lib/rubocop/cop/performance/ancestors_include.rb#23
43
+ RuboCop::Cop::Performance::AncestorsInclude::MSG = T.let(T.unsafe(nil), String)
44
+
45
+ # source://rubocop-performance//lib/rubocop/cop/performance/ancestors_include.rb#24
46
+ RuboCop::Cop::Performance::AncestorsInclude::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
47
+
48
+ # Identifies places where slicing arrays with semi-infinite ranges
49
+ # can be replaced by `Array#take` and `Array#drop`.
50
+ # This cop was created due to a mistake in microbenchmark and hence is disabled by default.
51
+ # Refer https://github.com/rubocop/rubocop-performance/pull/175#issuecomment-731892717
52
+ #
53
+ # @example
54
+ # # bad
55
+ # array[..2]
56
+ # array[...2]
57
+ # array[2..]
58
+ # array[2...]
59
+ # array.slice(..2)
60
+ #
61
+ # # good
62
+ # array.take(3)
63
+ # array.take(2)
64
+ # array.drop(2)
65
+ # array.drop(2)
66
+ # array.take(3)
67
+ #
68
+ # source://rubocop-performance//lib/rubocop/cop/performance/array_semi_infinite_range_slice.rb#29
69
+ class RuboCop::Cop::Performance::ArraySemiInfiniteRangeSlice < ::RuboCop::Cop::Base
70
+ include ::RuboCop::Cop::RangeHelp
71
+ extend ::RuboCop::Cop::AutoCorrector
72
+ extend ::RuboCop::Cop::TargetRubyVersion
73
+
74
+ # source://rubocop-performance//lib/rubocop/cop/performance/array_semi_infinite_range_slice.rb#45
75
+ def endless_range?(param0 = T.unsafe(nil)); end
76
+
77
+ # source://rubocop-performance//lib/rubocop/cop/performance/array_semi_infinite_range_slice.rb#41
78
+ def endless_range_slice?(param0 = T.unsafe(nil)); end
79
+
80
+ # source://rubocop-performance//lib/rubocop/cop/performance/array_semi_infinite_range_slice.rb#52
81
+ def on_csend(node); end
82
+
83
+ # source://rubocop-performance//lib/rubocop/cop/performance/array_semi_infinite_range_slice.rb#52
84
+ def on_send(node); end
85
+
86
+ private
87
+
88
+ # source://rubocop-performance//lib/rubocop/cop/performance/array_semi_infinite_range_slice.rb#66
89
+ def correction(receiver, range_node); end
90
+ end
91
+
92
+ # source://rubocop-performance//lib/rubocop/cop/performance/array_semi_infinite_range_slice.rb#36
93
+ RuboCop::Cop::Performance::ArraySemiInfiniteRangeSlice::MSG = T.let(T.unsafe(nil), String)
94
+
95
+ # source://rubocop-performance//lib/rubocop/cop/performance/array_semi_infinite_range_slice.rb#39
96
+ RuboCop::Cop::Performance::ArraySemiInfiniteRangeSlice::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Set)
97
+
98
+ # source://rubocop-performance//lib/rubocop/cop/performance/array_semi_infinite_range_slice.rb#38
99
+ RuboCop::Cop::Performance::ArraySemiInfiniteRangeSlice::SLICE_METHODS = T.let(T.unsafe(nil), Set)
100
+
101
+ # Identifies places where numeric argument to BigDecimal should be
102
+ # converted to string. Initializing from String is faster
103
+ # than from Numeric for BigDecimal.
104
+ #
105
+ # @example
106
+ # # bad
107
+ # BigDecimal(1, 2)
108
+ # 4.to_d(6)
109
+ # BigDecimal(1.2, 3, exception: true)
110
+ # 4.5.to_d(6, exception: true)
111
+ #
112
+ # # good
113
+ # BigDecimal('1', 2)
114
+ # BigDecimal('4', 6)
115
+ # BigDecimal('1.2', 3, exception: true)
116
+ # BigDecimal('4.5', 6, exception: true)
117
+ #
118
+ # source://rubocop-performance//lib/rubocop/cop/performance/big_decimal_with_numeric_argument.rb#23
119
+ class RuboCop::Cop::Performance::BigDecimalWithNumericArgument < ::RuboCop::Cop::Base
120
+ extend ::RuboCop::Cop::AutoCorrector
121
+
122
+ # source://rubocop-performance//lib/rubocop/cop/performance/big_decimal_with_numeric_argument.rb#29
123
+ def big_decimal_with_numeric_argument?(param0 = T.unsafe(nil)); end
124
+
125
+ # source://rubocop-performance//lib/rubocop/cop/performance/big_decimal_with_numeric_argument.rb#37
126
+ def on_send(node); end
127
+
128
+ # source://rubocop-performance//lib/rubocop/cop/performance/big_decimal_with_numeric_argument.rb#33
129
+ def to_d?(param0 = T.unsafe(nil)); end
130
+ end
131
+
132
+ # source://rubocop-performance//lib/rubocop/cop/performance/big_decimal_with_numeric_argument.rb#26
133
+ RuboCop::Cop::Performance::BigDecimalWithNumericArgument::MSG = T.let(T.unsafe(nil), String)
134
+
135
+ # source://rubocop-performance//lib/rubocop/cop/performance/big_decimal_with_numeric_argument.rb#27
136
+ RuboCop::Cop::Performance::BigDecimalWithNumericArgument::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
137
+
138
+ # In Ruby 2.7, `UnboundMethod#bind_call` has been added.
139
+ #
140
+ # This cop identifies places where `bind(obj).call(args, ...)`
141
+ # can be replaced by `bind_call(obj, args, ...)`.
142
+ #
143
+ # The `bind_call(obj, args, ...)` method is faster than
144
+ # `bind(obj).call(args, ...)`.
145
+ #
146
+ # @example
147
+ # # bad
148
+ # umethod.bind(obj).call(foo, bar)
149
+ # umethod.bind(obj).(foo, bar)
150
+ #
151
+ # # good
152
+ # umethod.bind_call(obj, foo, bar)
153
+ #
154
+ # source://rubocop-performance//lib/rubocop/cop/performance/bind_call.rb#22
155
+ class RuboCop::Cop::Performance::BindCall < ::RuboCop::Cop::Base
156
+ include ::RuboCop::Cop::RangeHelp
157
+ extend ::RuboCop::Cop::AutoCorrector
158
+ extend ::RuboCop::Cop::TargetRubyVersion
159
+
160
+ # source://rubocop-performance//lib/rubocop/cop/performance/bind_call.rb#32
161
+ def bind_with_call_method?(param0 = T.unsafe(nil)); end
162
+
163
+ # source://rubocop-performance//lib/rubocop/cop/performance/bind_call.rb#40
164
+ def on_send(node); end
165
+
166
+ private
167
+
168
+ # source://rubocop-performance//lib/rubocop/cop/performance/bind_call.rb#71
169
+ def build_call_args(call_args_node); end
170
+
171
+ # source://rubocop-performance//lib/rubocop/cop/performance/bind_call.rb#64
172
+ def correction_range(receiver, node); end
173
+
174
+ # source://rubocop-performance//lib/rubocop/cop/performance/bind_call.rb#58
175
+ def message(bind_arg, call_args); end
176
+ end
177
+
178
+ # source://rubocop-performance//lib/rubocop/cop/performance/bind_call.rb#29
179
+ RuboCop::Cop::Performance::BindCall::MSG = T.let(T.unsafe(nil), String)
180
+
181
+ # source://rubocop-performance//lib/rubocop/cop/performance/bind_call.rb#30
182
+ RuboCop::Cop::Performance::BindCall::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
183
+
184
+ # Identifies unnecessary use of a `block_given?` where explicit check
185
+ # of block argument would suffice.
186
+ #
187
+ # @example
188
+ # # bad
189
+ # def method(&block)
190
+ # do_something if block_given?
191
+ # end
192
+ #
193
+ # # good
194
+ # def method(&block)
195
+ # do_something if block
196
+ # end
197
+ #
198
+ # # good - block is reassigned
199
+ # def method(&block)
200
+ # block ||= -> { do_something }
201
+ # warn "Using default ..." unless block_given?
202
+ # # ...
203
+ # end
204
+ #
205
+ # source://rubocop-performance//lib/rubocop/cop/performance/block_given_with_explicit_block.rb#27
206
+ class RuboCop::Cop::Performance::BlockGivenWithExplicitBlock < ::RuboCop::Cop::Base
207
+ extend ::RuboCop::Cop::AutoCorrector
208
+
209
+ # source://rubocop-performance//lib/rubocop/cop/performance/block_given_with_explicit_block.rb#35
210
+ def on_send(node); end
211
+
212
+ # source://rubocop-performance//lib/rubocop/cop/performance/block_given_with_explicit_block.rb#33
213
+ def reassigns_block_arg?(param0 = T.unsafe(nil), param1); end
214
+ end
215
+
216
+ # source://rubocop-performance//lib/rubocop/cop/performance/block_given_with_explicit_block.rb#31
217
+ RuboCop::Cop::Performance::BlockGivenWithExplicitBlock::MSG = T.let(T.unsafe(nil), String)
218
+
219
+ # source://rubocop-performance//lib/rubocop/cop/performance/block_given_with_explicit_block.rb#30
220
+ RuboCop::Cop::Performance::BlockGivenWithExplicitBlock::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
221
+
222
+ # Identifies places where `caller[n]` can be replaced by `caller(n..n).first`.
223
+ #
224
+ # @example
225
+ # # bad
226
+ # caller[1]
227
+ # caller.first
228
+ # caller_locations[1]
229
+ # caller_locations.first
230
+ #
231
+ # # good
232
+ # caller(2..2).first
233
+ # caller(1..1).first
234
+ # caller_locations(2..2).first
235
+ # caller_locations(1..1).first
236
+ #
237
+ # source://rubocop-performance//lib/rubocop/cop/performance/caller.rb#20
238
+ class RuboCop::Cop::Performance::Caller < ::RuboCop::Cop::Base
239
+ extend ::RuboCop::Cop::AutoCorrector
240
+
241
+ # source://rubocop-performance//lib/rubocop/cop/performance/caller.rb#33
242
+ def caller_with_scope_method?(param0 = T.unsafe(nil)); end
243
+
244
+ # source://rubocop-performance//lib/rubocop/cop/performance/caller.rb#40
245
+ def on_send(node); end
246
+
247
+ # source://rubocop-performance//lib/rubocop/cop/performance/caller.rb#26
248
+ def slow_caller?(param0 = T.unsafe(nil)); end
249
+
250
+ private
251
+
252
+ # source://rubocop-performance//lib/rubocop/cop/performance/caller.rb#61
253
+ def int_value(node); end
254
+ end
255
+
256
+ # source://rubocop-performance//lib/rubocop/cop/performance/caller.rb#23
257
+ RuboCop::Cop::Performance::Caller::MSG = T.let(T.unsafe(nil), String)
258
+
259
+ # source://rubocop-performance//lib/rubocop/cop/performance/caller.rb#24
260
+ RuboCop::Cop::Performance::Caller::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
261
+
262
+ # Reordering `when` conditions with a splat to the end
263
+ # of the `when` branches can improve performance.
264
+ #
265
+ # Ruby has to allocate memory for the splat expansion every time
266
+ # that the `case` `when` statement is run. Since Ruby does not support
267
+ # fall through inside of `case` `when`, like some other languages do,
268
+ # the order of the `when` branches should not matter. By placing any
269
+ # splat expansions at the end of the list of `when` branches we will
270
+ # reduce the number of times that memory has to be allocated for
271
+ # the expansion. The exception to this is if multiple of your `when`
272
+ # conditions can be true for any given condition. A likely scenario for
273
+ # this defining a higher level when condition to override a condition
274
+ # that is inside of the splat expansion.
275
+ #
276
+ # @example
277
+ # # bad
278
+ # case foo
279
+ # when *condition
280
+ # bar
281
+ # when baz
282
+ # foobar
283
+ # end
284
+ #
285
+ # case foo
286
+ # when *[1, 2, 3, 4]
287
+ # bar
288
+ # when 5
289
+ # baz
290
+ # end
291
+ #
292
+ # # good
293
+ # case foo
294
+ # when baz
295
+ # foobar
296
+ # when *condition
297
+ # bar
298
+ # end
299
+ #
300
+ # case foo
301
+ # when 1, 2, 3, 4
302
+ # bar
303
+ # when 5
304
+ # baz
305
+ # end
306
+ #
307
+ # source://rubocop-performance//lib/rubocop/cop/performance/case_when_splat.rb#58
308
+ class RuboCop::Cop::Performance::CaseWhenSplat < ::RuboCop::Cop::Base
309
+ include ::RuboCop::Cop::Alignment
310
+ include ::RuboCop::Cop::RangeHelp
311
+ extend ::RuboCop::Cop::AutoCorrector
312
+
313
+ # source://rubocop-performance//lib/rubocop/cop/performance/case_when_splat.rb#66
314
+ def on_case(case_node); end
315
+
316
+ private
317
+
318
+ # source://rubocop-performance//lib/rubocop/cop/performance/case_when_splat.rb#83
319
+ def autocorrect(corrector, when_node); end
320
+
321
+ # source://rubocop-performance//lib/rubocop/cop/performance/case_when_splat.rb#140
322
+ def indent_for(node); end
323
+
324
+ # source://rubocop-performance//lib/rubocop/cop/performance/case_when_splat.rb#100
325
+ def inline_fix_branch(corrector, when_node); end
326
+
327
+ # @return [Boolean]
328
+ #
329
+ # source://rubocop-performance//lib/rubocop/cop/performance/case_when_splat.rb#164
330
+ def needs_reorder?(when_node); end
331
+
332
+ # source://rubocop-performance//lib/rubocop/cop/performance/case_when_splat.rb#136
333
+ def new_branch_without_then(node, new_condition); end
334
+
335
+ # source://rubocop-performance//lib/rubocop/cop/performance/case_when_splat.rb#132
336
+ def new_condition_with_then(node, new_condition); end
337
+
338
+ # @return [Boolean]
339
+ #
340
+ # source://rubocop-performance//lib/rubocop/cop/performance/case_when_splat.rb#158
341
+ def non_splat?(condition); end
342
+
343
+ # source://rubocop-performance//lib/rubocop/cop/performance/case_when_splat.rb#91
344
+ def range(node); end
345
+
346
+ # source://rubocop-performance//lib/rubocop/cop/performance/case_when_splat.rb#107
347
+ def reorder_condition(corrector, when_node); end
348
+
349
+ # source://rubocop-performance//lib/rubocop/cop/performance/case_when_splat.rb#116
350
+ def reordering_correction(when_node); end
351
+
352
+ # source://rubocop-performance//lib/rubocop/cop/performance/case_when_splat.rb#95
353
+ def replacement(conditions); end
354
+
355
+ # source://rubocop-performance//lib/rubocop/cop/performance/case_when_splat.rb#144
356
+ def splat_offenses(when_conditions); end
357
+
358
+ # source://rubocop-performance//lib/rubocop/cop/performance/case_when_splat.rb#126
359
+ def when_branch_range(when_node); end
360
+ end
361
+
362
+ # source://rubocop-performance//lib/rubocop/cop/performance/case_when_splat.rb#64
363
+ RuboCop::Cop::Performance::CaseWhenSplat::ARRAY_MSG = T.let(T.unsafe(nil), String)
364
+
365
+ # source://rubocop-performance//lib/rubocop/cop/performance/case_when_splat.rb#63
366
+ RuboCop::Cop::Performance::CaseWhenSplat::MSG = T.let(T.unsafe(nil), String)
367
+
368
+ # Identifies places where a case-insensitive string comparison
369
+ # can better be implemented using `casecmp`.
370
+ #
371
+ # @example
372
+ # # bad
373
+ # str.downcase == 'abc'
374
+ # str.upcase.eql? 'ABC'
375
+ # 'abc' == str.downcase
376
+ # 'ABC'.eql? str.upcase
377
+ # str.downcase == str.downcase
378
+ #
379
+ # # good
380
+ # str.casecmp('ABC').zero?
381
+ # 'abc'.casecmp(str).zero?
382
+ #
383
+ # source://rubocop-performance//lib/rubocop/cop/performance/casecmp.rb#24
384
+ class RuboCop::Cop::Performance::Casecmp < ::RuboCop::Cop::Base
385
+ extend ::RuboCop::Cop::AutoCorrector
386
+
387
+ # source://rubocop-performance//lib/rubocop/cop/performance/casecmp.rb#45
388
+ def downcase_downcase(param0 = T.unsafe(nil)); end
389
+
390
+ # source://rubocop-performance//lib/rubocop/cop/performance/casecmp.rb#31
391
+ def downcase_eq(param0 = T.unsafe(nil)); end
392
+
393
+ # source://rubocop-performance//lib/rubocop/cop/performance/casecmp.rb#38
394
+ def eq_downcase(param0 = T.unsafe(nil)); end
395
+
396
+ # source://rubocop-performance//lib/rubocop/cop/performance/casecmp.rb#52
397
+ def on_send(node); end
398
+
399
+ private
400
+
401
+ # source://rubocop-performance//lib/rubocop/cop/performance/casecmp.rb#84
402
+ def autocorrect(corrector, node, replacement); end
403
+
404
+ # source://rubocop-performance//lib/rubocop/cop/performance/casecmp.rb#88
405
+ def build_good_method(method, arg, variable); end
406
+
407
+ # source://rubocop-performance//lib/rubocop/cop/performance/casecmp.rb#67
408
+ def take_method_apart(node); end
409
+ end
410
+
411
+ # source://rubocop-performance//lib/rubocop/cop/performance/casecmp.rb#29
412
+ RuboCop::Cop::Performance::Casecmp::CASE_METHODS = T.let(T.unsafe(nil), Array)
413
+
414
+ # source://rubocop-performance//lib/rubocop/cop/performance/casecmp.rb#27
415
+ RuboCop::Cop::Performance::Casecmp::MSG = T.let(T.unsafe(nil), String)
416
+
417
+ # source://rubocop-performance//lib/rubocop/cop/performance/casecmp.rb#28
418
+ RuboCop::Cop::Performance::Casecmp::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
419
+
420
+ # Identifies usages of `array.compact.flatten.map { |x| x.downcase }`.
421
+ # Each of these methods (`compact`, `flatten`, `map`) will generate a new intermediate array
422
+ # that is promptly thrown away. Instead it is faster to mutate when we know it's safe.
423
+ #
424
+ # @example
425
+ # # bad
426
+ # array = ["a", "b", "c"]
427
+ # array.compact.flatten.map { |x| x.downcase }
428
+ #
429
+ # # good
430
+ # array = ["a", "b", "c"]
431
+ # array.compact!
432
+ # array.flatten!
433
+ # array.map! { |x| x.downcase }
434
+ # array
435
+ #
436
+ # source://rubocop-performance//lib/rubocop/cop/performance/chain_array_allocation.rb#21
437
+ class RuboCop::Cop::Performance::ChainArrayAllocation < ::RuboCop::Cop::Base
438
+ include ::RuboCop::Cop::RangeHelp
439
+
440
+ # source://rubocop-performance//lib/rubocop/cop/performance/chain_array_allocation.rb#54
441
+ def chain_array_allocation?(param0 = T.unsafe(nil)); end
442
+
443
+ # source://rubocop-performance//lib/rubocop/cop/performance/chain_array_allocation.rb#62
444
+ def on_send(node); end
445
+ end
446
+
447
+ # These methods ALWAYS return a new array
448
+ # after they're called it's safe to mutate the resulting array
449
+ #
450
+ # source://rubocop-performance//lib/rubocop/cop/performance/chain_array_allocation.rb#37
451
+ RuboCop::Cop::Performance::ChainArrayAllocation::ALWAYS_RETURNS_NEW_ARRAY = T.let(T.unsafe(nil), Set)
452
+
453
+ # These methods have a mutation alternative. For example :collect
454
+ # can be called as :collect!
455
+ #
456
+ # source://rubocop-performance//lib/rubocop/cop/performance/chain_array_allocation.rb#45
457
+ RuboCop::Cop::Performance::ChainArrayAllocation::HAS_MUTATION_ALTERNATIVE = T.let(T.unsafe(nil), Set)
458
+
459
+ # source://rubocop-performance//lib/rubocop/cop/performance/chain_array_allocation.rb#50
460
+ RuboCop::Cop::Performance::ChainArrayAllocation::MSG = T.let(T.unsafe(nil), String)
461
+
462
+ # source://rubocop-performance//lib/rubocop/cop/performance/chain_array_allocation.rb#48
463
+ RuboCop::Cop::Performance::ChainArrayAllocation::RETURNS_NEW_ARRAY = T.let(T.unsafe(nil), Set)
464
+
465
+ # These methods return a new array only when called without a block.
466
+ #
467
+ # source://rubocop-performance//lib/rubocop/cop/performance/chain_array_allocation.rb#33
468
+ RuboCop::Cop::Performance::ChainArrayAllocation::RETURNS_NEW_ARRAY_WHEN_NO_BLOCK = T.let(T.unsafe(nil), Set)
469
+
470
+ # These methods return a new array but only sometimes. They must be
471
+ # called with an argument. For example:
472
+ #
473
+ # [1,2].first # => 1
474
+ # [1,2].first(1) # => [1]
475
+ #
476
+ # source://rubocop-performance//lib/rubocop/cop/performance/chain_array_allocation.rb#30
477
+ RuboCop::Cop::Performance::ChainArrayAllocation::RETURN_NEW_ARRAY_WHEN_ARGS = T.let(T.unsafe(nil), Set)
478
+
479
+ # Identifies places where Array and Hash literals are used within loops.
480
+ # It is better to extract them into a local variable or constant
481
+ # to avoid unnecessary allocations on each iteration.
482
+ #
483
+ # You can set the minimum number of elements to consider
484
+ # an offense with `MinSize`.
485
+ #
486
+ # @example
487
+ # # bad
488
+ # users.select do |user|
489
+ # %i[superadmin admin].include?(user.role)
490
+ # end
491
+ #
492
+ # # good
493
+ # admin_roles = %i[superadmin admin]
494
+ # users.select do |user|
495
+ # admin_roles.include?(user.role)
496
+ # end
497
+ #
498
+ # # good
499
+ # ADMIN_ROLES = %i[superadmin admin]
500
+ # ...
501
+ # users.select do |user|
502
+ # ADMIN_ROLES.include?(user.role)
503
+ # end
504
+ #
505
+ # source://rubocop-performance//lib/rubocop/cop/performance/collection_literal_in_loop.rb#34
506
+ class RuboCop::Cop::Performance::CollectionLiteralInLoop < ::RuboCop::Cop::Base
507
+ # source://rubocop-performance//lib/rubocop/cop/performance/collection_literal_in_loop.rb#74
508
+ def enumerable_loop?(param0 = T.unsafe(nil)); end
509
+
510
+ # source://rubocop-performance//lib/rubocop/cop/performance/collection_literal_in_loop.rb#68
511
+ def kernel_loop?(param0 = T.unsafe(nil)); end
512
+
513
+ # source://rubocop-performance//lib/rubocop/cop/performance/collection_literal_in_loop.rb#80
514
+ def on_send(node); end
515
+
516
+ private
517
+
518
+ # @return [Boolean]
519
+ #
520
+ # source://rubocop-performance//lib/rubocop/cop/performance/collection_literal_in_loop.rb#90
521
+ def check_literal?(node, method); end
522
+
523
+ # @return [Boolean]
524
+ #
525
+ # source://rubocop-performance//lib/rubocop/cop/performance/collection_literal_in_loop.rb#128
526
+ def enumerable_method?(method_name); end
527
+
528
+ # @return [Boolean]
529
+ #
530
+ # source://rubocop-performance//lib/rubocop/cop/performance/collection_literal_in_loop.rb#110
531
+ def keyword_loop?(type); end
532
+
533
+ # source://rubocop-performance//lib/rubocop/cop/performance/collection_literal_in_loop.rb#120
534
+ def literal_class(node); end
535
+
536
+ # @return [Boolean]
537
+ #
538
+ # source://rubocop-performance//lib/rubocop/cop/performance/collection_literal_in_loop.rb#106
539
+ def loop?(ancestor, node); end
540
+
541
+ # source://rubocop-performance//lib/rubocop/cop/performance/collection_literal_in_loop.rb#132
542
+ def min_size; end
543
+
544
+ # @return [Boolean]
545
+ #
546
+ # source://rubocop-performance//lib/rubocop/cop/performance/collection_literal_in_loop.rb#114
547
+ def node_within_enumerable_loop?(node, ancestor); end
548
+
549
+ # @return [Boolean]
550
+ #
551
+ # source://rubocop-performance//lib/rubocop/cop/performance/collection_literal_in_loop.rb#97
552
+ def nonmutable_method_of_array_or_hash?(node, method); end
553
+
554
+ # @return [Boolean]
555
+ #
556
+ # source://rubocop-performance//lib/rubocop/cop/performance/collection_literal_in_loop.rb#102
557
+ def parent_is_loop?(node); end
558
+ end
559
+
560
+ # source://rubocop-performance//lib/rubocop/cop/performance/collection_literal_in_loop.rb#56
561
+ RuboCop::Cop::Performance::CollectionLiteralInLoop::ARRAY_METHODS = T.let(T.unsafe(nil), Set)
562
+
563
+ # source://rubocop-performance//lib/rubocop/cop/performance/collection_literal_in_loop.rb#41
564
+ RuboCop::Cop::Performance::CollectionLiteralInLoop::ENUMERABLE_METHOD_NAMES = T.let(T.unsafe(nil), Set)
565
+
566
+ # source://rubocop-performance//lib/rubocop/cop/performance/collection_literal_in_loop.rb#66
567
+ RuboCop::Cop::Performance::CollectionLiteralInLoop::HASH_METHODS = T.let(T.unsafe(nil), Set)
568
+
569
+ # source://rubocop-performance//lib/rubocop/cop/performance/collection_literal_in_loop.rb#39
570
+ RuboCop::Cop::Performance::CollectionLiteralInLoop::LOOP_TYPES = T.let(T.unsafe(nil), Array)
571
+
572
+ # source://rubocop-performance//lib/rubocop/cop/performance/collection_literal_in_loop.rb#35
573
+ RuboCop::Cop::Performance::CollectionLiteralInLoop::MSG = T.let(T.unsafe(nil), String)
574
+
575
+ # source://rubocop-performance//lib/rubocop/cop/performance/collection_literal_in_loop.rb#42
576
+ RuboCop::Cop::Performance::CollectionLiteralInLoop::NONMUTATING_ARRAY_METHODS = T.let(T.unsafe(nil), Array)
577
+
578
+ # source://rubocop-performance//lib/rubocop/cop/performance/collection_literal_in_loop.rb#58
579
+ RuboCop::Cop::Performance::CollectionLiteralInLoop::NONMUTATING_HASH_METHODS = T.let(T.unsafe(nil), Array)
580
+
581
+ # source://rubocop-performance//lib/rubocop/cop/performance/collection_literal_in_loop.rb#38
582
+ RuboCop::Cop::Performance::CollectionLiteralInLoop::POST_CONDITION_LOOP_TYPES = T.let(T.unsafe(nil), Array)
583
+
584
+ # Identifies places where `sort { |a, b| a.foo <=> b.foo }`
585
+ # can be replaced by `sort_by(&:foo)`.
586
+ # This cop also checks `sort!`, `min`, `max` and `minmax` methods.
587
+ #
588
+ # @example
589
+ # # bad
590
+ # array.sort { |a, b| a.foo <=> b.foo }
591
+ # array.sort! { |a, b| a.foo <=> b.foo }
592
+ # array.max { |a, b| a.foo <=> b.foo }
593
+ # array.min { |a, b| a.foo <=> b.foo }
594
+ # array.minmax { |a, b| a.foo <=> b.foo }
595
+ # array.sort { |a, b| a[:foo] <=> b[:foo] }
596
+ #
597
+ # # good
598
+ # array.sort_by(&:foo)
599
+ # array.sort_by!(&:foo)
600
+ # array.sort_by { |v| v.foo }
601
+ # array.sort_by do |var|
602
+ # var.foo
603
+ # end
604
+ # array.max_by(&:foo)
605
+ # array.min_by(&:foo)
606
+ # array.minmax_by(&:foo)
607
+ # array.sort_by { |a| a[:foo] }
608
+ #
609
+ # source://rubocop-performance//lib/rubocop/cop/performance/compare_with_block.rb#30
610
+ class RuboCop::Cop::Performance::CompareWithBlock < ::RuboCop::Cop::Base
611
+ include ::RuboCop::Cop::RangeHelp
612
+ extend ::RuboCop::Cop::AutoCorrector
613
+
614
+ # source://rubocop-performance//lib/rubocop/cop/performance/compare_with_block.rb#41
615
+ def compare?(param0 = T.unsafe(nil)); end
616
+
617
+ # source://rubocop-performance//lib/rubocop/cop/performance/compare_with_block.rb#55
618
+ def on_block(node); end
619
+
620
+ # source://rubocop-performance//lib/rubocop/cop/performance/compare_with_block.rb#48
621
+ def replaceable_body?(param0 = T.unsafe(nil), param1, param2); end
622
+
623
+ private
624
+
625
+ # source://rubocop-performance//lib/rubocop/cop/performance/compare_with_block.rb#114
626
+ def compare_range(send, node); end
627
+
628
+ # source://rubocop-performance//lib/rubocop/cop/performance/compare_with_block.rb#91
629
+ def message(send, method, var_a, var_b, args); end
630
+
631
+ # @return [Boolean]
632
+ #
633
+ # source://rubocop-performance//lib/rubocop/cop/performance/compare_with_block.rb#76
634
+ def slow_compare?(method, args_a, args_b); end
635
+ end
636
+
637
+ # source://rubocop-performance//lib/rubocop/cop/performance/compare_with_block.rb#34
638
+ RuboCop::Cop::Performance::CompareWithBlock::MSG = T.let(T.unsafe(nil), String)
639
+
640
+ # source://rubocop-performance//lib/rubocop/cop/performance/compare_with_block.rb#38
641
+ RuboCop::Cop::Performance::CompareWithBlock::REPLACEMENT = T.let(T.unsafe(nil), Hash)
642
+
643
+ # Identifies places where `Concurrent.monotonic_time`
644
+ # can be replaced by `Process.clock_gettime(Process::CLOCK_MONOTONIC)`.
645
+ #
646
+ # @example
647
+ #
648
+ # # bad
649
+ # Concurrent.monotonic_time
650
+ #
651
+ # # good
652
+ # Process.clock_gettime(Process::CLOCK_MONOTONIC)
653
+ #
654
+ # source://rubocop-performance//lib/rubocop/cop/performance/concurrent_monotonic_time.rb#17
655
+ class RuboCop::Cop::Performance::ConcurrentMonotonicTime < ::RuboCop::Cop::Base
656
+ extend ::RuboCop::Cop::AutoCorrector
657
+
658
+ # source://rubocop-performance//lib/rubocop/cop/performance/concurrent_monotonic_time.rb#23
659
+ def concurrent_monotonic_time?(param0 = T.unsafe(nil)); end
660
+
661
+ # source://rubocop-performance//lib/rubocop/cop/performance/concurrent_monotonic_time.rb#28
662
+ def on_send(node); end
663
+ end
664
+
665
+ # source://rubocop-performance//lib/rubocop/cop/performance/concurrent_monotonic_time.rb#20
666
+ RuboCop::Cop::Performance::ConcurrentMonotonicTime::MSG = T.let(T.unsafe(nil), String)
667
+
668
+ # source://rubocop-performance//lib/rubocop/cop/performance/concurrent_monotonic_time.rb#21
669
+ RuboCop::Cop::Performance::ConcurrentMonotonicTime::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
670
+
671
+ # Finds regular expressions with dynamic components that are all constants.
672
+ #
673
+ # Ruby allocates a new Regexp object every time it executes a code containing such
674
+ # a regular expression. It is more efficient to extract it into a constant,
675
+ # memoize it, or add an `/o` option to perform `#{}` interpolation only once and
676
+ # reuse that Regexp object.
677
+ #
678
+ # @example
679
+ #
680
+ # # bad
681
+ # def tokens(pattern)
682
+ # pattern.scan(TOKEN).reject { |token| token.match?(/\A#{SEPARATORS}\Z/) }
683
+ # end
684
+ #
685
+ # # good
686
+ # ALL_SEPARATORS = /\A#{SEPARATORS}\Z/
687
+ # def tokens(pattern)
688
+ # pattern.scan(TOKEN).reject { |token| token.match?(ALL_SEPARATORS) }
689
+ # end
690
+ #
691
+ # # good
692
+ # def tokens(pattern)
693
+ # pattern.scan(TOKEN).reject { |token| token.match?(/\A#{SEPARATORS}\Z/o) }
694
+ # end
695
+ #
696
+ # # good
697
+ # def separators
698
+ # @separators ||= /\A#{SEPARATORS}\Z/
699
+ # end
700
+ #
701
+ # source://rubocop-performance//lib/rubocop/cop/performance/constant_regexp.rb#36
702
+ class RuboCop::Cop::Performance::ConstantRegexp < ::RuboCop::Cop::Base
703
+ extend ::RuboCop::Cop::AutoCorrector
704
+
705
+ # source://rubocop-performance//lib/rubocop/cop/performance/constant_regexp.rb#45
706
+ def on_regexp(node); end
707
+
708
+ # source://rubocop-performance//lib/rubocop/cop/performance/constant_regexp.rb#59
709
+ def regexp_escape?(param0 = T.unsafe(nil)); end
710
+
711
+ private
712
+
713
+ # @return [Boolean]
714
+ #
715
+ # source://rubocop-performance//lib/rubocop/cop/performance/constant_regexp.rb#64
716
+ def include_interpolated_const?(node); end
717
+
718
+ # @return [Boolean]
719
+ #
720
+ # source://rubocop-performance//lib/rubocop/cop/performance/constant_regexp.rb#55
721
+ def within_allowed_assignment?(node); end
722
+
723
+ class << self
724
+ # source://rubocop-performance//lib/rubocop/cop/performance/constant_regexp.rb#41
725
+ def autocorrect_incompatible_with; end
726
+ end
727
+ end
728
+
729
+ # source://rubocop-performance//lib/rubocop/cop/performance/constant_regexp.rb#39
730
+ RuboCop::Cop::Performance::ConstantRegexp::MSG = T.let(T.unsafe(nil), String)
731
+
732
+ # Identifies usages of `count` on an `Enumerable` that
733
+ # follow calls to `select`, `find_all`, `filter` or `reject`. Querying logic can instead be
734
+ # passed to the `count` call.
735
+ #
736
+ # @example
737
+ # # bad
738
+ # [1, 2, 3].select { |e| e > 2 }.size
739
+ # [1, 2, 3].reject { |e| e > 2 }.size
740
+ # [1, 2, 3].select { |e| e > 2 }.length
741
+ # [1, 2, 3].reject { |e| e > 2 }.length
742
+ # [1, 2, 3].select { |e| e > 2 }.count { |e| e.odd? }
743
+ # [1, 2, 3].reject { |e| e > 2 }.count { |e| e.even? }
744
+ # array.select(&:value).count
745
+ #
746
+ # # good
747
+ # [1, 2, 3].count { |e| e > 2 }
748
+ # [1, 2, 3].count { |e| e < 2 }
749
+ # [1, 2, 3].count { |e| e > 2 && e.odd? }
750
+ # [1, 2, 3].count { |e| e < 2 && e.even? }
751
+ # Model.select('field AS field_one').count
752
+ # Model.select(:value).count
753
+ #
754
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#49
755
+ class RuboCop::Cop::Performance::Count < ::RuboCop::Cop::Base
756
+ include ::RuboCop::Cop::RangeHelp
757
+ extend ::RuboCop::Cop::AutoCorrector
758
+
759
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#56
760
+ def count_candidate?(param0 = T.unsafe(nil)); end
761
+
762
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#63
763
+ def on_send(node); end
764
+
765
+ private
766
+
767
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#79
768
+ def autocorrect(corrector, node, selector_node, selector); end
769
+
770
+ # @return [Boolean]
771
+ #
772
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#89
773
+ def eligible_node?(node); end
774
+
775
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#132
776
+ def negate_block_pass_as_inline_block(node); end
777
+
778
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#111
779
+ def negate_block_pass_reject(corrector, node); end
780
+
781
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#118
782
+ def negate_block_reject(corrector, node); end
783
+
784
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#128
785
+ def negate_expression(node); end
786
+
787
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#103
788
+ def negate_reject(corrector, node); end
789
+
790
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#93
791
+ def source_starting_at(node); end
792
+ end
793
+
794
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#53
795
+ RuboCop::Cop::Performance::Count::MSG = T.let(T.unsafe(nil), String)
796
+
797
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#54
798
+ RuboCop::Cop::Performance::Count::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
799
+
800
+ # In Ruby 2.5, `String#delete_prefix` has been added.
801
+ #
802
+ # This cop identifies places where `gsub(/\Aprefix/, '')` and `sub(/\Aprefix/, '')`
803
+ # can be replaced by `delete_prefix('prefix')`.
804
+ #
805
+ # This cop has `SafeMultiline` configuration option that `true` by default because
806
+ # `^prefix` is unsafe as it will behave incompatible with `delete_prefix`
807
+ # for receiver is multiline string.
808
+ #
809
+ # The `delete_prefix('prefix')` method is faster than `gsub(/\Aprefix/, '')`.
810
+ #
811
+ # @example
812
+ #
813
+ # # bad
814
+ # str.gsub(/\Aprefix/, '')
815
+ # str.gsub!(/\Aprefix/, '')
816
+ #
817
+ # str.sub(/\Aprefix/, '')
818
+ # str.sub!(/\Aprefix/, '')
819
+ #
820
+ # # good
821
+ # str.delete_prefix('prefix')
822
+ # str.delete_prefix!('prefix')
823
+ # @example SafeMultiline: true (default)
824
+ #
825
+ # # good
826
+ # str.gsub(/^prefix/, '')
827
+ # str.gsub!(/^prefix/, '')
828
+ # str.sub(/^prefix/, '')
829
+ # str.sub!(/^prefix/, '')
830
+ # @example SafeMultiline: false
831
+ #
832
+ # # bad
833
+ # str.gsub(/^prefix/, '')
834
+ # str.gsub!(/^prefix/, '')
835
+ # str.sub(/^prefix/, '')
836
+ # str.sub!(/^prefix/, '')
837
+ #
838
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_prefix.rb#49
839
+ class RuboCop::Cop::Performance::DeletePrefix < ::RuboCop::Cop::Base
840
+ include ::RuboCop::Cop::RegexpMetacharacter
841
+ extend ::RuboCop::Cop::AutoCorrector
842
+ extend ::RuboCop::Cop::TargetRubyVersion
843
+
844
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_prefix.rb#66
845
+ def delete_prefix_candidate?(param0 = T.unsafe(nil)); end
846
+
847
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_prefix.rb#71
848
+ def on_csend(node); end
849
+
850
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_prefix.rb#71
851
+ def on_send(node); end
852
+ end
853
+
854
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_prefix.rb#56
855
+ RuboCop::Cop::Performance::DeletePrefix::MSG = T.let(T.unsafe(nil), String)
856
+
857
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_prefix.rb#59
858
+ RuboCop::Cop::Performance::DeletePrefix::PREFERRED_METHODS = T.let(T.unsafe(nil), Hash)
859
+
860
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_prefix.rb#57
861
+ RuboCop::Cop::Performance::DeletePrefix::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
862
+
863
+ # In Ruby 2.5, `String#delete_suffix` has been added.
864
+ #
865
+ # This cop identifies places where `gsub(/suffix\z/, '')` and `sub(/suffix\z/, '')`
866
+ # can be replaced by `delete_suffix('suffix')`.
867
+ #
868
+ # This cop has `SafeMultiline` configuration option that `true` by default because
869
+ # `suffix$` is unsafe as it will behave incompatible with `delete_suffix?`
870
+ # for receiver is multiline string.
871
+ #
872
+ # The `delete_suffix('suffix')` method is faster than `gsub(/suffix\z/, '')`.
873
+ #
874
+ # @example
875
+ #
876
+ # # bad
877
+ # str.gsub(/suffix\z/, '')
878
+ # str.gsub!(/suffix\z/, '')
879
+ #
880
+ # str.sub(/suffix\z/, '')
881
+ # str.sub!(/suffix\z/, '')
882
+ #
883
+ # # good
884
+ # str.delete_suffix('suffix')
885
+ # str.delete_suffix!('suffix')
886
+ # @example SafeMultiline: true (default)
887
+ #
888
+ # # good
889
+ # str.gsub(/suffix$/, '')
890
+ # str.gsub!(/suffix$/, '')
891
+ # str.sub(/suffix$/, '')
892
+ # str.sub!(/suffix$/, '')
893
+ # @example SafeMultiline: false
894
+ #
895
+ # # bad
896
+ # str.gsub(/suffix$/, '')
897
+ # str.gsub!(/suffix$/, '')
898
+ # str.sub(/suffix$/, '')
899
+ # str.sub!(/suffix$/, '')
900
+ #
901
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_suffix.rb#49
902
+ class RuboCop::Cop::Performance::DeleteSuffix < ::RuboCop::Cop::Base
903
+ include ::RuboCop::Cop::RegexpMetacharacter
904
+ extend ::RuboCop::Cop::AutoCorrector
905
+ extend ::RuboCop::Cop::TargetRubyVersion
906
+
907
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_suffix.rb#66
908
+ def delete_suffix_candidate?(param0 = T.unsafe(nil)); end
909
+
910
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_suffix.rb#71
911
+ def on_csend(node); end
912
+
913
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_suffix.rb#71
914
+ def on_send(node); end
915
+ end
916
+
917
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_suffix.rb#56
918
+ RuboCop::Cop::Performance::DeleteSuffix::MSG = T.let(T.unsafe(nil), String)
919
+
920
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_suffix.rb#59
921
+ RuboCop::Cop::Performance::DeleteSuffix::PREFERRED_METHODS = T.let(T.unsafe(nil), Hash)
922
+
923
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_suffix.rb#57
924
+ RuboCop::Cop::Performance::DeleteSuffix::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
925
+
926
+ # Identifies usages of `first`, `last`, `[0]` or `[-1]`
927
+ # chained to `select`, `find_all` or `filter` and change them to use
928
+ # `detect` instead.
929
+ #
930
+ # @example
931
+ # # bad
932
+ # [].select { |item| true }.first
933
+ # [].select { |item| true }.last
934
+ # [].find_all { |item| true }.first
935
+ # [].find_all { |item| true }.last
936
+ # [].filter { |item| true }.first
937
+ # [].filter { |item| true }.last
938
+ # [].filter { |item| true }[0]
939
+ # [].filter { |item| true }[-1]
940
+ #
941
+ # # good
942
+ # [].detect { |item| true }
943
+ # [].reverse.detect { |item| true }
944
+ #
945
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#30
946
+ class RuboCop::Cop::Performance::Detect < ::RuboCop::Cop::Base
947
+ extend ::RuboCop::Cop::AutoCorrector
948
+
949
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#41
950
+ def detect_candidate?(param0 = T.unsafe(nil)); end
951
+
952
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#50
953
+ def on_csend(node); end
954
+
955
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#50
956
+ def on_send(node); end
957
+
958
+ private
959
+
960
+ # @return [Boolean]
961
+ #
962
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#70
963
+ def accept_first_call?(receiver, body); end
964
+
965
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#102
966
+ def autocorrect(corrector, node, replacement); end
967
+
968
+ # @return [Boolean]
969
+ #
970
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#128
971
+ def lazy?(node); end
972
+
973
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#113
974
+ def message_for_method(method, index); end
975
+
976
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#124
977
+ def preferred_method; end
978
+
979
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#79
980
+ def register_offense(node, receiver, second_method, index); end
981
+
982
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#94
983
+ def replacement(method, index); end
984
+ end
985
+
986
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#33
987
+ RuboCop::Cop::Performance::Detect::CANDIDATE_METHODS = T.let(T.unsafe(nil), Set)
988
+
989
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#37
990
+ RuboCop::Cop::Performance::Detect::INDEX_MSG = T.let(T.unsafe(nil), String)
991
+
992
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#38
993
+ RuboCop::Cop::Performance::Detect::INDEX_REVERSE_MSG = T.let(T.unsafe(nil), String)
994
+
995
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#35
996
+ RuboCop::Cop::Performance::Detect::MSG = T.let(T.unsafe(nil), String)
997
+
998
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#39
999
+ RuboCop::Cop::Performance::Detect::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1000
+
1001
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#36
1002
+ RuboCop::Cop::Performance::Detect::REVERSE_MSG = T.let(T.unsafe(nil), String)
1003
+
1004
+ # Checks for double `#start_with?` or `#end_with?` calls
1005
+ # separated by `||`. In some cases such calls can be replaced
1006
+ # with an single `#start_with?`/`#end_with?` call.
1007
+ #
1008
+ # `IncludeActiveSupportAliases` configuration option is used to check for
1009
+ # `starts_with?` and `ends_with?`. These methods are defined by Active Support.
1010
+ #
1011
+ # @example
1012
+ # # bad
1013
+ # str.start_with?("a") || str.start_with?(Some::CONST)
1014
+ # str.start_with?("a", "b") || str.start_with?("c")
1015
+ # str.end_with?(var1) || str.end_with?(var2)
1016
+ #
1017
+ # # good
1018
+ # str.start_with?("a", Some::CONST)
1019
+ # str.start_with?("a", "b", "c")
1020
+ # str.end_with?(var1, var2)
1021
+ # @example IncludeActiveSupportAliases: false (default)
1022
+ # # good
1023
+ # str.starts_with?("a", "b") || str.starts_with?("c")
1024
+ # str.ends_with?(var1) || str.ends_with?(var2)
1025
+ #
1026
+ # str.starts_with?("a", "b", "c")
1027
+ # str.ends_with?(var1, var2)
1028
+ # @example IncludeActiveSupportAliases: true
1029
+ # # bad
1030
+ # str.starts_with?("a", "b") || str.starts_with?("c")
1031
+ # str.ends_with?(var1) || str.ends_with?(var2)
1032
+ #
1033
+ # # good
1034
+ # str.starts_with?("a", "b", "c")
1035
+ # str.ends_with?(var1, var2)
1036
+ #
1037
+ # source://rubocop-performance//lib/rubocop/cop/performance/double_start_end_with.rb#41
1038
+ class RuboCop::Cop::Performance::DoubleStartEndWith < ::RuboCop::Cop::Base
1039
+ extend ::RuboCop::Cop::AutoCorrector
1040
+
1041
+ # source://rubocop-performance//lib/rubocop/cop/performance/double_start_end_with.rb#96
1042
+ def check_with_active_support_aliases(param0 = T.unsafe(nil)); end
1043
+
1044
+ # source://rubocop-performance//lib/rubocop/cop/performance/double_start_end_with.rb#46
1045
+ def on_or(node); end
1046
+
1047
+ # source://rubocop-performance//lib/rubocop/cop/performance/double_start_end_with.rb#90
1048
+ def two_start_end_with_calls(param0 = T.unsafe(nil)); end
1049
+
1050
+ private
1051
+
1052
+ # source://rubocop-performance//lib/rubocop/cop/performance/double_start_end_with.rb#60
1053
+ def autocorrect(corrector, first_call_args, second_call_args, combined_args); end
1054
+
1055
+ # @return [Boolean]
1056
+ #
1057
+ # source://rubocop-performance//lib/rubocop/cop/performance/double_start_end_with.rb#86
1058
+ def check_for_active_support_aliases?; end
1059
+
1060
+ # source://rubocop-performance//lib/rubocop/cop/performance/double_start_end_with.rb#82
1061
+ def combine_args(first_call_args, second_call_args); end
1062
+
1063
+ # source://rubocop-performance//lib/rubocop/cop/performance/double_start_end_with.rb#76
1064
+ def message(node, receiver, method, combined_args); end
1065
+
1066
+ # source://rubocop-performance//lib/rubocop/cop/performance/double_start_end_with.rb#68
1067
+ def process_source(node); end
1068
+ end
1069
+
1070
+ # source://rubocop-performance//lib/rubocop/cop/performance/double_start_end_with.rb#44
1071
+ RuboCop::Cop::Performance::DoubleStartEndWith::MSG = T.let(T.unsafe(nil), String)
1072
+
1073
+ # Identifies unnecessary use of a regex where `String#end_with?` would suffice.
1074
+ #
1075
+ # This cop has `SafeMultiline` configuration option that `true` by default because
1076
+ # `end$` is unsafe as it will behave incompatible with `end_with?`
1077
+ # for receiver is multiline string.
1078
+ #
1079
+ # @example
1080
+ # # bad
1081
+ # 'abc'.match?(/bc\Z/)
1082
+ # /bc\Z/.match?('abc')
1083
+ # 'abc' =~ /bc\Z/
1084
+ # /bc\Z/ =~ 'abc'
1085
+ # 'abc'.match(/bc\Z/)
1086
+ # /bc\Z/.match('abc')
1087
+ #
1088
+ # # good
1089
+ # 'abc'.end_with?('bc')
1090
+ # @example SafeMultiline: true (default)
1091
+ #
1092
+ # # good
1093
+ # 'abc'.match?(/bc$/)
1094
+ # /bc$/.match?('abc')
1095
+ # 'abc' =~ /bc$/
1096
+ # /bc$/ =~ 'abc'
1097
+ # 'abc'.match(/bc$/)
1098
+ # /bc$/.match('abc')
1099
+ # @example SafeMultiline: false
1100
+ #
1101
+ # # bad
1102
+ # 'abc'.match?(/bc$/)
1103
+ # /bc$/.match?('abc')
1104
+ # 'abc' =~ /bc$/
1105
+ # /bc$/ =~ 'abc'
1106
+ # 'abc'.match(/bc$/)
1107
+ # /bc$/.match('abc')
1108
+ #
1109
+ # source://rubocop-performance//lib/rubocop/cop/performance/end_with.rb#49
1110
+ class RuboCop::Cop::Performance::EndWith < ::RuboCop::Cop::Base
1111
+ include ::RuboCop::Cop::RegexpMetacharacter
1112
+ extend ::RuboCop::Cop::AutoCorrector
1113
+
1114
+ # source://rubocop-performance//lib/rubocop/cop/performance/end_with.rb#62
1115
+ def on_csend(node); end
1116
+
1117
+ # source://rubocop-performance//lib/rubocop/cop/performance/end_with.rb#62
1118
+ def on_match_with_lvasgn(node); end
1119
+
1120
+ # source://rubocop-performance//lib/rubocop/cop/performance/end_with.rb#62
1121
+ def on_send(node); end
1122
+
1123
+ # source://rubocop-performance//lib/rubocop/cop/performance/end_with.rb#56
1124
+ def redundant_regex?(param0 = T.unsafe(nil)); end
1125
+ end
1126
+
1127
+ # source://rubocop-performance//lib/rubocop/cop/performance/end_with.rb#53
1128
+ RuboCop::Cop::Performance::EndWith::MSG = T.let(T.unsafe(nil), String)
1129
+
1130
+ # source://rubocop-performance//lib/rubocop/cop/performance/end_with.rb#54
1131
+ RuboCop::Cop::Performance::EndWith::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1132
+
1133
+ # Do not compute the size of statically sized objects.
1134
+ #
1135
+ # @example
1136
+ # # String methods
1137
+ # # bad
1138
+ # 'foo'.size
1139
+ # %q[bar].count
1140
+ # %(qux).length
1141
+ #
1142
+ # # Symbol methods
1143
+ # # bad
1144
+ # :fred.size
1145
+ # :'baz'.length
1146
+ #
1147
+ # # Array methods
1148
+ # # bad
1149
+ # [1, 2, thud].count
1150
+ # %W(1, 2, bar).size
1151
+ #
1152
+ # # Hash methods
1153
+ # # bad
1154
+ # { a: corge, b: grault }.length
1155
+ #
1156
+ # # good
1157
+ # foo.size
1158
+ # bar.count
1159
+ # qux.length
1160
+ #
1161
+ # # good
1162
+ # :"#{fred}".size
1163
+ # CONST = :baz.length
1164
+ #
1165
+ # # good
1166
+ # [1, 2, *thud].count
1167
+ # garply = [1, 2, 3]
1168
+ # garply.size
1169
+ #
1170
+ # # good
1171
+ # { a: corge, **grault }.length
1172
+ # waldo = { a: corge, b: grault }
1173
+ # waldo.size
1174
+ #
1175
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#48
1176
+ class RuboCop::Cop::Performance::FixedSize < ::RuboCop::Cop::Base
1177
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#52
1178
+ def counter(param0 = T.unsafe(nil)); end
1179
+
1180
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#56
1181
+ def on_send(node); end
1182
+
1183
+ private
1184
+
1185
+ # @return [Boolean]
1186
+ #
1187
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#72
1188
+ def allowed_argument?(arg); end
1189
+
1190
+ # @return [Boolean]
1191
+ #
1192
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#76
1193
+ def allowed_parent?(node); end
1194
+
1195
+ # @return [Boolean]
1196
+ #
1197
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#68
1198
+ def allowed_variable?(var); end
1199
+
1200
+ # @return [Boolean]
1201
+ #
1202
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#86
1203
+ def contains_double_splat?(node); end
1204
+
1205
+ # @return [Boolean]
1206
+ #
1207
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#80
1208
+ def contains_splat?(node); end
1209
+
1210
+ # @return [Boolean]
1211
+ #
1212
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#92
1213
+ def non_string_argument?(node); end
1214
+ end
1215
+
1216
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#49
1217
+ RuboCop::Cop::Performance::FixedSize::MSG = T.let(T.unsafe(nil), String)
1218
+
1219
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#50
1220
+ RuboCop::Cop::Performance::FixedSize::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1221
+
1222
+ # Identifies usages of `map { ... }.flatten` and
1223
+ # change them to use `flat_map { ... }` instead.
1224
+ #
1225
+ # @example
1226
+ # # bad
1227
+ # [1, 2, 3, 4].map { |e| [e, e] }.flatten(1)
1228
+ # [1, 2, 3, 4].collect { |e| [e, e] }.flatten(1)
1229
+ #
1230
+ # # good
1231
+ # [1, 2, 3, 4].flat_map { |e| [e, e] }
1232
+ # [1, 2, 3, 4].map { |e| [e, e] }.flatten
1233
+ # [1, 2, 3, 4].collect { |e| [e, e] }.flatten
1234
+ #
1235
+ # source://rubocop-performance//lib/rubocop/cop/performance/flat_map.rb#18
1236
+ class RuboCop::Cop::Performance::FlatMap < ::RuboCop::Cop::Base
1237
+ include ::RuboCop::Cop::RangeHelp
1238
+ extend ::RuboCop::Cop::AutoCorrector
1239
+
1240
+ # source://rubocop-performance//lib/rubocop/cop/performance/flat_map.rb#28
1241
+ def flat_map_candidate?(param0 = T.unsafe(nil)); end
1242
+
1243
+ # source://rubocop-performance//lib/rubocop/cop/performance/flat_map.rb#39
1244
+ def on_send(node); end
1245
+
1246
+ private
1247
+
1248
+ # source://rubocop-performance//lib/rubocop/cop/performance/flat_map.rb#72
1249
+ def autocorrect(corrector, node); end
1250
+
1251
+ # source://rubocop-performance//lib/rubocop/cop/performance/flat_map.rb#52
1252
+ def offense_for_levels(node, map_node, first_method, flatten); end
1253
+
1254
+ # source://rubocop-performance//lib/rubocop/cop/performance/flat_map.rb#58
1255
+ def offense_for_method(node, map_node, first_method, flatten); end
1256
+
1257
+ # source://rubocop-performance//lib/rubocop/cop/performance/flat_map.rb#62
1258
+ def register_offense(node, map_node, first_method, flatten, message); end
1259
+ end
1260
+
1261
+ # source://rubocop-performance//lib/rubocop/cop/performance/flat_map.rb#24
1262
+ RuboCop::Cop::Performance::FlatMap::FLATTEN_MULTIPLE_LEVELS = T.let(T.unsafe(nil), String)
1263
+
1264
+ # source://rubocop-performance//lib/rubocop/cop/performance/flat_map.rb#22
1265
+ RuboCop::Cop::Performance::FlatMap::MSG = T.let(T.unsafe(nil), String)
1266
+
1267
+ # source://rubocop-performance//lib/rubocop/cop/performance/flat_map.rb#23
1268
+ RuboCop::Cop::Performance::FlatMap::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1269
+
1270
+ # Checks for inefficient searching of keys and values within
1271
+ # hashes.
1272
+ #
1273
+ # `Hash#keys.include?` is less efficient than `Hash#key?` because
1274
+ # the former allocates a new array and then performs an O(n) search
1275
+ # through that array, while `Hash#key?` does not allocate any array and
1276
+ # performs a faster O(1) search for the key.
1277
+ #
1278
+ # `Hash#values.include?` is less efficient than `Hash#value?`. While they
1279
+ # both perform an O(n) search through all of the values, calling `values`
1280
+ # allocates a new array while using `value?` does not.
1281
+ #
1282
+ # @example
1283
+ # # bad
1284
+ # { a: 1, b: 2 }.keys.include?(:a)
1285
+ # { a: 1, b: 2 }.keys.include?(:z)
1286
+ # h = { a: 1, b: 2 }; h.keys.include?(100)
1287
+ #
1288
+ # # good
1289
+ # { a: 1, b: 2 }.key?(:a)
1290
+ # { a: 1, b: 2 }.has_key?(:z)
1291
+ # h = { a: 1, b: 2 }; h.key?(100)
1292
+ #
1293
+ # # bad
1294
+ # { a: 1, b: 2 }.values.include?(2)
1295
+ # { a: 1, b: 2 }.values.include?('garbage')
1296
+ # h = { a: 1, b: 2 }; h.values.include?(nil)
1297
+ #
1298
+ # # good
1299
+ # { a: 1, b: 2 }.value?(2)
1300
+ # { a: 1, b: 2 }.has_value?('garbage')
1301
+ # h = { a: 1, b: 2 }; h.value?(nil)
1302
+ #
1303
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#42
1304
+ class RuboCop::Cop::Performance::InefficientHashSearch < ::RuboCop::Cop::Base
1305
+ extend ::RuboCop::Cop::AutoCorrector
1306
+
1307
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#47
1308
+ def inefficient_include?(param0 = T.unsafe(nil)); end
1309
+
1310
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#51
1311
+ def on_csend(node); end
1312
+
1313
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#51
1314
+ def on_send(node); end
1315
+
1316
+ private
1317
+
1318
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#91
1319
+ def correct_argument(node); end
1320
+
1321
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#99
1322
+ def correct_dot(node); end
1323
+
1324
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#95
1325
+ def correct_hash_expression(node); end
1326
+
1327
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#75
1328
+ def correct_method(node); end
1329
+
1330
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#82
1331
+ def current_method(node); end
1332
+
1333
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#67
1334
+ def message(node); end
1335
+
1336
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#71
1337
+ def replacement(node); end
1338
+
1339
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#86
1340
+ def use_long_method; end
1341
+ end
1342
+
1343
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#45
1344
+ RuboCop::Cop::Performance::InefficientHashSearch::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1345
+
1346
+ # Identifies places where inefficient `readlines` method
1347
+ # can be replaced by `each_line` to avoid fully loading file content into memory.
1348
+ #
1349
+ # @example
1350
+ #
1351
+ # # bad
1352
+ # File.readlines('testfile').each { |l| puts l }
1353
+ # IO.readlines('testfile', chomp: true).each { |l| puts l }
1354
+ #
1355
+ # conn.readlines(10).map { |l| l.size }
1356
+ # file.readlines.find { |l| l.start_with?('#') }
1357
+ # file.readlines.each { |l| puts l }
1358
+ #
1359
+ # # good
1360
+ # File.open('testfile', 'r').each_line { |l| puts l }
1361
+ # IO.open('testfile').each_line(chomp: true) { |l| puts l }
1362
+ #
1363
+ # conn.each_line(10).map { |l| l.size }
1364
+ # file.each_line.find { |l| l.start_with?('#') }
1365
+ # file.each_line { |l| puts l }
1366
+ #
1367
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#27
1368
+ class RuboCop::Cop::Performance::IoReadlines < ::RuboCop::Cop::Base
1369
+ include ::RuboCop::Cop::RangeHelp
1370
+ extend ::RuboCop::Cop::AutoCorrector
1371
+
1372
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#42
1373
+ def on_send(node); end
1374
+
1375
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#34
1376
+ def readlines_on_class?(param0 = T.unsafe(nil)); end
1377
+
1378
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#38
1379
+ def readlines_on_instance?(param0 = T.unsafe(nil)); end
1380
+
1381
+ private
1382
+
1383
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#58
1384
+ def autocorrect(corrector, enumerable_call, readlines_call, receiver); end
1385
+
1386
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#90
1387
+ def build_bad_method(enumerable_call); end
1388
+
1389
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#106
1390
+ def build_call_args(call_args_node); end
1391
+
1392
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#82
1393
+ def build_good_method(enumerable_call); end
1394
+
1395
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#94
1396
+ def correction_range(enumerable_call, readlines_call); end
1397
+
1398
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#76
1399
+ def offense_range(enumerable_call, readlines_call); end
1400
+ end
1401
+
1402
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#31
1403
+ RuboCop::Cop::Performance::IoReadlines::MSG = T.let(T.unsafe(nil), String)
1404
+
1405
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#32
1406
+ RuboCop::Cop::Performance::IoReadlines::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1407
+
1408
+ # In Ruby 2.7, `Enumerable#filter_map` has been added.
1409
+ #
1410
+ # This cop identifies places where `map { ... }.compact` can be replaced by `filter_map`.
1411
+ #
1412
+ # [source,ruby]
1413
+ # ----
1414
+ # [true, false, nil].compact #=> [true, false]
1415
+ # [true, false, nil].filter_map(&:itself) #=> [true]
1416
+ # ----
1417
+ #
1418
+ # @example
1419
+ # # bad
1420
+ # ary.map(&:foo).compact
1421
+ # ary.collect(&:foo).compact
1422
+ #
1423
+ # # good
1424
+ # ary.filter_map(&:foo)
1425
+ # ary.map(&:foo).compact!
1426
+ # ary.compact.map(&:foo)
1427
+ #
1428
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#30
1429
+ class RuboCop::Cop::Performance::MapCompact < ::RuboCop::Cop::Base
1430
+ include ::RuboCop::Cop::RangeHelp
1431
+ extend ::RuboCop::Cop::AutoCorrector
1432
+ extend ::RuboCop::Cop::TargetRubyVersion
1433
+
1434
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#40
1435
+ def map_compact(param0 = T.unsafe(nil)); end
1436
+
1437
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#53
1438
+ def on_csend(node); end
1439
+
1440
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#53
1441
+ def on_send(node); end
1442
+
1443
+ private
1444
+
1445
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#94
1446
+ def compact_method_with_final_newline_range(compact_method_range); end
1447
+
1448
+ # @return [Boolean]
1449
+ #
1450
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#90
1451
+ def invoke_method_after_map_compact_on_same_line?(compact_node, chained_method); end
1452
+
1453
+ # @return [Boolean]
1454
+ #
1455
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#86
1456
+ def map_method_and_compact_method_on_same_line?(map_node, compact_node); end
1457
+
1458
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#68
1459
+ def remove_compact_method(corrector, map_node, compact_node, chained_method); end
1460
+
1461
+ # @return [Boolean]
1462
+ #
1463
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#82
1464
+ def use_dot?(node); end
1465
+ end
1466
+
1467
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#35
1468
+ RuboCop::Cop::Performance::MapCompact::MSG = T.let(T.unsafe(nil), String)
1469
+
1470
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#36
1471
+ RuboCop::Cop::Performance::MapCompact::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1472
+
1473
+ # Checks if the map method is used in a chain.
1474
+ #
1475
+ # Autocorrection is not supported because an appropriate block variable name cannot be determined automatically.
1476
+ #
1477
+ # [source,ruby]
1478
+ # ----
1479
+ # class X
1480
+ # def initialize
1481
+ # @@num = 0
1482
+ # end
1483
+ #
1484
+ # def foo
1485
+ # @@num += 1
1486
+ # self
1487
+ # end
1488
+ #
1489
+ # def bar
1490
+ # @@num * 2
1491
+ # end
1492
+ # end
1493
+ #
1494
+ # [X.new, X.new].map(&:foo).map(&:bar) # => [4, 4]
1495
+ # [X.new, X.new].map { |x| x.foo.bar } # => [2, 4]
1496
+ # ----
1497
+ #
1498
+ # @example
1499
+ #
1500
+ # # bad
1501
+ # array.map(&:foo).map(&:bar)
1502
+ #
1503
+ # # good
1504
+ # array.map { |item| item.foo.bar }
1505
+ #
1506
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_method_chain.rb#43
1507
+ class RuboCop::Cop::Performance::MapMethodChain < ::RuboCop::Cop::Base
1508
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_method_chain.rb#49
1509
+ def block_pass_with_symbol_arg?(param0 = T.unsafe(nil)); end
1510
+
1511
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_method_chain.rb#53
1512
+ def on_send(node); end
1513
+
1514
+ private
1515
+
1516
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_method_chain.rb#71
1517
+ def find_begin_of_chained_map_method(node, map_args); end
1518
+ end
1519
+
1520
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_method_chain.rb#46
1521
+ RuboCop::Cop::Performance::MapMethodChain::MSG = T.let(T.unsafe(nil), String)
1522
+
1523
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_method_chain.rb#47
1524
+ RuboCop::Cop::Performance::MapMethodChain::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1525
+
1526
+ # Identifies places where methods are converted to blocks, with the
1527
+ # use of `&method`, and passed as arguments to method calls.
1528
+ # It is faster to replace those with explicit blocks, calling those methods inside.
1529
+ #
1530
+ # @example
1531
+ # # bad
1532
+ # array.map(&method(:do_something))
1533
+ # [1, 2, 3].each(&out.method(:puts))
1534
+ #
1535
+ # # good
1536
+ # array.map { |x| do_something(x) }
1537
+ # [1, 2, 3].each { |x| out.puts(x) }
1538
+ #
1539
+ # source://rubocop-performance//lib/rubocop/cop/performance/method_object_as_block.rb#19
1540
+ class RuboCop::Cop::Performance::MethodObjectAsBlock < ::RuboCop::Cop::Base
1541
+ # source://rubocop-performance//lib/rubocop/cop/performance/method_object_as_block.rb#22
1542
+ def method_object_as_argument?(param0 = T.unsafe(nil)); end
1543
+
1544
+ # source://rubocop-performance//lib/rubocop/cop/performance/method_object_as_block.rb#26
1545
+ def on_block_pass(node); end
1546
+ end
1547
+
1548
+ # source://rubocop-performance//lib/rubocop/cop/performance/method_object_as_block.rb#20
1549
+ RuboCop::Cop::Performance::MethodObjectAsBlock::MSG = T.let(T.unsafe(nil), String)
1550
+
1551
+ # Checks for `OpenStruct.new` calls.
1552
+ # Instantiation of an `OpenStruct` invalidates
1553
+ # Ruby global method cache as it causes dynamic method
1554
+ # definition during program runtime.
1555
+ # This could have an effect on performance,
1556
+ # especially in case of single-threaded
1557
+ # applications with multiple `OpenStruct` instantiations.
1558
+ #
1559
+ # @example
1560
+ # # bad
1561
+ # class MyClass
1562
+ # def my_method
1563
+ # OpenStruct.new(my_key1: 'my_value1', my_key2: 'my_value2')
1564
+ # end
1565
+ # end
1566
+ #
1567
+ # # good
1568
+ # class MyClass
1569
+ # MyStruct = Struct.new(:my_key1, :my_key2)
1570
+ # def my_method
1571
+ # MyStruct.new('my_value1', 'my_value2')
1572
+ # end
1573
+ # end
1574
+ #
1575
+ # source://rubocop-performance//lib/rubocop/cop/performance/open_struct.rb#34
1576
+ class RuboCop::Cop::Performance::OpenStruct < ::RuboCop::Cop::Base
1577
+ # source://rubocop-performance//lib/rubocop/cop/performance/open_struct.rb#42
1578
+ def on_send(node); end
1579
+
1580
+ # source://rubocop-performance//lib/rubocop/cop/performance/open_struct.rb#38
1581
+ def open_struct(param0 = T.unsafe(nil)); end
1582
+ end
1583
+
1584
+ # source://rubocop-performance//lib/rubocop/cop/performance/open_struct.rb#35
1585
+ RuboCop::Cop::Performance::OpenStruct::MSG = T.let(T.unsafe(nil), String)
1586
+
1587
+ # source://rubocop-performance//lib/rubocop/cop/performance/open_struct.rb#36
1588
+ RuboCop::Cop::Performance::OpenStruct::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1589
+
1590
+ # Identifies uses of `Range#include?` and `Range#member?`, which iterates over each
1591
+ # item in a `Range` to see if a specified item is there. In contrast,
1592
+ # `Range#cover?` simply compares the target item with the beginning and
1593
+ # end points of the `Range`. In a great majority of cases, this is what
1594
+ # is wanted.
1595
+ #
1596
+ # @example
1597
+ # # bad
1598
+ # ('a'..'z').include?('b') # => true
1599
+ # ('a'..'z').member?('b') # => true
1600
+ #
1601
+ # # good
1602
+ # ('a'..'z').cover?('b') # => true
1603
+ #
1604
+ # # Example of a case where `Range#cover?` may not provide
1605
+ # # the desired result:
1606
+ #
1607
+ # ('a'..'z').cover?('yellow') # => true
1608
+ #
1609
+ # source://rubocop-performance//lib/rubocop/cop/performance/range_include.rb#28
1610
+ class RuboCop::Cop::Performance::RangeInclude < ::RuboCop::Cop::Base
1611
+ extend ::RuboCop::Cop::AutoCorrector
1612
+
1613
+ # source://rubocop-performance//lib/rubocop/cop/performance/range_include.rb#43
1614
+ def on_send(node); end
1615
+
1616
+ # source://rubocop-performance//lib/rubocop/cop/performance/range_include.rb#39
1617
+ def range_include(param0 = T.unsafe(nil)); end
1618
+ end
1619
+
1620
+ # source://rubocop-performance//lib/rubocop/cop/performance/range_include.rb#31
1621
+ RuboCop::Cop::Performance::RangeInclude::MSG = T.let(T.unsafe(nil), String)
1622
+
1623
+ # source://rubocop-performance//lib/rubocop/cop/performance/range_include.rb#32
1624
+ RuboCop::Cop::Performance::RangeInclude::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1625
+
1626
+ # Identifies the use of a `&block` parameter and `block.call`
1627
+ # where `yield` would do just as well.
1628
+ #
1629
+ # @example
1630
+ # # bad
1631
+ # def method(&block)
1632
+ # block.call
1633
+ # end
1634
+ # def another(&func)
1635
+ # func.call 1, 2, 3
1636
+ # end
1637
+ #
1638
+ # # good
1639
+ # def method
1640
+ # yield
1641
+ # end
1642
+ # def another
1643
+ # yield 1, 2, 3
1644
+ # end
1645
+ #
1646
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#25
1647
+ class RuboCop::Cop::Performance::RedundantBlockCall < ::RuboCop::Cop::Base
1648
+ extend ::RuboCop::Cop::AutoCorrector
1649
+
1650
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#43
1651
+ def blockarg_assigned?(param0, param1); end
1652
+
1653
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#39
1654
+ def blockarg_calls(param0, param1); end
1655
+
1656
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#34
1657
+ def blockarg_def(param0 = T.unsafe(nil)); end
1658
+
1659
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#47
1660
+ def on_def(node); end
1661
+
1662
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#47
1663
+ def on_defs(node); end
1664
+
1665
+ private
1666
+
1667
+ # @return [Boolean]
1668
+ #
1669
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#97
1670
+ def args_include_block_pass?(blockcall); end
1671
+
1672
+ # offenses are registered on the `block.call` nodes
1673
+ #
1674
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#63
1675
+ def autocorrect(corrector, node); end
1676
+
1677
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#81
1678
+ def calls_to_report(argname, body); end
1679
+
1680
+ # @return [Boolean]
1681
+ #
1682
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#91
1683
+ def shadowed_block_argument?(body, block_argument_of_method_signature); end
1684
+ end
1685
+
1686
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#31
1687
+ RuboCop::Cop::Performance::RedundantBlockCall::CLOSE_PAREN = T.let(T.unsafe(nil), String)
1688
+
1689
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#28
1690
+ RuboCop::Cop::Performance::RedundantBlockCall::MSG = T.let(T.unsafe(nil), String)
1691
+
1692
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#30
1693
+ RuboCop::Cop::Performance::RedundantBlockCall::OPEN_PAREN = T.let(T.unsafe(nil), String)
1694
+
1695
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#32
1696
+ RuboCop::Cop::Performance::RedundantBlockCall::SPACE = T.let(T.unsafe(nil), String)
1697
+
1698
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#29
1699
+ RuboCop::Cop::Performance::RedundantBlockCall::YIELD = T.let(T.unsafe(nil), String)
1700
+
1701
+ # Checks for uses `Enumerable#all?`, `Enumerable#any?`, `Enumerable#one?`,
1702
+ # and `Enumerable#none?` are compared with `===` or similar methods in block.
1703
+ #
1704
+ # By default, `Object#===` behaves the same as `Object#==`, but this
1705
+ # behavior is appropriately overridden in subclass. For example,
1706
+ # `Range#===` returns `true` when argument is within the range.
1707
+ #
1708
+ # This cop has `AllowRegexpMatch` option and it is true by default because
1709
+ # `regexp.match?('string')` often used in block changes to the opposite result:
1710
+ #
1711
+ # [source,ruby]
1712
+ # ----
1713
+ # [/pattern/].all? { |regexp| regexp.match?('pattern') } # => true
1714
+ # [/pattern/].all? { |regexp| regexp =~ 'pattern' } # => true
1715
+ # [/pattern/].all?('pattern') # => false
1716
+ # ----
1717
+ #
1718
+ # @example
1719
+ # # bad
1720
+ # items.all? { |item| pattern === item }
1721
+ # items.all? { |item| item == other }
1722
+ # items.all? { |item| item.is_a?(Klass) }
1723
+ # items.all? { |item| item.kind_of?(Klass) }
1724
+ #
1725
+ # # good
1726
+ # items.all?(pattern)
1727
+ # items.all?(Klass)
1728
+ # @example AllowRegexpMatch: true (default)
1729
+ #
1730
+ # # good
1731
+ # items.all? { |item| item =~ pattern }
1732
+ # items.all? { |item| item.match?(pattern) }
1733
+ # @example AllowRegexpMatch: false
1734
+ #
1735
+ # # bad
1736
+ # items.all? { |item| item =~ pattern }
1737
+ # items.all? { |item| item.match?(pattern) }
1738
+ #
1739
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#49
1740
+ class RuboCop::Cop::Performance::RedundantEqualityComparisonBlock < ::RuboCop::Cop::Base
1741
+ extend ::RuboCop::Cop::AutoCorrector
1742
+ extend ::RuboCop::Cop::TargetRubyVersion
1743
+
1744
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#62
1745
+ def on_block(node); end
1746
+
1747
+ private
1748
+
1749
+ # @return [Boolean]
1750
+ #
1751
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#131
1752
+ def allow_regexp_match?; end
1753
+
1754
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#104
1755
+ def new_argument(block_argument, block_body); end
1756
+
1757
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#127
1758
+ def offense_range(node); end
1759
+
1760
+ # @return [Boolean]
1761
+ #
1762
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#82
1763
+ def one_block_argument?(block_arguments); end
1764
+
1765
+ # @return [Boolean]
1766
+ #
1767
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#94
1768
+ def same_block_argument_and_is_a_argument?(block_body, block_argument); end
1769
+
1770
+ # @return [Boolean]
1771
+ #
1772
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#118
1773
+ def use_block_argument_in_method_argument_of_operand?(block_argument, operand); end
1774
+
1775
+ # @return [Boolean]
1776
+ #
1777
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#86
1778
+ def use_equality_comparison_block?(block_body); end
1779
+ end
1780
+
1781
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#58
1782
+ RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::COMPARISON_METHODS = T.let(T.unsafe(nil), Array)
1783
+
1784
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#60
1785
+ RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::IS_A_METHODS = T.let(T.unsafe(nil), Array)
1786
+
1787
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#55
1788
+ RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::MSG = T.let(T.unsafe(nil), String)
1789
+
1790
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#59
1791
+ RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::REGEXP_METHODS = T.let(T.unsafe(nil), Array)
1792
+
1793
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#57
1794
+ RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::TARGET_METHODS = T.let(T.unsafe(nil), Array)
1795
+
1796
+ # Identifies the use of `Regexp#match` or `String#match`, which
1797
+ # returns `#<MatchData>`/`nil`. The return value of `=~` is an integral
1798
+ # index/`nil` and is more performant.
1799
+ #
1800
+ # @example
1801
+ # # bad
1802
+ # do_something if str.match(/regex/)
1803
+ # while regex.match('str')
1804
+ # do_something
1805
+ # end
1806
+ #
1807
+ # # good
1808
+ # method(str =~ /regex/)
1809
+ # return value unless regex =~ 'str'
1810
+ #
1811
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#20
1812
+ class RuboCop::Cop::Performance::RedundantMatch < ::RuboCop::Cop::Base
1813
+ extend ::RuboCop::Cop::AutoCorrector
1814
+
1815
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#28
1816
+ def match_call?(param0 = T.unsafe(nil)); end
1817
+
1818
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#37
1819
+ def on_send(node); end
1820
+
1821
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#33
1822
+ def only_truthiness_matters?(param0 = T.unsafe(nil)); end
1823
+
1824
+ private
1825
+
1826
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#49
1827
+ def autocorrect(corrector, node); end
1828
+
1829
+ # @return [Boolean]
1830
+ #
1831
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#55
1832
+ def autocorrectable?(node); end
1833
+ end
1834
+
1835
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#23
1836
+ RuboCop::Cop::Performance::RedundantMatch::MSG = T.let(T.unsafe(nil), String)
1837
+
1838
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#24
1839
+ RuboCop::Cop::Performance::RedundantMatch::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1840
+
1841
+ # Identifies places where `Hash#merge!` can be replaced by `Hash#[]=`.
1842
+ # You can set the maximum number of key-value pairs to consider
1843
+ # an offense with `MaxKeyValuePairs`.
1844
+ #
1845
+ # @example
1846
+ # # bad
1847
+ # hash.merge!(a: 1)
1848
+ # hash.merge!({'key' => 'value'})
1849
+ #
1850
+ # # good
1851
+ # hash[:a] = 1
1852
+ # hash['key'] = 'value'
1853
+ # @example MaxKeyValuePairs: 2 (default)
1854
+ # # bad
1855
+ # hash.merge!(a: 1, b: 2)
1856
+ #
1857
+ # # good
1858
+ # hash[:a] = 1
1859
+ # hash[:b] = 2
1860
+ #
1861
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#30
1862
+ class RuboCop::Cop::Performance::RedundantMerge < ::RuboCop::Cop::Base
1863
+ include ::RuboCop::Cop::Alignment
1864
+ extend ::RuboCop::Cop::AutoCorrector
1865
+
1866
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#48
1867
+ def modifier_flow_control?(param0 = T.unsafe(nil)); end
1868
+
1869
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#52
1870
+ def on_send(node); end
1871
+
1872
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#44
1873
+ def redundant_merge_candidate(param0 = T.unsafe(nil)); end
1874
+
1875
+ private
1876
+
1877
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#106
1878
+ def correct_multiple_elements(corrector, node, parent, new_source); end
1879
+
1880
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#118
1881
+ def correct_single_element(corrector, node, new_source); end
1882
+
1883
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#79
1884
+ def each_redundant_merge(node); end
1885
+
1886
+ # @return [Boolean]
1887
+ #
1888
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#98
1889
+ def kwsplat_used?(pairs); end
1890
+
1891
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#144
1892
+ def leading_spaces(node); end
1893
+
1894
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#148
1895
+ def max_key_value_pairs; end
1896
+
1897
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#71
1898
+ def message(node); end
1899
+
1900
+ # @return [Boolean]
1901
+ #
1902
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#87
1903
+ def non_redundant_merge?(node, receiver, pairs); end
1904
+
1905
+ # @return [Boolean]
1906
+ #
1907
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#94
1908
+ def non_redundant_pairs?(receiver, pairs); end
1909
+
1910
+ # @return [Boolean]
1911
+ #
1912
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#102
1913
+ def non_redundant_value_used?(receiver, node); end
1914
+
1915
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#132
1916
+ def rewrite_with_modifier(node, parent, new_source); end
1917
+
1918
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#122
1919
+ def to_assignments(receiver, pairs); end
1920
+ end
1921
+
1922
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#34
1923
+ RuboCop::Cop::Performance::RedundantMerge::AREF_ASGN = T.let(T.unsafe(nil), String)
1924
+
1925
+ # A utility class for checking the use of values within an
1926
+ # `each_with_object` call.
1927
+ #
1928
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#154
1929
+ class RuboCop::Cop::Performance::RedundantMerge::EachWithObjectInspector
1930
+ extend ::RuboCop::AST::NodePattern::Macros
1931
+
1932
+ # @return [EachWithObjectInspector] a new instance of EachWithObjectInspector
1933
+ #
1934
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#157
1935
+ def initialize(node, receiver); end
1936
+
1937
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#188
1938
+ def each_with_object_node(param0 = T.unsafe(nil)); end
1939
+
1940
+ # @return [Boolean]
1941
+ #
1942
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#162
1943
+ def value_used?; end
1944
+
1945
+ private
1946
+
1947
+ # @return [Boolean]
1948
+ #
1949
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#172
1950
+ def eligible_receiver?; end
1951
+
1952
+ # Returns the value of attribute node.
1953
+ #
1954
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#170
1955
+ def node; end
1956
+
1957
+ # Returns the value of attribute receiver.
1958
+ #
1959
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#170
1960
+ def receiver; end
1961
+
1962
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#176
1963
+ def second_argument; end
1964
+
1965
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#183
1966
+ def unwind(receiver); end
1967
+ end
1968
+
1969
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#35
1970
+ RuboCop::Cop::Performance::RedundantMerge::MSG = T.let(T.unsafe(nil), String)
1971
+
1972
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#36
1973
+ RuboCop::Cop::Performance::RedundantMerge::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1974
+
1975
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#38
1976
+ RuboCop::Cop::Performance::RedundantMerge::WITH_MODIFIER_CORRECTION = T.let(T.unsafe(nil), String)
1977
+
1978
+ # Identifies places where `sort { |a, b| a <=> b }` can be replaced with `sort`.
1979
+ #
1980
+ # @example
1981
+ # # bad
1982
+ # array.sort { |a, b| a <=> b }
1983
+ #
1984
+ # # good
1985
+ # array.sort
1986
+ #
1987
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_sort_block.rb#15
1988
+ class RuboCop::Cop::Performance::RedundantSortBlock < ::RuboCop::Cop::Base
1989
+ include ::RuboCop::Cop::RangeHelp
1990
+ include ::RuboCop::Cop::SortBlock
1991
+ extend ::RuboCop::Cop::AutoCorrector
1992
+
1993
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_sort_block.rb#21
1994
+ def on_block(node); end
1995
+
1996
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_sort_block.rb#29
1997
+ def on_numblock(node); end
1998
+
1999
+ private
2000
+
2001
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_sort_block.rb#40
2002
+ def register_offense(send, node); end
2003
+ end
2004
+
2005
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_sort_block.rb#19
2006
+ RuboCop::Cop::Performance::RedundantSortBlock::MSG = T.let(T.unsafe(nil), String)
2007
+
2008
+ # Identifies places where `split` argument can be replaced from
2009
+ # a deterministic regexp to a string.
2010
+ #
2011
+ # @example
2012
+ # # bad
2013
+ # 'a,b,c'.split(/,/)
2014
+ #
2015
+ # # good
2016
+ # 'a,b,c'.split(',')
2017
+ #
2018
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#15
2019
+ class RuboCop::Cop::Performance::RedundantSplitRegexpArgument < ::RuboCop::Cop::Base
2020
+ extend ::RuboCop::Cop::AutoCorrector
2021
+
2022
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#27
2023
+ def on_csend(node); end
2024
+
2025
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#27
2026
+ def on_send(node); end
2027
+
2028
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#23
2029
+ def split_call_with_regexp?(param0 = T.unsafe(nil)); end
2030
+
2031
+ private
2032
+
2033
+ # @return [Boolean]
2034
+ #
2035
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#42
2036
+ def determinist_regexp?(regexp_node); end
2037
+
2038
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#46
2039
+ def replacement(regexp_node); end
2040
+ end
2041
+
2042
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#20
2043
+ RuboCop::Cop::Performance::RedundantSplitRegexpArgument::DETERMINISTIC_REGEX = T.let(T.unsafe(nil), Regexp)
2044
+
2045
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#18
2046
+ RuboCop::Cop::Performance::RedundantSplitRegexpArgument::MSG = T.let(T.unsafe(nil), String)
2047
+
2048
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#19
2049
+ RuboCop::Cop::Performance::RedundantSplitRegexpArgument::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2050
+
2051
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#21
2052
+ RuboCop::Cop::Performance::RedundantSplitRegexpArgument::STR_SPECIAL_CHARS = T.let(T.unsafe(nil), Array)
2053
+
2054
+ # Checks for redundant `String#chars`.
2055
+ #
2056
+ # @example
2057
+ # # bad
2058
+ # str.chars[0..2]
2059
+ # str.chars.slice(0..2)
2060
+ # str.chars.last
2061
+ #
2062
+ # # good
2063
+ # str[0..2].chars
2064
+ #
2065
+ # # bad
2066
+ # str.chars.first
2067
+ # str.chars.first(2)
2068
+ #
2069
+ # # good
2070
+ # str[0]
2071
+ # str[0...2].chars
2072
+ # str[-1]
2073
+ #
2074
+ # # bad
2075
+ # str.chars.take(2)
2076
+ # str.chars.length
2077
+ # str.chars.size
2078
+ # str.chars.empty?
2079
+ #
2080
+ # # good
2081
+ # str[0...2].chars
2082
+ # str.length
2083
+ # str.size
2084
+ # str.empty?
2085
+ #
2086
+ # # For example, if the receiver is an empty string, it will be incompatible.
2087
+ # # If a negative value is specified for the receiver, `nil` is returned.
2088
+ # str.chars.last(2) # Incompatible with `str[-2..-1].chars`.
2089
+ # str.chars.drop(2) # Incompatible with `str[2..-1].chars`.
2090
+ #
2091
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#43
2092
+ class RuboCop::Cop::Performance::RedundantStringChars < ::RuboCop::Cop::Base
2093
+ include ::RuboCop::Cop::RangeHelp
2094
+ extend ::RuboCop::Cop::AutoCorrector
2095
+
2096
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#54
2097
+ def on_send(node); end
2098
+
2099
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#50
2100
+ def redundant_chars_call?(param0 = T.unsafe(nil)); end
2101
+
2102
+ private
2103
+
2104
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#112
2105
+ def build_bad_method(method, args); end
2106
+
2107
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#125
2108
+ def build_call_args(call_args_node); end
2109
+
2110
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#85
2111
+ def build_good_method(method, args); end
2112
+
2113
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#100
2114
+ def build_good_method_for_brackets_or_first_method(method, args); end
2115
+
2116
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#79
2117
+ def build_message(method, args); end
2118
+
2119
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#75
2120
+ def correction_range(receiver, node); end
2121
+
2122
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#71
2123
+ def offense_range(receiver, node); end
2124
+ end
2125
+
2126
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#47
2127
+ RuboCop::Cop::Performance::RedundantStringChars::MSG = T.let(T.unsafe(nil), String)
2128
+
2129
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#48
2130
+ RuboCop::Cop::Performance::RedundantStringChars::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2131
+
2132
+ # In Ruby 2.4, `String#match?`, `Regexp#match?`, and `Symbol#match?`
2133
+ # have been added. The methods are faster than `match`.
2134
+ # Because the methods avoid creating a `MatchData` object or saving
2135
+ # backref.
2136
+ # So, when `MatchData` is not used, use `match?` instead of `match`.
2137
+ #
2138
+ # @example
2139
+ # # bad
2140
+ # def foo
2141
+ # if x =~ /re/
2142
+ # do_something
2143
+ # end
2144
+ # end
2145
+ #
2146
+ # # bad
2147
+ # def foo
2148
+ # if x !~ /re/
2149
+ # do_something
2150
+ # end
2151
+ # end
2152
+ #
2153
+ # # bad
2154
+ # def foo
2155
+ # if x.match(/re/)
2156
+ # do_something
2157
+ # end
2158
+ # end
2159
+ #
2160
+ # # bad
2161
+ # def foo
2162
+ # if /re/ === x
2163
+ # do_something
2164
+ # end
2165
+ # end
2166
+ #
2167
+ # # good
2168
+ # def foo
2169
+ # if x.match?(/re/)
2170
+ # do_something
2171
+ # end
2172
+ # end
2173
+ #
2174
+ # # good
2175
+ # def foo
2176
+ # if !x.match?(/re/)
2177
+ # do_something
2178
+ # end
2179
+ # end
2180
+ #
2181
+ # # good
2182
+ # def foo
2183
+ # if x =~ /re/
2184
+ # do_something(Regexp.last_match)
2185
+ # end
2186
+ # end
2187
+ #
2188
+ # # good
2189
+ # def foo
2190
+ # if x.match(/re/)
2191
+ # do_something($~)
2192
+ # end
2193
+ # end
2194
+ #
2195
+ # # good
2196
+ # def foo
2197
+ # if /re/ === x
2198
+ # do_something($~)
2199
+ # end
2200
+ # end
2201
+ #
2202
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#75
2203
+ class RuboCop::Cop::Performance::RegexpMatch < ::RuboCop::Cop::Base
2204
+ extend ::RuboCop::Cop::AutoCorrector
2205
+ extend ::RuboCop::Cop::TargetRubyVersion
2206
+
2207
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#125
2208
+ def last_matches(param0); end
2209
+
2210
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#86
2211
+ def match_method?(param0 = T.unsafe(nil)); end
2212
+
2213
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#122
2214
+ def match_node?(param0 = T.unsafe(nil)); end
2215
+
2216
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#97
2217
+ def match_operator?(param0 = T.unsafe(nil)); end
2218
+
2219
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#101
2220
+ def match_threequals?(param0 = T.unsafe(nil)); end
2221
+
2222
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#93
2223
+ def match_with_int_arg_method?(param0 = T.unsafe(nil)); end
2224
+
2225
+ # @return [Boolean]
2226
+ #
2227
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#105
2228
+ def match_with_lvasgn?(node); end
2229
+
2230
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#142
2231
+ def on_case(node); end
2232
+
2233
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#138
2234
+ def on_if(node); end
2235
+
2236
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#123
2237
+ def search_match_nodes(param0); end
2238
+
2239
+ private
2240
+
2241
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#165
2242
+ def autocorrect(corrector, node); end
2243
+
2244
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#154
2245
+ def check_condition(cond); end
2246
+
2247
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#250
2248
+ def correct_operator(corrector, recv, arg, oper = T.unsafe(nil)); end
2249
+
2250
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#275
2251
+ def correction_range(recv, arg); end
2252
+
2253
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#221
2254
+ def find_last_match(body, range, scope_root); end
2255
+
2256
+ # @return [Boolean]
2257
+ #
2258
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#181
2259
+ def last_match_used?(match_node); end
2260
+
2261
+ # @return [Boolean]
2262
+ #
2263
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#246
2264
+ def match_gvar?(sym); end
2265
+
2266
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#177
2267
+ def message(node); end
2268
+
2269
+ # @return [Boolean]
2270
+ #
2271
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#217
2272
+ def modifier_form?(match_node); end
2273
+
2274
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#203
2275
+ def next_match_pos(body, match_node_pos, scope_root); end
2276
+
2277
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#190
2278
+ def range_to_search_for_last_matches(match_node, body, scope_root); end
2279
+
2280
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#259
2281
+ def replace_with_match_predicate_method(corrector, recv, arg, op_range); end
2282
+
2283
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#228
2284
+ def scope_body(node); end
2285
+
2286
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#240
2287
+ def scope_root(node); end
2288
+
2289
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#270
2290
+ def swap_receiver_and_arg(corrector, recv, arg); end
2291
+
2292
+ class << self
2293
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#134
2294
+ def autocorrect_incompatible_with; end
2295
+ end
2296
+ end
2297
+
2298
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#112
2299
+ RuboCop::Cop::Performance::RegexpMatch::MATCH_NODE_PATTERN = T.let(T.unsafe(nil), String)
2300
+
2301
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#84
2302
+ RuboCop::Cop::Performance::RegexpMatch::MSG = T.let(T.unsafe(nil), String)
2303
+
2304
+ # Constants are included in this list because it is unlikely that
2305
+ # someone will store `nil` as a constant and then use it for comparison
2306
+ #
2307
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#83
2308
+ RuboCop::Cop::Performance::RegexpMatch::TYPES_IMPLEMENTING_MATCH = T.let(T.unsafe(nil), Array)
2309
+
2310
+ # Identifies usages of `reverse.each` and change them to use `reverse_each` instead.
2311
+ #
2312
+ # If the return value is used, it will not be detected because the result will be different.
2313
+ #
2314
+ # [source,ruby]
2315
+ # ----
2316
+ # [1, 2, 3].reverse.each {} #=> [3, 2, 1]
2317
+ # [1, 2, 3].reverse_each {} #=> [1, 2, 3]
2318
+ # ----
2319
+ #
2320
+ # @example
2321
+ # # bad
2322
+ # items.reverse.each
2323
+ #
2324
+ # # good
2325
+ # items.reverse_each
2326
+ #
2327
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#22
2328
+ class RuboCop::Cop::Performance::ReverseEach < ::RuboCop::Cop::Base
2329
+ include ::RuboCop::Cop::RangeHelp
2330
+ extend ::RuboCop::Cop::AutoCorrector
2331
+
2332
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#33
2333
+ def on_csend(node); end
2334
+
2335
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#33
2336
+ def on_send(node); end
2337
+
2338
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#29
2339
+ def reverse_each?(param0 = T.unsafe(nil)); end
2340
+
2341
+ private
2342
+
2343
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#54
2344
+ def offense_range(node); end
2345
+
2346
+ # @return [Boolean]
2347
+ #
2348
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#48
2349
+ def use_return_value?(node); end
2350
+ end
2351
+
2352
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#26
2353
+ RuboCop::Cop::Performance::ReverseEach::MSG = T.let(T.unsafe(nil), String)
2354
+
2355
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#27
2356
+ RuboCop::Cop::Performance::ReverseEach::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2357
+
2358
+ # Identifies places where `reverse.first(n)` and `reverse.first`
2359
+ # can be replaced by `last(n).reverse` and `last`.
2360
+ #
2361
+ # @example
2362
+ #
2363
+ # # bad
2364
+ # array.reverse.first(5)
2365
+ # array.reverse.first
2366
+ #
2367
+ # # good
2368
+ # array.last(5).reverse
2369
+ # array.last
2370
+ #
2371
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#19
2372
+ class RuboCop::Cop::Performance::ReverseFirst < ::RuboCop::Cop::Base
2373
+ include ::RuboCop::Cop::RangeHelp
2374
+ extend ::RuboCop::Cop::AutoCorrector
2375
+
2376
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#30
2377
+ def on_csend(node); end
2378
+
2379
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#30
2380
+ def on_send(node); end
2381
+
2382
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#26
2383
+ def reverse_first_candidate?(param0 = T.unsafe(nil)); end
2384
+
2385
+ private
2386
+
2387
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#64
2388
+ def build_bad_method(node); end
2389
+
2390
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#56
2391
+ def build_good_method(node); end
2392
+
2393
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#50
2394
+ def build_message(node); end
2395
+
2396
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#46
2397
+ def correction_range(receiver, node); end
2398
+ end
2399
+
2400
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#23
2401
+ RuboCop::Cop::Performance::ReverseFirst::MSG = T.let(T.unsafe(nil), String)
2402
+
2403
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#24
2404
+ RuboCop::Cop::Performance::ReverseFirst::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2405
+
2406
+ # In Ruby 2.7, `Enumerable#filter_map` has been added.
2407
+ #
2408
+ # This cop identifies places where `select.map` can be replaced by `filter_map`.
2409
+ #
2410
+ # @example
2411
+ # # bad
2412
+ # ary.select(&:foo).map(&:bar)
2413
+ # ary.filter(&:foo).map(&:bar)
2414
+ #
2415
+ # # good
2416
+ # ary.filter_map { |o| o.bar if o.foo }
2417
+ #
2418
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#18
2419
+ class RuboCop::Cop::Performance::SelectMap < ::RuboCop::Cop::Base
2420
+ include ::RuboCop::Cop::RangeHelp
2421
+ extend ::RuboCop::Cop::TargetRubyVersion
2422
+
2423
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#27
2424
+ def bad_method?(param0 = T.unsafe(nil)); end
2425
+
2426
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#31
2427
+ def on_csend(node); end
2428
+
2429
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#31
2430
+ def on_send(node); end
2431
+
2432
+ private
2433
+
2434
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#45
2435
+ def map_method_candidate(node); end
2436
+
2437
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#55
2438
+ def offense_range(node, map_method); end
2439
+ end
2440
+
2441
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#24
2442
+ RuboCop::Cop::Performance::SelectMap::MSG = T.let(T.unsafe(nil), String)
2443
+
2444
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#25
2445
+ RuboCop::Cop::Performance::SelectMap::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2446
+
2447
+ # Identifies usages of `count` on an `Array` and `Hash` and change them to `size`.
2448
+ #
2449
+ # TODO: Add advanced detection of variables that could
2450
+ # have been assigned to an array or a hash.
2451
+ #
2452
+ # @example
2453
+ # # bad
2454
+ # [1, 2, 3].count
2455
+ # (1..3).to_a.count
2456
+ # Array[*1..3].count
2457
+ # Array(1..3).count
2458
+ #
2459
+ # # bad
2460
+ # {a: 1, b: 2, c: 3}.count
2461
+ # [[:foo, :bar], [1, 2]].to_h.count
2462
+ # Hash[*('a'..'z')].count
2463
+ # Hash(key: :value).count
2464
+ #
2465
+ # # good
2466
+ # [1, 2, 3].size
2467
+ # (1..3).to_a.size
2468
+ # Array[*1..3].size
2469
+ # Array(1..3).size
2470
+ #
2471
+ # # good
2472
+ # {a: 1, b: 2, c: 3}.size
2473
+ # [[:foo, :bar], [1, 2]].to_h.size
2474
+ # Hash[*('a'..'z')].size
2475
+ # Hash(key: :value).size
2476
+ #
2477
+ # # good
2478
+ # [1, 2, 3].count { |e| e > 2 }
2479
+ #
2480
+ # source://rubocop-performance//lib/rubocop/cop/performance/size.rb#37
2481
+ class RuboCop::Cop::Performance::Size < ::RuboCop::Cop::Base
2482
+ extend ::RuboCop::Cop::AutoCorrector
2483
+
2484
+ # source://rubocop-performance//lib/rubocop/cop/performance/size.rb#43
2485
+ def array?(param0 = T.unsafe(nil)); end
2486
+
2487
+ # source://rubocop-performance//lib/rubocop/cop/performance/size.rb#61
2488
+ def count?(param0 = T.unsafe(nil)); end
2489
+
2490
+ # source://rubocop-performance//lib/rubocop/cop/performance/size.rb#52
2491
+ def hash?(param0 = T.unsafe(nil)); end
2492
+
2493
+ # source://rubocop-performance//lib/rubocop/cop/performance/size.rb#65
2494
+ def on_send(node); end
2495
+ end
2496
+
2497
+ # source://rubocop-performance//lib/rubocop/cop/performance/size.rb#40
2498
+ RuboCop::Cop::Performance::Size::MSG = T.let(T.unsafe(nil), String)
2499
+
2500
+ # source://rubocop-performance//lib/rubocop/cop/performance/size.rb#41
2501
+ RuboCop::Cop::Performance::Size::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2502
+
2503
+ # Identifies places where `sort { |a, b| b <=> a }`
2504
+ # can be replaced by a faster `sort.reverse`.
2505
+ #
2506
+ # @example
2507
+ # # bad
2508
+ # array.sort { |a, b| b <=> a }
2509
+ #
2510
+ # # good
2511
+ # array.sort.reverse
2512
+ #
2513
+ # source://rubocop-performance//lib/rubocop/cop/performance/sort_reverse.rb#16
2514
+ class RuboCop::Cop::Performance::SortReverse < ::RuboCop::Cop::Base
2515
+ include ::RuboCop::Cop::RangeHelp
2516
+ include ::RuboCop::Cop::SortBlock
2517
+ extend ::RuboCop::Cop::AutoCorrector
2518
+
2519
+ # source://rubocop-performance//lib/rubocop/cop/performance/sort_reverse.rb#22
2520
+ def on_block(node); end
2521
+
2522
+ # source://rubocop-performance//lib/rubocop/cop/performance/sort_reverse.rb#30
2523
+ def on_numblock(node); end
2524
+
2525
+ private
2526
+
2527
+ # source://rubocop-performance//lib/rubocop/cop/performance/sort_reverse.rb#42
2528
+ def register_offense(send, node); end
2529
+ end
2530
+
2531
+ # source://rubocop-performance//lib/rubocop/cop/performance/sort_reverse.rb#20
2532
+ RuboCop::Cop::Performance::SortReverse::MSG = T.let(T.unsafe(nil), String)
2533
+
2534
+ # Identifies places where `gsub(/a+/, 'a')` and `gsub!(/a+/, 'a')`
2535
+ # can be replaced by `squeeze('a')` and `squeeze!('a')`.
2536
+ #
2537
+ # The `squeeze('a')` method is faster than `gsub(/a+/, 'a')`.
2538
+ #
2539
+ # @example
2540
+ #
2541
+ # # bad
2542
+ # str.gsub(/a+/, 'a')
2543
+ # str.gsub!(/a+/, 'a')
2544
+ #
2545
+ # # good
2546
+ # str.squeeze('a')
2547
+ # str.squeeze!('a')
2548
+ #
2549
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#21
2550
+ class RuboCop::Cop::Performance::Squeeze < ::RuboCop::Cop::Base
2551
+ extend ::RuboCop::Cop::AutoCorrector
2552
+
2553
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#39
2554
+ def on_csend(node); end
2555
+
2556
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#39
2557
+ def on_send(node); end
2558
+
2559
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#29
2560
+ def squeeze_candidate?(param0 = T.unsafe(nil)); end
2561
+
2562
+ private
2563
+
2564
+ # @return [Boolean]
2565
+ #
2566
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#61
2567
+ def repeating_literal?(regex_str); end
2568
+ end
2569
+
2570
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#24
2571
+ RuboCop::Cop::Performance::Squeeze::MSG = T.let(T.unsafe(nil), String)
2572
+
2573
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#27
2574
+ RuboCop::Cop::Performance::Squeeze::PREFERRED_METHODS = T.let(T.unsafe(nil), Hash)
2575
+
2576
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#25
2577
+ RuboCop::Cop::Performance::Squeeze::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2578
+
2579
+ # Identifies unnecessary use of a regex where `String#start_with?` would suffice.
2580
+ #
2581
+ # This cop has `SafeMultiline` configuration option that `true` by default because
2582
+ # `^start` is unsafe as it will behave incompatible with `start_with?`
2583
+ # for receiver is multiline string.
2584
+ #
2585
+ # @example
2586
+ # # bad
2587
+ # 'abc'.match?(/\Aab/)
2588
+ # /\Aab/.match?('abc')
2589
+ # 'abc' =~ /\Aab/
2590
+ # /\Aab/ =~ 'abc'
2591
+ # 'abc'.match(/\Aab/)
2592
+ # /\Aab/.match('abc')
2593
+ #
2594
+ # # good
2595
+ # 'abc'.start_with?('ab')
2596
+ # @example SafeMultiline: true (default)
2597
+ #
2598
+ # # good
2599
+ # 'abc'.match?(/^ab/)
2600
+ # /^ab/.match?('abc')
2601
+ # 'abc' =~ /^ab/
2602
+ # /^ab/ =~ 'abc'
2603
+ # 'abc'.match(/^ab/)
2604
+ # /^ab/.match('abc')
2605
+ # @example SafeMultiline: false
2606
+ #
2607
+ # # bad
2608
+ # 'abc'.match?(/^ab/)
2609
+ # /^ab/.match?('abc')
2610
+ # 'abc' =~ /^ab/
2611
+ # /^ab/ =~ 'abc'
2612
+ # 'abc'.match(/^ab/)
2613
+ # /^ab/.match('abc')
2614
+ #
2615
+ # source://rubocop-performance//lib/rubocop/cop/performance/start_with.rb#49
2616
+ class RuboCop::Cop::Performance::StartWith < ::RuboCop::Cop::Base
2617
+ include ::RuboCop::Cop::RegexpMetacharacter
2618
+ extend ::RuboCop::Cop::AutoCorrector
2619
+
2620
+ # source://rubocop-performance//lib/rubocop/cop/performance/start_with.rb#62
2621
+ def on_csend(node); end
2622
+
2623
+ # source://rubocop-performance//lib/rubocop/cop/performance/start_with.rb#62
2624
+ def on_match_with_lvasgn(node); end
2625
+
2626
+ # source://rubocop-performance//lib/rubocop/cop/performance/start_with.rb#62
2627
+ def on_send(node); end
2628
+
2629
+ # source://rubocop-performance//lib/rubocop/cop/performance/start_with.rb#56
2630
+ def redundant_regex?(param0 = T.unsafe(nil)); end
2631
+ end
2632
+
2633
+ # source://rubocop-performance//lib/rubocop/cop/performance/start_with.rb#53
2634
+ RuboCop::Cop::Performance::StartWith::MSG = T.let(T.unsafe(nil), String)
2635
+
2636
+ # source://rubocop-performance//lib/rubocop/cop/performance/start_with.rb#54
2637
+ RuboCop::Cop::Performance::StartWith::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2638
+
2639
+ # Identifies places where string identifier argument can be replaced
2640
+ # by symbol identifier argument.
2641
+ # It prevents the redundancy of the internal string-to-symbol conversion.
2642
+ #
2643
+ # This cop targets methods that take identifier (e.g. method name) argument
2644
+ # and the following examples are parts of it.
2645
+ #
2646
+ # @example
2647
+ #
2648
+ # # bad
2649
+ # send('do_something')
2650
+ # attr_accessor 'do_something'
2651
+ # instance_variable_get('@ivar')
2652
+ #
2653
+ # # good
2654
+ # send(:do_something)
2655
+ # attr_accessor :do_something
2656
+ # instance_variable_get(:@ivar)
2657
+ #
2658
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_identifier_argument.rb#25
2659
+ class RuboCop::Cop::Performance::StringIdentifierArgument < ::RuboCop::Cop::Base
2660
+ extend ::RuboCop::Cop::AutoCorrector
2661
+
2662
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_identifier_argument.rb#48
2663
+ def on_send(node); end
2664
+ end
2665
+
2666
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_identifier_argument.rb#30
2667
+ RuboCop::Cop::Performance::StringIdentifierArgument::COMMAND_METHODS = T.let(T.unsafe(nil), Array)
2668
+
2669
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_identifier_argument.rb#28
2670
+ RuboCop::Cop::Performance::StringIdentifierArgument::MSG = T.let(T.unsafe(nil), String)
2671
+
2672
+ # NOTE: `attr` method is not included in this list as it can cause false positives in Nokogiri API.
2673
+ # And `attr` may not be used because `Style/Attr` registers an offense.
2674
+ # https://github.com/rubocop/rubocop-performance/issues/278
2675
+ #
2676
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_identifier_argument.rb#38
2677
+ RuboCop::Cop::Performance::StringIdentifierArgument::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2678
+
2679
+ # Identifies unnecessary use of a regex where `String#include?` would suffice.
2680
+ #
2681
+ # @example
2682
+ # # bad
2683
+ # str.match?(/ab/)
2684
+ # /ab/.match?(str)
2685
+ # str =~ /ab/
2686
+ # /ab/ =~ str
2687
+ # str.match(/ab/)
2688
+ # /ab/.match(str)
2689
+ #
2690
+ # # good
2691
+ # str.include?('ab')
2692
+ #
2693
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#22
2694
+ class RuboCop::Cop::Performance::StringInclude < ::RuboCop::Cop::Base
2695
+ extend ::RuboCop::Cop::AutoCorrector
2696
+
2697
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#35
2698
+ def on_csend(node); end
2699
+
2700
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#35
2701
+ def on_match_with_lvasgn(node); end
2702
+
2703
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#35
2704
+ def on_send(node); end
2705
+
2706
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#28
2707
+ def redundant_regex?(param0 = T.unsafe(nil)); end
2708
+
2709
+ private
2710
+
2711
+ # @return [Boolean]
2712
+ #
2713
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#57
2714
+ def literal?(regex_str); end
2715
+ end
2716
+
2717
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#25
2718
+ RuboCop::Cop::Performance::StringInclude::MSG = T.let(T.unsafe(nil), String)
2719
+
2720
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#26
2721
+ RuboCop::Cop::Performance::StringInclude::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2722
+
2723
+ # Identifies places where `gsub` can be replaced by `tr` or `delete`.
2724
+ #
2725
+ # @example
2726
+ # # bad
2727
+ # 'abc'.gsub('b', 'd')
2728
+ # 'abc'.gsub('a', '')
2729
+ # 'abc'.gsub(/a/, 'd')
2730
+ # 'abc'.gsub!('a', 'd')
2731
+ #
2732
+ # # good
2733
+ # 'abc'.gsub(/.*/, 'a')
2734
+ # 'abc'.gsub(/a+/, 'd')
2735
+ # 'abc'.tr('b', 'd')
2736
+ # 'a b c'.delete(' ')
2737
+ #
2738
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#20
2739
+ class RuboCop::Cop::Performance::StringReplacement < ::RuboCop::Cop::Base
2740
+ include ::RuboCop::Cop::RangeHelp
2741
+ extend ::RuboCop::Cop::AutoCorrector
2742
+
2743
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#37
2744
+ def on_csend(node); end
2745
+
2746
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#37
2747
+ def on_send(node); end
2748
+
2749
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#31
2750
+ def string_replacement?(param0 = T.unsafe(nil)); end
2751
+
2752
+ private
2753
+
2754
+ # @return [Boolean]
2755
+ #
2756
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#84
2757
+ def accept_first_param?(first_param); end
2758
+
2759
+ # @return [Boolean]
2760
+ #
2761
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#79
2762
+ def accept_second_param?(second_param); end
2763
+
2764
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#60
2765
+ def autocorrect(corrector, node); end
2766
+
2767
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#100
2768
+ def first_source(first_param); end
2769
+
2770
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#143
2771
+ def message(node, first_source, second_source); end
2772
+
2773
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#149
2774
+ def method_suffix(node); end
2775
+
2776
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#49
2777
+ def offense(node, first_param, second_param); end
2778
+
2779
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#129
2780
+ def range(node); end
2781
+
2782
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#153
2783
+ def remove_second_param(corrector, node, first_param); end
2784
+
2785
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#70
2786
+ def replace_method(corrector, node, first_source, second_source, first_param); end
2787
+
2788
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#133
2789
+ def replacement_method(node, first_source, second_source); end
2790
+
2791
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#118
2792
+ def source_from_regex_constructor(node); end
2793
+
2794
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#111
2795
+ def source_from_regex_literal(node); end
2796
+ end
2797
+
2798
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#29
2799
+ RuboCop::Cop::Performance::StringReplacement::BANG = T.let(T.unsafe(nil), String)
2800
+
2801
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#27
2802
+ RuboCop::Cop::Performance::StringReplacement::DELETE = T.let(T.unsafe(nil), String)
2803
+
2804
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#26
2805
+ RuboCop::Cop::Performance::StringReplacement::DETERMINISTIC_REGEX = T.let(T.unsafe(nil), Regexp)
2806
+
2807
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#24
2808
+ RuboCop::Cop::Performance::StringReplacement::MSG = T.let(T.unsafe(nil), String)
2809
+
2810
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#25
2811
+ RuboCop::Cop::Performance::StringReplacement::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2812
+
2813
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#28
2814
+ RuboCop::Cop::Performance::StringReplacement::TR = T.let(T.unsafe(nil), String)
2815
+
2816
+ # Identifies places where custom code finding the sum of elements
2817
+ # in some Enumerable object can be replaced by `Enumerable#sum` method.
2818
+ #
2819
+ # @example OnlySumOrWithInitialValue: false (default)
2820
+ # # bad
2821
+ # [1, 2, 3].inject(:+) # Autocorrections for cases without initial value are unsafe
2822
+ # [1, 2, 3].inject(&:+) # and will only be performed when using the `-A` option.
2823
+ # [1, 2, 3].reduce { |acc, elem| acc + elem } # They can be prohibited completely using `SafeAutoCorrect: true`.
2824
+ # [1, 2, 3].reduce(10, :+)
2825
+ # [1, 2, 3].map { |elem| elem ** 2 }.sum
2826
+ # [1, 2, 3].collect(&:count).sum(10)
2827
+ #
2828
+ # # good
2829
+ # [1, 2, 3].sum
2830
+ # [1, 2, 3].sum(10)
2831
+ # [1, 2, 3].sum { |elem| elem ** 2 }
2832
+ # [1, 2, 3].sum(10, &:count)
2833
+ # @example OnlySumOrWithInitialValue: true
2834
+ # # bad
2835
+ # [1, 2, 3].reduce(10, :+)
2836
+ # [1, 2, 3].map { |elem| elem ** 2 }.sum
2837
+ # [1, 2, 3].collect(&:count).sum(10)
2838
+ #
2839
+ # # good
2840
+ # [1, 2, 3].sum(10)
2841
+ # [1, 2, 3].sum { |elem| elem ** 2 }
2842
+ # [1, 2, 3].sum(10, &:count)
2843
+ #
2844
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#70
2845
+ class RuboCop::Cop::Performance::Sum < ::RuboCop::Cop::Base
2846
+ include ::RuboCop::Cop::RangeHelp
2847
+ extend ::RuboCop::Cop::AutoCorrector
2848
+ extend ::RuboCop::Cop::TargetRubyVersion
2849
+
2850
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#102
2851
+ def acc_plus_elem?(param0 = T.unsafe(nil), param1, param2); end
2852
+
2853
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#102
2854
+ def elem_plus_acc?(param0 = T.unsafe(nil), param1, param2); end
2855
+
2856
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#114
2857
+ def on_block(node); end
2858
+
2859
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#107
2860
+ def on_send(node); end
2861
+
2862
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#82
2863
+ def sum_candidate?(param0 = T.unsafe(nil)); end
2864
+
2865
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#86
2866
+ def sum_map_candidate?(param0 = T.unsafe(nil)); end
2867
+
2868
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#95
2869
+ def sum_with_block_candidate?(param0 = T.unsafe(nil)); end
2870
+
2871
+ private
2872
+
2873
+ # @return [Boolean]
2874
+ #
2875
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#159
2876
+ def array_literal?(node); end
2877
+
2878
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#164
2879
+ def autocorrect(corrector, init, range); end
2880
+
2881
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#172
2882
+ def autocorrect_sum_map(corrector, sum, map, init); end
2883
+
2884
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#248
2885
+ def build_block_bad_method(method, init, var_acc, var_elem, body); end
2886
+
2887
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#215
2888
+ def build_block_message(send, init, var_acc, var_elem, body); end
2889
+
2890
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#221
2891
+ def build_good_method(init, block_pass = T.unsafe(nil)); end
2892
+
2893
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#234
2894
+ def build_method_bad_method(init, method, operation); end
2895
+
2896
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#197
2897
+ def build_method_message(node, method, init, operation); end
2898
+
2899
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#208
2900
+ def build_sum_map_message(method, init); end
2901
+
2902
+ # @return [Boolean]
2903
+ #
2904
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#154
2905
+ def empty_array_literal?(node); end
2906
+
2907
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#129
2908
+ def handle_sum_candidate(node); end
2909
+
2910
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#142
2911
+ def handle_sum_map_candidate(node); end
2912
+
2913
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#259
2914
+ def method_call_with_args_range(node); end
2915
+
2916
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#193
2917
+ def sum_block_range(send, node); end
2918
+
2919
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#189
2920
+ def sum_map_range(map, sum); end
2921
+
2922
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#185
2923
+ def sum_method_range(node); end
2924
+ end
2925
+
2926
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#77
2927
+ RuboCop::Cop::Performance::Sum::MSG = T.let(T.unsafe(nil), String)
2928
+
2929
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#78
2930
+ RuboCop::Cop::Performance::Sum::MSG_IF_NO_INIT_VALUE = T.let(T.unsafe(nil), String)
2931
+
2932
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#80
2933
+ RuboCop::Cop::Performance::Sum::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2934
+
2935
+ # Checks for .times.map calls.
2936
+ # In most cases such calls can be replaced
2937
+ # with an explicit array creation.
2938
+ #
2939
+ # @example
2940
+ # # bad
2941
+ # 9.times.map do |i|
2942
+ # i.to_s
2943
+ # end
2944
+ #
2945
+ # # good
2946
+ # Array.new(9) do |i|
2947
+ # i.to_s
2948
+ # end
2949
+ #
2950
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#32
2951
+ class RuboCop::Cop::Performance::TimesMap < ::RuboCop::Cop::Base
2952
+ extend ::RuboCop::Cop::AutoCorrector
2953
+
2954
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#43
2955
+ def on_block(node); end
2956
+
2957
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#43
2958
+ def on_numblock(node); end
2959
+
2960
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#39
2961
+ def on_send(node); end
2962
+
2963
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#69
2964
+ def times_map_call(param0 = T.unsafe(nil)); end
2965
+
2966
+ private
2967
+
2968
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#50
2969
+ def check(node); end
2970
+
2971
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#60
2972
+ def message(map_or_collect, count); end
2973
+ end
2974
+
2975
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#35
2976
+ RuboCop::Cop::Performance::TimesMap::MESSAGE = T.let(T.unsafe(nil), String)
2977
+
2978
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#36
2979
+ RuboCop::Cop::Performance::TimesMap::MESSAGE_ONLY_IF = T.let(T.unsafe(nil), String)
2980
+
2981
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#37
2982
+ RuboCop::Cop::Performance::TimesMap::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2983
+
2984
+ # In Ruby 2.3 or later, use unary plus operator to unfreeze a string
2985
+ # literal instead of `String#dup` and `String.new`.
2986
+ # Unary plus operator is faster than `String#dup`.
2987
+ #
2988
+ # @example
2989
+ # # bad
2990
+ # ''.dup
2991
+ # "something".dup
2992
+ # String.new
2993
+ # String.new('')
2994
+ # String.new('something')
2995
+ #
2996
+ # # good
2997
+ # +'something'
2998
+ # +''
2999
+ #
3000
+ # source://rubocop-performance//lib/rubocop/cop/performance/unfreeze_string.rb#27
3001
+ class RuboCop::Cop::Performance::UnfreezeString < ::RuboCop::Cop::Base
3002
+ extend ::RuboCop::Cop::AutoCorrector
3003
+
3004
+ # source://rubocop-performance//lib/rubocop/cop/performance/unfreeze_string.rb#33
3005
+ def dup_string?(param0 = T.unsafe(nil)); end
3006
+
3007
+ # source://rubocop-performance//lib/rubocop/cop/performance/unfreeze_string.rb#44
3008
+ def on_send(node); end
3009
+
3010
+ # source://rubocop-performance//lib/rubocop/cop/performance/unfreeze_string.rb#37
3011
+ def string_new?(param0 = T.unsafe(nil)); end
3012
+
3013
+ private
3014
+
3015
+ # source://rubocop-performance//lib/rubocop/cop/performance/unfreeze_string.rb#57
3016
+ def string_value(node); end
3017
+ end
3018
+
3019
+ # source://rubocop-performance//lib/rubocop/cop/performance/unfreeze_string.rb#30
3020
+ RuboCop::Cop::Performance::UnfreezeString::MSG = T.let(T.unsafe(nil), String)
3021
+
3022
+ # source://rubocop-performance//lib/rubocop/cop/performance/unfreeze_string.rb#31
3023
+ RuboCop::Cop::Performance::UnfreezeString::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
3024
+
3025
+ # Identifies places where `URI::Parser.new` can be replaced by `URI::DEFAULT_PARSER`.
3026
+ #
3027
+ # @example
3028
+ # # bad
3029
+ # URI::Parser.new
3030
+ #
3031
+ # # good
3032
+ # URI::DEFAULT_PARSER
3033
+ #
3034
+ # source://rubocop-performance//lib/rubocop/cop/performance/uri_default_parser.rb#15
3035
+ class RuboCop::Cop::Performance::UriDefaultParser < ::RuboCop::Cop::Base
3036
+ extend ::RuboCop::Cop::AutoCorrector
3037
+
3038
+ # source://rubocop-performance//lib/rubocop/cop/performance/uri_default_parser.rb#27
3039
+ def on_send(node); end
3040
+
3041
+ # source://rubocop-performance//lib/rubocop/cop/performance/uri_default_parser.rb#21
3042
+ def uri_parser_new?(param0 = T.unsafe(nil)); end
3043
+ end
3044
+
3045
+ # source://rubocop-performance//lib/rubocop/cop/performance/uri_default_parser.rb#18
3046
+ RuboCop::Cop::Performance::UriDefaultParser::MSG = T.let(T.unsafe(nil), String)
3047
+
3048
+ # source://rubocop-performance//lib/rubocop/cop/performance/uri_default_parser.rb#19
3049
+ RuboCop::Cop::Performance::UriDefaultParser::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
3050
+
3051
+ # Common functionality for handling regexp metacharacters.
3052
+ #
3053
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#6
3054
+ module RuboCop::Cop::RegexpMetacharacter
3055
+ private
3056
+
3057
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#63
3058
+ def drop_end_metacharacter(regexp_string); end
3059
+
3060
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#55
3061
+ def drop_start_metacharacter(regexp_string); end
3062
+
3063
+ # @return [Boolean]
3064
+ #
3065
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#15
3066
+ def literal_at_end?(regexp); end
3067
+
3068
+ # @return [Boolean]
3069
+ #
3070
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#41
3071
+ def literal_at_end_with_backslash_z?(regex_str); end
3072
+
3073
+ # @return [Boolean]
3074
+ #
3075
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#48
3076
+ def literal_at_end_with_dollar?(regex_str); end
3077
+
3078
+ # @return [Boolean]
3079
+ #
3080
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#9
3081
+ def literal_at_start?(regexp); end
3082
+
3083
+ # @return [Boolean]
3084
+ #
3085
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#21
3086
+ def literal_at_start_with_backslash_a?(regex_str); end
3087
+
3088
+ # @return [Boolean]
3089
+ #
3090
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#31
3091
+ def literal_at_start_with_caret?(regex_str); end
3092
+
3093
+ # @return [Boolean]
3094
+ #
3095
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#71
3096
+ def safe_multiline?; end
3097
+ end
3098
+
3099
+ # Common functionality for cops checking `Enumerable#sort` blocks.
3100
+ #
3101
+ # source://rubocop-performance//lib/rubocop/cop/mixin/sort_block.rb#6
3102
+ module RuboCop::Cop::SortBlock
3103
+ include ::RuboCop::Cop::RangeHelp
3104
+ extend ::RuboCop::AST::NodePattern::Macros
3105
+
3106
+ # source://rubocop-performance//lib/rubocop/cop/mixin/sort_block.rb#24
3107
+ def replaceable_body?(param0 = T.unsafe(nil), param1, param2); end
3108
+
3109
+ # source://rubocop-performance//lib/rubocop/cop/mixin/sort_block.rb#10
3110
+ def sort_with_block?(param0 = T.unsafe(nil)); end
3111
+
3112
+ # source://rubocop-performance//lib/rubocop/cop/mixin/sort_block.rb#17
3113
+ def sort_with_numblock?(param0 = T.unsafe(nil)); end
3114
+
3115
+ private
3116
+
3117
+ # source://rubocop-performance//lib/rubocop/cop/mixin/sort_block.rb#30
3118
+ def sort_range(send, node); end
3119
+ end
3120
+
3121
+ # RuboCop Performance project namespace
3122
+ #
3123
+ # source://rubocop-performance//lib/rubocop/performance.rb#5
3124
+ module RuboCop::Performance; end
3125
+
3126
+ # source://rubocop-performance//lib/rubocop/performance.rb#8
3127
+ RuboCop::Performance::CONFIG = T.let(T.unsafe(nil), Hash)
3128
+
3129
+ # source://rubocop-performance//lib/rubocop/performance.rb#7
3130
+ RuboCop::Performance::CONFIG_DEFAULT = T.let(T.unsafe(nil), Pathname)
3131
+
3132
+ # Because RuboCop doesn't yet support plugins, we have to monkey patch in a
3133
+ # bit of our configuration.
3134
+ #
3135
+ # source://rubocop-performance//lib/rubocop/performance/inject.rb#7
3136
+ module RuboCop::Performance::Inject
3137
+ class << self
3138
+ # source://rubocop-performance//lib/rubocop/performance/inject.rb#8
3139
+ def defaults!; end
3140
+ end
3141
+ end
3142
+
3143
+ # source://rubocop-performance//lib/rubocop/performance.rb#6
3144
+ RuboCop::Performance::PROJECT_ROOT = T.let(T.unsafe(nil), Pathname)
3145
+
3146
+ # This module holds the RuboCop Performance version information.
3147
+ #
3148
+ # source://rubocop-performance//lib/rubocop/performance/version.rb#6
3149
+ module RuboCop::Performance::Version
3150
+ class << self
3151
+ # source://rubocop-performance//lib/rubocop/performance/version.rb#9
3152
+ def document_version; end
3153
+ end
3154
+ end
3155
+
3156
+ # source://rubocop-performance//lib/rubocop/performance/version.rb#7
3157
+ RuboCop::Performance::Version::STRING = T.let(T.unsafe(nil), String)