hierarchical_config 0.11 → 0.13

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