openfeature-sdk-sorbet 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/.DS_Store +0 -0
  3. data/.rubocop.yml +42 -0
  4. data/.ruby-version +1 -0
  5. data/.tool-versions +1 -0
  6. data/CHANGELOG.md +15 -0
  7. data/CODE_OF_CONDUCT.md +84 -0
  8. data/Gemfile +25 -0
  9. data/Gemfile.lock +113 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +115 -0
  12. data/Rakefile +24 -0
  13. data/lib/open_feature/client.rb +180 -0
  14. data/lib/open_feature/client_metadata.rb +9 -0
  15. data/lib/open_feature/configuration.rb +47 -0
  16. data/lib/open_feature/error_code.rb +17 -0
  17. data/lib/open_feature/evaluation_context.rb +10 -0
  18. data/lib/open_feature/evaluation_details.rb +56 -0
  19. data/lib/open_feature/evaluation_options.rb +9 -0
  20. data/lib/open_feature/flag_metadata.rb +6 -0
  21. data/lib/open_feature/hook.rb +6 -0
  22. data/lib/open_feature/no_op_provider.rb +77 -0
  23. data/lib/open_feature/provider.rb +61 -0
  24. data/lib/open_feature/provider_metadata.rb +11 -0
  25. data/lib/open_feature/resolution_details.rb +20 -0
  26. data/lib/open_feature.rb +40 -0
  27. data/sorbet/config +4 -0
  28. data/sorbet/rbi/annotations/rainbow.rbi +269 -0
  29. data/sorbet/rbi/gems/ast@2.4.2.rbi +584 -0
  30. data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +1083 -0
  31. data/sorbet/rbi/gems/io-console@0.6.0.rbi +8 -0
  32. data/sorbet/rbi/gems/irb@1.6.4.rbi +342 -0
  33. data/sorbet/rbi/gems/json@2.6.3.rbi +1533 -0
  34. data/sorbet/rbi/gems/minitest@5.18.0.rbi +2153 -0
  35. data/sorbet/rbi/gems/netrc@0.11.0.rbi +158 -0
  36. data/sorbet/rbi/gems/parallel@1.23.0.rbi +273 -0
  37. data/sorbet/rbi/gems/parser@3.2.2.1.rbi +7253 -0
  38. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +402 -0
  39. data/sorbet/rbi/gems/rake@13.0.6.rbi +3024 -0
  40. data/sorbet/rbi/gems/rbi@0.0.16.rbi +3049 -0
  41. data/sorbet/rbi/gems/regexp_parser@2.8.0.rbi +3748 -0
  42. data/sorbet/rbi/gems/reline@0.3.3.rbi +8 -0
  43. data/sorbet/rbi/gems/rexml@3.2.5.rbi +4717 -0
  44. data/sorbet/rbi/gems/rubocop-ast@1.28.1.rbi +6990 -0
  45. data/sorbet/rbi/gems/rubocop-minitest@0.31.0.rbi +2528 -0
  46. data/sorbet/rbi/gems/rubocop-performance@1.17.1.rbi +3036 -0
  47. data/sorbet/rbi/gems/rubocop-rake@0.6.0.rbi +328 -0
  48. data/sorbet/rbi/gems/rubocop-sorbet@0.7.0.rbi +1043 -0
  49. data/sorbet/rbi/gems/rubocop@1.51.0.rbi +55316 -0
  50. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1317 -0
  51. data/sorbet/rbi/gems/sorbet-struct-comparable@1.3.0.rbi +34 -0
  52. data/sorbet/rbi/gems/spoom@1.2.1.rbi +2536 -0
  53. data/sorbet/rbi/gems/tapioca@0.11.6.rbi +3301 -0
  54. data/sorbet/rbi/gems/thor@1.2.2.rbi +3965 -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/yard-sorbet@0.8.1.rbi +428 -0
  58. data/sorbet/rbi/gems/yard@0.9.34.rbi +18219 -0
  59. data/sorbet/rbi/gems/zeitwerk@2.6.8.rbi +986 -0
  60. data/sorbet/tapioca/config.yml +4 -0
  61. data/sorbet/tapioca/require.rb +8 -0
  62. metadata +150 -0
@@ -0,0 +1,3036 @@
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#30
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#41
929
+ def detect_candidate?(param0 = T.unsafe(nil)); end
930
+
931
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#50
932
+ def on_send(node); end
933
+
934
+ private
935
+
936
+ # @return [Boolean]
937
+ #
938
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#69
939
+ def accept_first_call?(receiver, body); end
940
+
941
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#101
942
+ def autocorrect(corrector, node, replacement); end
943
+
944
+ # @return [Boolean]
945
+ #
946
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#127
947
+ def lazy?(node); end
948
+
949
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#112
950
+ def message_for_method(method, index); end
951
+
952
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#123
953
+ def preferred_method; end
954
+
955
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#78
956
+ def register_offense(node, receiver, second_method, index); end
957
+
958
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#93
959
+ def replacement(method, index); end
960
+ end
961
+
962
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#33
963
+ RuboCop::Cop::Performance::Detect::CANDIDATE_METHODS = T.let(T.unsafe(nil), Set)
964
+
965
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#37
966
+ RuboCop::Cop::Performance::Detect::INDEX_MSG = T.let(T.unsafe(nil), String)
967
+
968
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#38
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#35
972
+ RuboCop::Cop::Performance::Detect::MSG = T.let(T.unsafe(nil), String)
973
+
974
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#39
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#36
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#72
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
+ # This cop has `AllowRegexpMatch` option and it is true by default because
1617
+ # `regexp.match?('string')` often used in block changes to the opposite result:
1618
+ #
1619
+ # [source,ruby]
1620
+ # ----
1621
+ # [/pattern/].all? { |regexp| regexp.match?('pattern') } # => true
1622
+ # [/pattern/].all? { |regexp| regexp =~ 'pattern' } # => true
1623
+ # [/pattern/].all?('pattern') # => false
1624
+ # ----
1625
+ #
1626
+ # @example
1627
+ # # bad
1628
+ # items.all? { |item| pattern === item }
1629
+ # items.all? { |item| item == other }
1630
+ # items.all? { |item| item.is_a?(Klass) }
1631
+ # items.all? { |item| item.kind_of?(Klass) }
1632
+ #
1633
+ # # good
1634
+ # items.all?(pattern)
1635
+ # items.all?(Klass)
1636
+ # @example AllowRegexpMatch: true (default)
1637
+ #
1638
+ # # good
1639
+ # items.all? { |item| item =~ pattern }
1640
+ # items.all? { |item| item.match?(pattern) }
1641
+ # @example AllowRegexpMatch: false
1642
+ #
1643
+ # # bad
1644
+ # items.all? { |item| item =~ pattern }
1645
+ # items.all? { |item| item.match?(pattern) }
1646
+ #
1647
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#49
1648
+ class RuboCop::Cop::Performance::RedundantEqualityComparisonBlock < ::RuboCop::Cop::Base
1649
+ extend ::RuboCop::Cop::AutoCorrector
1650
+ extend ::RuboCop::Cop::TargetRubyVersion
1651
+
1652
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#62
1653
+ def on_block(node); end
1654
+
1655
+ private
1656
+
1657
+ # @return [Boolean]
1658
+ #
1659
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#131
1660
+ def allow_regexp_match?; end
1661
+
1662
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#104
1663
+ def new_argument(block_argument, block_body); end
1664
+
1665
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#127
1666
+ def offense_range(node); end
1667
+
1668
+ # @return [Boolean]
1669
+ #
1670
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#82
1671
+ def one_block_argument?(block_arguments); end
1672
+
1673
+ # @return [Boolean]
1674
+ #
1675
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#94
1676
+ def same_block_argument_and_is_a_argument?(block_body, block_argument); end
1677
+
1678
+ # @return [Boolean]
1679
+ #
1680
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#118
1681
+ def use_block_argument_in_method_argument_of_operand?(block_argument, operand); end
1682
+
1683
+ # @return [Boolean]
1684
+ #
1685
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#86
1686
+ def use_equality_comparison_block?(block_body); end
1687
+ end
1688
+
1689
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#58
1690
+ RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::COMPARISON_METHODS = T.let(T.unsafe(nil), Array)
1691
+
1692
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#60
1693
+ RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::IS_A_METHODS = T.let(T.unsafe(nil), Array)
1694
+
1695
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#55
1696
+ RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::MSG = T.let(T.unsafe(nil), String)
1697
+
1698
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#59
1699
+ RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::REGEXP_METHODS = T.let(T.unsafe(nil), Array)
1700
+
1701
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#57
1702
+ RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::TARGET_METHODS = T.let(T.unsafe(nil), Array)
1703
+
1704
+ # Identifies the use of `Regexp#match` or `String#match`, which
1705
+ # returns `#<MatchData>`/`nil`. The return value of `=~` is an integral
1706
+ # index/`nil` and is more performant.
1707
+ #
1708
+ # @example
1709
+ # # bad
1710
+ # do_something if str.match(/regex/)
1711
+ # while regex.match('str')
1712
+ # do_something
1713
+ # end
1714
+ #
1715
+ # # good
1716
+ # method(str =~ /regex/)
1717
+ # return value unless regex =~ 'str'
1718
+ #
1719
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#20
1720
+ class RuboCop::Cop::Performance::RedundantMatch < ::RuboCop::Cop::Base
1721
+ extend ::RuboCop::Cop::AutoCorrector
1722
+
1723
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#28
1724
+ def match_call?(param0 = T.unsafe(nil)); end
1725
+
1726
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#37
1727
+ def on_send(node); end
1728
+
1729
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#33
1730
+ def only_truthiness_matters?(param0 = T.unsafe(nil)); end
1731
+
1732
+ private
1733
+
1734
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#49
1735
+ def autocorrect(corrector, node); end
1736
+
1737
+ # @return [Boolean]
1738
+ #
1739
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#55
1740
+ def autocorrectable?(node); end
1741
+ end
1742
+
1743
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#23
1744
+ RuboCop::Cop::Performance::RedundantMatch::MSG = T.let(T.unsafe(nil), String)
1745
+
1746
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#24
1747
+ RuboCop::Cop::Performance::RedundantMatch::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1748
+
1749
+ # Identifies places where `Hash#merge!` can be replaced by `Hash#[]=`.
1750
+ # You can set the maximum number of key-value pairs to consider
1751
+ # an offense with `MaxKeyValuePairs`.
1752
+ #
1753
+ # @example
1754
+ # # bad
1755
+ # hash.merge!(a: 1)
1756
+ # hash.merge!({'key' => 'value'})
1757
+ #
1758
+ # # good
1759
+ # hash[:a] = 1
1760
+ # hash['key'] = 'value'
1761
+ # @example MaxKeyValuePairs: 2 (default)
1762
+ # # bad
1763
+ # hash.merge!(a: 1, b: 2)
1764
+ #
1765
+ # # good
1766
+ # hash[:a] = 1
1767
+ # hash[:b] = 2
1768
+ #
1769
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#30
1770
+ class RuboCop::Cop::Performance::RedundantMerge < ::RuboCop::Cop::Base
1771
+ include ::RuboCop::Cop::Alignment
1772
+ extend ::RuboCop::Cop::AutoCorrector
1773
+
1774
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#48
1775
+ def modifier_flow_control?(param0 = T.unsafe(nil)); end
1776
+
1777
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#52
1778
+ def on_send(node); end
1779
+
1780
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#44
1781
+ def redundant_merge_candidate(param0 = T.unsafe(nil)); end
1782
+
1783
+ private
1784
+
1785
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#106
1786
+ def correct_multiple_elements(corrector, node, parent, new_source); end
1787
+
1788
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#118
1789
+ def correct_single_element(corrector, node, new_source); end
1790
+
1791
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#79
1792
+ def each_redundant_merge(node); end
1793
+
1794
+ # @return [Boolean]
1795
+ #
1796
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#98
1797
+ def kwsplat_used?(pairs); end
1798
+
1799
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#144
1800
+ def leading_spaces(node); end
1801
+
1802
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#148
1803
+ def max_key_value_pairs; end
1804
+
1805
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#71
1806
+ def message(node); end
1807
+
1808
+ # @return [Boolean]
1809
+ #
1810
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#87
1811
+ def non_redundant_merge?(node, receiver, pairs); end
1812
+
1813
+ # @return [Boolean]
1814
+ #
1815
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#94
1816
+ def non_redundant_pairs?(receiver, pairs); end
1817
+
1818
+ # @return [Boolean]
1819
+ #
1820
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#102
1821
+ def non_redundant_value_used?(receiver, node); end
1822
+
1823
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#132
1824
+ def rewrite_with_modifier(node, parent, new_source); end
1825
+
1826
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#122
1827
+ def to_assignments(receiver, pairs); end
1828
+ end
1829
+
1830
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#34
1831
+ RuboCop::Cop::Performance::RedundantMerge::AREF_ASGN = T.let(T.unsafe(nil), String)
1832
+
1833
+ # A utility class for checking the use of values within an
1834
+ # `each_with_object` call.
1835
+ #
1836
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#154
1837
+ class RuboCop::Cop::Performance::RedundantMerge::EachWithObjectInspector
1838
+ extend ::RuboCop::AST::NodePattern::Macros
1839
+
1840
+ # @return [EachWithObjectInspector] a new instance of EachWithObjectInspector
1841
+ #
1842
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#157
1843
+ def initialize(node, receiver); end
1844
+
1845
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#188
1846
+ def each_with_object_node(param0 = T.unsafe(nil)); end
1847
+
1848
+ # @return [Boolean]
1849
+ #
1850
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#162
1851
+ def value_used?; end
1852
+
1853
+ private
1854
+
1855
+ # @return [Boolean]
1856
+ #
1857
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#172
1858
+ def eligible_receiver?; end
1859
+
1860
+ # Returns the value of attribute node.
1861
+ #
1862
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#170
1863
+ def node; end
1864
+
1865
+ # Returns the value of attribute receiver.
1866
+ #
1867
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#170
1868
+ def receiver; end
1869
+
1870
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#176
1871
+ def second_argument; end
1872
+
1873
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#183
1874
+ def unwind(receiver); end
1875
+ end
1876
+
1877
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#35
1878
+ RuboCop::Cop::Performance::RedundantMerge::MSG = T.let(T.unsafe(nil), String)
1879
+
1880
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#36
1881
+ RuboCop::Cop::Performance::RedundantMerge::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1882
+
1883
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#38
1884
+ RuboCop::Cop::Performance::RedundantMerge::WITH_MODIFIER_CORRECTION = T.let(T.unsafe(nil), String)
1885
+
1886
+ # Identifies places where `sort { |a, b| a <=> b }` can be replaced with `sort`.
1887
+ #
1888
+ # @example
1889
+ # # bad
1890
+ # array.sort { |a, b| a <=> b }
1891
+ #
1892
+ # # good
1893
+ # array.sort
1894
+ #
1895
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_sort_block.rb#15
1896
+ class RuboCop::Cop::Performance::RedundantSortBlock < ::RuboCop::Cop::Base
1897
+ include ::RuboCop::Cop::RangeHelp
1898
+ include ::RuboCop::Cop::SortBlock
1899
+ extend ::RuboCop::Cop::AutoCorrector
1900
+
1901
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_sort_block.rb#21
1902
+ def on_block(node); end
1903
+
1904
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_sort_block.rb#29
1905
+ def on_numblock(node); end
1906
+
1907
+ private
1908
+
1909
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_sort_block.rb#40
1910
+ def register_offense(send, node); end
1911
+ end
1912
+
1913
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_sort_block.rb#19
1914
+ RuboCop::Cop::Performance::RedundantSortBlock::MSG = T.let(T.unsafe(nil), String)
1915
+
1916
+ # Identifies places where `split` argument can be replaced from
1917
+ # a deterministic regexp to a string.
1918
+ #
1919
+ # @example
1920
+ # # bad
1921
+ # 'a,b,c'.split(/,/)
1922
+ #
1923
+ # # good
1924
+ # 'a,b,c'.split(',')
1925
+ #
1926
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#15
1927
+ class RuboCop::Cop::Performance::RedundantSplitRegexpArgument < ::RuboCop::Cop::Base
1928
+ extend ::RuboCop::Cop::AutoCorrector
1929
+
1930
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#27
1931
+ def on_send(node); end
1932
+
1933
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#23
1934
+ def split_call_with_regexp?(param0 = T.unsafe(nil)); end
1935
+
1936
+ private
1937
+
1938
+ # @return [Boolean]
1939
+ #
1940
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#41
1941
+ def determinist_regexp?(regexp_node); end
1942
+
1943
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#45
1944
+ def replacement(regexp_node); end
1945
+ end
1946
+
1947
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#20
1948
+ RuboCop::Cop::Performance::RedundantSplitRegexpArgument::DETERMINISTIC_REGEX = T.let(T.unsafe(nil), Regexp)
1949
+
1950
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#18
1951
+ RuboCop::Cop::Performance::RedundantSplitRegexpArgument::MSG = T.let(T.unsafe(nil), String)
1952
+
1953
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#19
1954
+ RuboCop::Cop::Performance::RedundantSplitRegexpArgument::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1955
+
1956
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#21
1957
+ RuboCop::Cop::Performance::RedundantSplitRegexpArgument::STR_SPECIAL_CHARS = T.let(T.unsafe(nil), Array)
1958
+
1959
+ # Checks for redundant `String#chars`.
1960
+ #
1961
+ # @example
1962
+ # # bad
1963
+ # str.chars[0..2]
1964
+ # str.chars.slice(0..2)
1965
+ # str.chars.last
1966
+ #
1967
+ # # good
1968
+ # str[0..2].chars
1969
+ #
1970
+ # # bad
1971
+ # str.chars.first
1972
+ # str.chars.first(2)
1973
+ #
1974
+ # # good
1975
+ # str[0]
1976
+ # str[0...2].chars
1977
+ # str[-1]
1978
+ #
1979
+ # # bad
1980
+ # str.chars.take(2)
1981
+ # str.chars.length
1982
+ # str.chars.size
1983
+ # str.chars.empty?
1984
+ #
1985
+ # # good
1986
+ # str[0...2].chars
1987
+ # str.length
1988
+ # str.size
1989
+ # str.empty?
1990
+ #
1991
+ # # For example, if the receiver is an empty string, it will be incompatible.
1992
+ # # If a negative value is specified for the receiver, `nil` is returned.
1993
+ # str.chars.last(2) # Incompatible with `str[-2..-1].chars`.
1994
+ # str.chars.drop(2) # Incompatible with `str[2..-1].chars`.
1995
+ #
1996
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#43
1997
+ class RuboCop::Cop::Performance::RedundantStringChars < ::RuboCop::Cop::Base
1998
+ include ::RuboCop::Cop::RangeHelp
1999
+ extend ::RuboCop::Cop::AutoCorrector
2000
+
2001
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#54
2002
+ def on_send(node); end
2003
+
2004
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#50
2005
+ def redundant_chars_call?(param0 = T.unsafe(nil)); end
2006
+
2007
+ private
2008
+
2009
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#112
2010
+ def build_bad_method(method, args); end
2011
+
2012
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#125
2013
+ def build_call_args(call_args_node); end
2014
+
2015
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#85
2016
+ def build_good_method(method, args); end
2017
+
2018
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#100
2019
+ def build_good_method_for_brackets_or_first_method(method, args); end
2020
+
2021
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#79
2022
+ def build_message(method, args); end
2023
+
2024
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#75
2025
+ def correction_range(receiver, node); end
2026
+
2027
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#71
2028
+ def offense_range(receiver, node); end
2029
+ end
2030
+
2031
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#47
2032
+ RuboCop::Cop::Performance::RedundantStringChars::MSG = T.let(T.unsafe(nil), String)
2033
+
2034
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#48
2035
+ RuboCop::Cop::Performance::RedundantStringChars::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2036
+
2037
+ # In Ruby 2.4, `String#match?`, `Regexp#match?`, and `Symbol#match?`
2038
+ # have been added. The methods are faster than `match`.
2039
+ # Because the methods avoid creating a `MatchData` object or saving
2040
+ # backref.
2041
+ # So, when `MatchData` is not used, use `match?` instead of `match`.
2042
+ #
2043
+ # @example
2044
+ # # bad
2045
+ # def foo
2046
+ # if x =~ /re/
2047
+ # do_something
2048
+ # end
2049
+ # end
2050
+ #
2051
+ # # bad
2052
+ # def foo
2053
+ # if x !~ /re/
2054
+ # do_something
2055
+ # end
2056
+ # end
2057
+ #
2058
+ # # bad
2059
+ # def foo
2060
+ # if x.match(/re/)
2061
+ # do_something
2062
+ # end
2063
+ # end
2064
+ #
2065
+ # # bad
2066
+ # def foo
2067
+ # if /re/ === x
2068
+ # do_something
2069
+ # end
2070
+ # end
2071
+ #
2072
+ # # good
2073
+ # def foo
2074
+ # if x.match?(/re/)
2075
+ # do_something
2076
+ # end
2077
+ # end
2078
+ #
2079
+ # # good
2080
+ # def foo
2081
+ # if !x.match?(/re/)
2082
+ # do_something
2083
+ # end
2084
+ # end
2085
+ #
2086
+ # # good
2087
+ # def foo
2088
+ # if x =~ /re/
2089
+ # do_something(Regexp.last_match)
2090
+ # end
2091
+ # end
2092
+ #
2093
+ # # good
2094
+ # def foo
2095
+ # if x.match(/re/)
2096
+ # do_something($~)
2097
+ # end
2098
+ # end
2099
+ #
2100
+ # # good
2101
+ # def foo
2102
+ # if /re/ === x
2103
+ # do_something($~)
2104
+ # end
2105
+ # end
2106
+ #
2107
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#75
2108
+ class RuboCop::Cop::Performance::RegexpMatch < ::RuboCop::Cop::Base
2109
+ extend ::RuboCop::Cop::AutoCorrector
2110
+ extend ::RuboCop::Cop::TargetRubyVersion
2111
+
2112
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#125
2113
+ def last_matches(param0); end
2114
+
2115
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#86
2116
+ def match_method?(param0 = T.unsafe(nil)); end
2117
+
2118
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#122
2119
+ def match_node?(param0 = T.unsafe(nil)); end
2120
+
2121
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#97
2122
+ def match_operator?(param0 = T.unsafe(nil)); end
2123
+
2124
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#101
2125
+ def match_threequals?(param0 = T.unsafe(nil)); end
2126
+
2127
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#93
2128
+ def match_with_int_arg_method?(param0 = T.unsafe(nil)); end
2129
+
2130
+ # @return [Boolean]
2131
+ #
2132
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#105
2133
+ def match_with_lvasgn?(node); end
2134
+
2135
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#138
2136
+ def on_case(node); end
2137
+
2138
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#134
2139
+ def on_if(node); end
2140
+
2141
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#123
2142
+ def search_match_nodes(param0); end
2143
+
2144
+ private
2145
+
2146
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#161
2147
+ def autocorrect(corrector, node); end
2148
+
2149
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#150
2150
+ def check_condition(cond); end
2151
+
2152
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#246
2153
+ def correct_operator(corrector, recv, arg, oper = T.unsafe(nil)); end
2154
+
2155
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#271
2156
+ def correction_range(recv, arg); end
2157
+
2158
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#217
2159
+ def find_last_match(body, range, scope_root); end
2160
+
2161
+ # @return [Boolean]
2162
+ #
2163
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#177
2164
+ def last_match_used?(match_node); end
2165
+
2166
+ # @return [Boolean]
2167
+ #
2168
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#242
2169
+ def match_gvar?(sym); end
2170
+
2171
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#173
2172
+ def message(node); end
2173
+
2174
+ # @return [Boolean]
2175
+ #
2176
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#213
2177
+ def modifier_form?(match_node); end
2178
+
2179
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#199
2180
+ def next_match_pos(body, match_node_pos, scope_root); end
2181
+
2182
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#186
2183
+ def range_to_search_for_last_matches(match_node, body, scope_root); end
2184
+
2185
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#255
2186
+ def replace_with_match_predicate_method(corrector, recv, arg, op_range); end
2187
+
2188
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#224
2189
+ def scope_body(node); end
2190
+
2191
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#236
2192
+ def scope_root(node); end
2193
+
2194
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#266
2195
+ def swap_receiver_and_arg(corrector, recv, arg); end
2196
+ end
2197
+
2198
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#112
2199
+ RuboCop::Cop::Performance::RegexpMatch::MATCH_NODE_PATTERN = T.let(T.unsafe(nil), String)
2200
+
2201
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#84
2202
+ RuboCop::Cop::Performance::RegexpMatch::MSG = T.let(T.unsafe(nil), String)
2203
+
2204
+ # Constants are included in this list because it is unlikely that
2205
+ # someone will store `nil` as a constant and then use it for comparison
2206
+ #
2207
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#83
2208
+ RuboCop::Cop::Performance::RegexpMatch::TYPES_IMPLEMENTING_MATCH = T.let(T.unsafe(nil), Array)
2209
+
2210
+ # Identifies usages of `reverse.each` and change them to use `reverse_each` instead.
2211
+ #
2212
+ # If the return value is used, it will not be detected because the result will be different.
2213
+ #
2214
+ # [source,ruby]
2215
+ # ----
2216
+ # [1, 2, 3].reverse.each {} #=> [3, 2, 1]
2217
+ # [1, 2, 3].reverse_each {} #=> [1, 2, 3]
2218
+ # ----
2219
+ #
2220
+ # @example
2221
+ # # bad
2222
+ # items.reverse.each
2223
+ #
2224
+ # # good
2225
+ # items.reverse_each
2226
+ #
2227
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#22
2228
+ class RuboCop::Cop::Performance::ReverseEach < ::RuboCop::Cop::Base
2229
+ include ::RuboCop::Cop::RangeHelp
2230
+ extend ::RuboCop::Cop::AutoCorrector
2231
+
2232
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#33
2233
+ def on_send(node); end
2234
+
2235
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#29
2236
+ def reverse_each?(param0 = T.unsafe(nil)); end
2237
+
2238
+ private
2239
+
2240
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#53
2241
+ def offense_range(node); end
2242
+
2243
+ # @return [Boolean]
2244
+ #
2245
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#47
2246
+ def use_return_value?(node); end
2247
+ end
2248
+
2249
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#26
2250
+ RuboCop::Cop::Performance::ReverseEach::MSG = T.let(T.unsafe(nil), String)
2251
+
2252
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#27
2253
+ RuboCop::Cop::Performance::ReverseEach::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2254
+
2255
+ # Identifies places where `reverse.first(n)` and `reverse.first`
2256
+ # can be replaced by `last(n).reverse` and `last`.
2257
+ #
2258
+ # @example
2259
+ #
2260
+ # # bad
2261
+ # array.reverse.first(5)
2262
+ # array.reverse.first
2263
+ #
2264
+ # # good
2265
+ # array.last(5).reverse
2266
+ # array.last
2267
+ #
2268
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#19
2269
+ class RuboCop::Cop::Performance::ReverseFirst < ::RuboCop::Cop::Base
2270
+ include ::RuboCop::Cop::RangeHelp
2271
+ extend ::RuboCop::Cop::AutoCorrector
2272
+
2273
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#30
2274
+ def on_send(node); end
2275
+
2276
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#26
2277
+ def reverse_first_candidate?(param0 = T.unsafe(nil)); end
2278
+
2279
+ private
2280
+
2281
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#63
2282
+ def build_bad_method(node); end
2283
+
2284
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#55
2285
+ def build_good_method(node); end
2286
+
2287
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#49
2288
+ def build_message(node); end
2289
+
2290
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#45
2291
+ def correction_range(receiver, node); end
2292
+ end
2293
+
2294
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#23
2295
+ RuboCop::Cop::Performance::ReverseFirst::MSG = T.let(T.unsafe(nil), String)
2296
+
2297
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#24
2298
+ RuboCop::Cop::Performance::ReverseFirst::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2299
+
2300
+ # In Ruby 2.7, `Enumerable#filter_map` has been added.
2301
+ #
2302
+ # This cop identifies places where `select.map` can be replaced by `filter_map`.
2303
+ #
2304
+ # @example
2305
+ # # bad
2306
+ # ary.select(&:foo).map(&:bar)
2307
+ # ary.filter(&:foo).map(&:bar)
2308
+ #
2309
+ # # good
2310
+ # ary.filter_map { |o| o.bar if o.foo }
2311
+ #
2312
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#18
2313
+ class RuboCop::Cop::Performance::SelectMap < ::RuboCop::Cop::Base
2314
+ include ::RuboCop::Cop::RangeHelp
2315
+ extend ::RuboCop::Cop::TargetRubyVersion
2316
+
2317
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#27
2318
+ def bad_method?(param0 = T.unsafe(nil)); end
2319
+
2320
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#31
2321
+ def on_send(node); end
2322
+
2323
+ private
2324
+
2325
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#44
2326
+ def map_method_candidate(node); end
2327
+
2328
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#54
2329
+ def offense_range(node, map_method); end
2330
+ end
2331
+
2332
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#24
2333
+ RuboCop::Cop::Performance::SelectMap::MSG = T.let(T.unsafe(nil), String)
2334
+
2335
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#25
2336
+ RuboCop::Cop::Performance::SelectMap::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2337
+
2338
+ # Identifies usages of `count` on an `Array` and `Hash` and change them to `size`.
2339
+ #
2340
+ # TODO: Add advanced detection of variables that could
2341
+ # have been assigned to an array or a hash.
2342
+ #
2343
+ # @example
2344
+ # # bad
2345
+ # [1, 2, 3].count
2346
+ # (1..3).to_a.count
2347
+ # Array[*1..3].count
2348
+ # Array(1..3).count
2349
+ #
2350
+ # # bad
2351
+ # {a: 1, b: 2, c: 3}.count
2352
+ # [[:foo, :bar], [1, 2]].to_h.count
2353
+ # Hash[*('a'..'z')].count
2354
+ # Hash(key: :value).count
2355
+ #
2356
+ # # good
2357
+ # [1, 2, 3].size
2358
+ # (1..3).to_a.size
2359
+ # Array[*1..3].size
2360
+ # Array(1..3).size
2361
+ #
2362
+ # # good
2363
+ # {a: 1, b: 2, c: 3}.size
2364
+ # [[:foo, :bar], [1, 2]].to_h.size
2365
+ # Hash[*('a'..'z')].size
2366
+ # Hash(key: :value).size
2367
+ #
2368
+ # # good
2369
+ # [1, 2, 3].count { |e| e > 2 }
2370
+ #
2371
+ # source://rubocop-performance//lib/rubocop/cop/performance/size.rb#37
2372
+ class RuboCop::Cop::Performance::Size < ::RuboCop::Cop::Base
2373
+ extend ::RuboCop::Cop::AutoCorrector
2374
+
2375
+ # source://rubocop-performance//lib/rubocop/cop/performance/size.rb#43
2376
+ def array?(param0 = T.unsafe(nil)); end
2377
+
2378
+ # source://rubocop-performance//lib/rubocop/cop/performance/size.rb#61
2379
+ def count?(param0 = T.unsafe(nil)); end
2380
+
2381
+ # source://rubocop-performance//lib/rubocop/cop/performance/size.rb#52
2382
+ def hash?(param0 = T.unsafe(nil)); end
2383
+
2384
+ # source://rubocop-performance//lib/rubocop/cop/performance/size.rb#65
2385
+ def on_send(node); end
2386
+ end
2387
+
2388
+ # source://rubocop-performance//lib/rubocop/cop/performance/size.rb#40
2389
+ RuboCop::Cop::Performance::Size::MSG = T.let(T.unsafe(nil), String)
2390
+
2391
+ # source://rubocop-performance//lib/rubocop/cop/performance/size.rb#41
2392
+ RuboCop::Cop::Performance::Size::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2393
+
2394
+ # Identifies places where `sort { |a, b| b <=> a }`
2395
+ # can be replaced by a faster `sort.reverse`.
2396
+ #
2397
+ # @example
2398
+ # # bad
2399
+ # array.sort { |a, b| b <=> a }
2400
+ #
2401
+ # # good
2402
+ # array.sort.reverse
2403
+ #
2404
+ # source://rubocop-performance//lib/rubocop/cop/performance/sort_reverse.rb#16
2405
+ class RuboCop::Cop::Performance::SortReverse < ::RuboCop::Cop::Base
2406
+ include ::RuboCop::Cop::RangeHelp
2407
+ include ::RuboCop::Cop::SortBlock
2408
+ extend ::RuboCop::Cop::AutoCorrector
2409
+
2410
+ # source://rubocop-performance//lib/rubocop/cop/performance/sort_reverse.rb#22
2411
+ def on_block(node); end
2412
+
2413
+ # source://rubocop-performance//lib/rubocop/cop/performance/sort_reverse.rb#30
2414
+ def on_numblock(node); end
2415
+
2416
+ private
2417
+
2418
+ # source://rubocop-performance//lib/rubocop/cop/performance/sort_reverse.rb#42
2419
+ def register_offense(send, node); end
2420
+ end
2421
+
2422
+ # source://rubocop-performance//lib/rubocop/cop/performance/sort_reverse.rb#20
2423
+ RuboCop::Cop::Performance::SortReverse::MSG = T.let(T.unsafe(nil), String)
2424
+
2425
+ # Identifies places where `gsub(/a+/, 'a')` and `gsub!(/a+/, 'a')`
2426
+ # can be replaced by `squeeze('a')` and `squeeze!('a')`.
2427
+ #
2428
+ # The `squeeze('a')` method is faster than `gsub(/a+/, 'a')`.
2429
+ #
2430
+ # @example
2431
+ #
2432
+ # # bad
2433
+ # str.gsub(/a+/, 'a')
2434
+ # str.gsub!(/a+/, 'a')
2435
+ #
2436
+ # # good
2437
+ # str.squeeze('a')
2438
+ # str.squeeze!('a')
2439
+ #
2440
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#21
2441
+ class RuboCop::Cop::Performance::Squeeze < ::RuboCop::Cop::Base
2442
+ extend ::RuboCop::Cop::AutoCorrector
2443
+
2444
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#38
2445
+ def on_send(node); end
2446
+
2447
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#29
2448
+ def squeeze_candidate?(param0 = T.unsafe(nil)); end
2449
+
2450
+ private
2451
+
2452
+ # @return [Boolean]
2453
+ #
2454
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#58
2455
+ def repeating_literal?(regex_str); end
2456
+ end
2457
+
2458
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#24
2459
+ RuboCop::Cop::Performance::Squeeze::MSG = T.let(T.unsafe(nil), String)
2460
+
2461
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#27
2462
+ RuboCop::Cop::Performance::Squeeze::PREFERRED_METHODS = T.let(T.unsafe(nil), Hash)
2463
+
2464
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#25
2465
+ RuboCop::Cop::Performance::Squeeze::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2466
+
2467
+ # Identifies unnecessary use of a regex where `String#start_with?` would suffice.
2468
+ #
2469
+ # This cop has `SafeMultiline` configuration option that `true` by default because
2470
+ # `^start` is unsafe as it will behave incompatible with `start_with?`
2471
+ # for receiver is multiline string.
2472
+ #
2473
+ # @example
2474
+ # # bad
2475
+ # 'abc'.match?(/\Aab/)
2476
+ # /\Aab/.match?('abc')
2477
+ # 'abc' =~ /\Aab/
2478
+ # /\Aab/ =~ 'abc'
2479
+ # 'abc'.match(/\Aab/)
2480
+ # /\Aab/.match('abc')
2481
+ #
2482
+ # # good
2483
+ # 'abc'.start_with?('ab')
2484
+ # @example SafeMultiline: true (default)
2485
+ #
2486
+ # # good
2487
+ # 'abc'.match?(/^ab/)
2488
+ # /^ab/.match?('abc')
2489
+ # 'abc' =~ /^ab/
2490
+ # /^ab/ =~ 'abc'
2491
+ # 'abc'.match(/^ab/)
2492
+ # /^ab/.match('abc')
2493
+ # @example SafeMultiline: false
2494
+ #
2495
+ # # bad
2496
+ # 'abc'.match?(/^ab/)
2497
+ # /^ab/.match?('abc')
2498
+ # 'abc' =~ /^ab/
2499
+ # /^ab/ =~ 'abc'
2500
+ # 'abc'.match(/^ab/)
2501
+ # /^ab/.match('abc')
2502
+ #
2503
+ # source://rubocop-performance//lib/rubocop/cop/performance/start_with.rb#49
2504
+ class RuboCop::Cop::Performance::StartWith < ::RuboCop::Cop::Base
2505
+ include ::RuboCop::Cop::RegexpMetacharacter
2506
+ extend ::RuboCop::Cop::AutoCorrector
2507
+
2508
+ # source://rubocop-performance//lib/rubocop/cop/performance/start_with.rb#62
2509
+ def on_match_with_lvasgn(node); end
2510
+
2511
+ # source://rubocop-performance//lib/rubocop/cop/performance/start_with.rb#62
2512
+ def on_send(node); end
2513
+
2514
+ # source://rubocop-performance//lib/rubocop/cop/performance/start_with.rb#56
2515
+ def redundant_regex?(param0 = T.unsafe(nil)); end
2516
+ end
2517
+
2518
+ # source://rubocop-performance//lib/rubocop/cop/performance/start_with.rb#53
2519
+ RuboCop::Cop::Performance::StartWith::MSG = T.let(T.unsafe(nil), String)
2520
+
2521
+ # source://rubocop-performance//lib/rubocop/cop/performance/start_with.rb#54
2522
+ RuboCop::Cop::Performance::StartWith::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2523
+
2524
+ # Identifies places where string identifier argument can be replaced
2525
+ # by symbol identifier argument.
2526
+ # It prevents the redundancy of the internal string-to-symbol conversion.
2527
+ #
2528
+ # This cop targets methods that take identifier (e.g. method name) argument
2529
+ # and the following examples are parts of it.
2530
+ #
2531
+ # @example
2532
+ #
2533
+ # # bad
2534
+ # send('do_something')
2535
+ # attr_accessor 'do_something'
2536
+ # instance_variable_get('@ivar')
2537
+ #
2538
+ # # good
2539
+ # send(:do_something)
2540
+ # attr_accessor :do_something
2541
+ # instance_variable_get(:@ivar)
2542
+ #
2543
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_identifier_argument.rb#25
2544
+ class RuboCop::Cop::Performance::StringIdentifierArgument < ::RuboCop::Cop::Base
2545
+ extend ::RuboCop::Cop::AutoCorrector
2546
+
2547
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_identifier_argument.rb#48
2548
+ def on_send(node); end
2549
+ end
2550
+
2551
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_identifier_argument.rb#30
2552
+ RuboCop::Cop::Performance::StringIdentifierArgument::COMMAND_METHODS = T.let(T.unsafe(nil), Array)
2553
+
2554
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_identifier_argument.rb#28
2555
+ RuboCop::Cop::Performance::StringIdentifierArgument::MSG = T.let(T.unsafe(nil), String)
2556
+
2557
+ # NOTE: `attr` method is not included in this list as it can cause false positives in Nokogiri API.
2558
+ # And `attr` may not be used because `Style/Attr` registers an offense.
2559
+ # https://github.com/rubocop/rubocop-performance/issues/278
2560
+ #
2561
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_identifier_argument.rb#38
2562
+ RuboCop::Cop::Performance::StringIdentifierArgument::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2563
+
2564
+ # Identifies unnecessary use of a regex where `String#include?` would suffice.
2565
+ #
2566
+ # @example
2567
+ # # bad
2568
+ # str.match?(/ab/)
2569
+ # /ab/.match?(str)
2570
+ # str =~ /ab/
2571
+ # /ab/ =~ str
2572
+ # str.match(/ab/)
2573
+ # /ab/.match(str)
2574
+ #
2575
+ # # good
2576
+ # str.include?('ab')
2577
+ #
2578
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#22
2579
+ class RuboCop::Cop::Performance::StringInclude < ::RuboCop::Cop::Base
2580
+ extend ::RuboCop::Cop::AutoCorrector
2581
+
2582
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#34
2583
+ def on_match_with_lvasgn(node); end
2584
+
2585
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#34
2586
+ def on_send(node); end
2587
+
2588
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#28
2589
+ def redundant_regex?(param0 = T.unsafe(nil)); end
2590
+
2591
+ private
2592
+
2593
+ # @return [Boolean]
2594
+ #
2595
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#53
2596
+ def literal?(regex_str); end
2597
+ end
2598
+
2599
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#25
2600
+ RuboCop::Cop::Performance::StringInclude::MSG = T.let(T.unsafe(nil), String)
2601
+
2602
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#26
2603
+ RuboCop::Cop::Performance::StringInclude::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2604
+
2605
+ # Identifies places where `gsub` can be replaced by `tr` or `delete`.
2606
+ #
2607
+ # @example
2608
+ # # bad
2609
+ # 'abc'.gsub('b', 'd')
2610
+ # 'abc'.gsub('a', '')
2611
+ # 'abc'.gsub(/a/, 'd')
2612
+ # 'abc'.gsub!('a', 'd')
2613
+ #
2614
+ # # good
2615
+ # 'abc'.gsub(/.*/, 'a')
2616
+ # 'abc'.gsub(/a+/, 'd')
2617
+ # 'abc'.tr('b', 'd')
2618
+ # 'a b c'.delete(' ')
2619
+ #
2620
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#20
2621
+ class RuboCop::Cop::Performance::StringReplacement < ::RuboCop::Cop::Base
2622
+ include ::RuboCop::Cop::RangeHelp
2623
+ extend ::RuboCop::Cop::AutoCorrector
2624
+
2625
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#37
2626
+ def on_send(node); end
2627
+
2628
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#31
2629
+ def string_replacement?(param0 = T.unsafe(nil)); end
2630
+
2631
+ private
2632
+
2633
+ # @return [Boolean]
2634
+ #
2635
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#83
2636
+ def accept_first_param?(first_param); end
2637
+
2638
+ # @return [Boolean]
2639
+ #
2640
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#78
2641
+ def accept_second_param?(second_param); end
2642
+
2643
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#59
2644
+ def autocorrect(corrector, node); end
2645
+
2646
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#99
2647
+ def first_source(first_param); end
2648
+
2649
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#142
2650
+ def message(node, first_source, second_source); end
2651
+
2652
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#148
2653
+ def method_suffix(node); end
2654
+
2655
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#48
2656
+ def offense(node, first_param, second_param); end
2657
+
2658
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#128
2659
+ def range(node); end
2660
+
2661
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#152
2662
+ def remove_second_param(corrector, node, first_param); end
2663
+
2664
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#69
2665
+ def replace_method(corrector, node, first_source, second_source, first_param); end
2666
+
2667
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#132
2668
+ def replacement_method(node, first_source, second_source); end
2669
+
2670
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#117
2671
+ def source_from_regex_constructor(node); end
2672
+
2673
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#110
2674
+ def source_from_regex_literal(node); end
2675
+ end
2676
+
2677
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#29
2678
+ RuboCop::Cop::Performance::StringReplacement::BANG = T.let(T.unsafe(nil), String)
2679
+
2680
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#27
2681
+ RuboCop::Cop::Performance::StringReplacement::DELETE = T.let(T.unsafe(nil), String)
2682
+
2683
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#26
2684
+ RuboCop::Cop::Performance::StringReplacement::DETERMINISTIC_REGEX = T.let(T.unsafe(nil), Regexp)
2685
+
2686
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#24
2687
+ RuboCop::Cop::Performance::StringReplacement::MSG = T.let(T.unsafe(nil), String)
2688
+
2689
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#25
2690
+ RuboCop::Cop::Performance::StringReplacement::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2691
+
2692
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#28
2693
+ RuboCop::Cop::Performance::StringReplacement::TR = T.let(T.unsafe(nil), String)
2694
+
2695
+ # Identifies places where custom code finding the sum of elements
2696
+ # in some Enumerable object can be replaced by `Enumerable#sum` method.
2697
+ #
2698
+ # @example OnlySumOrWithInitialValue: false (default)
2699
+ # # bad
2700
+ # [1, 2, 3].inject(:+) # Autocorrections for cases without initial value are unsafe
2701
+ # [1, 2, 3].inject(&:+) # and will only be performed when using the `-A` option.
2702
+ # [1, 2, 3].reduce { |acc, elem| acc + elem } # They can be prohibited completely using `SafeAutoCorrect: true`.
2703
+ # [1, 2, 3].reduce(10, :+)
2704
+ # [1, 2, 3].map { |elem| elem ** 2 }.sum
2705
+ # [1, 2, 3].collect(&:count).sum(10)
2706
+ #
2707
+ # # good
2708
+ # [1, 2, 3].sum
2709
+ # [1, 2, 3].sum(10)
2710
+ # [1, 2, 3].sum { |elem| elem ** 2 }
2711
+ # [1, 2, 3].sum(10, &:count)
2712
+ # @example OnlySumOrWithInitialValue: true
2713
+ # # bad
2714
+ # [1, 2, 3].reduce(10, :+)
2715
+ # [1, 2, 3].map { |elem| elem ** 2 }.sum
2716
+ # [1, 2, 3].collect(&:count).sum(10)
2717
+ #
2718
+ # # good
2719
+ # [1, 2, 3].sum(10)
2720
+ # [1, 2, 3].sum { |elem| elem ** 2 }
2721
+ # [1, 2, 3].sum(10, &:count)
2722
+ #
2723
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#70
2724
+ class RuboCop::Cop::Performance::Sum < ::RuboCop::Cop::Base
2725
+ include ::RuboCop::Cop::RangeHelp
2726
+ extend ::RuboCop::Cop::AutoCorrector
2727
+ extend ::RuboCop::Cop::TargetRubyVersion
2728
+
2729
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#102
2730
+ def acc_plus_elem?(param0 = T.unsafe(nil), param1, param2); end
2731
+
2732
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#102
2733
+ def elem_plus_acc?(param0 = T.unsafe(nil), param1, param2); end
2734
+
2735
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#114
2736
+ def on_block(node); end
2737
+
2738
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#107
2739
+ def on_send(node); end
2740
+
2741
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#82
2742
+ def sum_candidate?(param0 = T.unsafe(nil)); end
2743
+
2744
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#86
2745
+ def sum_map_candidate?(param0 = T.unsafe(nil)); end
2746
+
2747
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#95
2748
+ def sum_with_block_candidate?(param0 = T.unsafe(nil)); end
2749
+
2750
+ private
2751
+
2752
+ # @return [Boolean]
2753
+ #
2754
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#159
2755
+ def array_literal?(node); end
2756
+
2757
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#164
2758
+ def autocorrect(corrector, init, range); end
2759
+
2760
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#172
2761
+ def autocorrect_sum_map(corrector, sum, map, init); end
2762
+
2763
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#248
2764
+ def build_block_bad_method(method, init, var_acc, var_elem, body); end
2765
+
2766
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#215
2767
+ def build_block_message(send, init, var_acc, var_elem, body); end
2768
+
2769
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#221
2770
+ def build_good_method(init, block_pass = T.unsafe(nil)); end
2771
+
2772
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#234
2773
+ def build_method_bad_method(init, method, operation); end
2774
+
2775
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#197
2776
+ def build_method_message(node, method, init, operation); end
2777
+
2778
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#208
2779
+ def build_sum_map_message(method, init); end
2780
+
2781
+ # @return [Boolean]
2782
+ #
2783
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#154
2784
+ def empty_array_literal?(node); end
2785
+
2786
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#129
2787
+ def handle_sum_candidate(node); end
2788
+
2789
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#142
2790
+ def handle_sum_map_candidate(node); end
2791
+
2792
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#259
2793
+ def method_call_with_args_range(node); end
2794
+
2795
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#193
2796
+ def sum_block_range(send, node); end
2797
+
2798
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#189
2799
+ def sum_map_range(map, sum); end
2800
+
2801
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#185
2802
+ def sum_method_range(node); end
2803
+ end
2804
+
2805
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#77
2806
+ RuboCop::Cop::Performance::Sum::MSG = T.let(T.unsafe(nil), String)
2807
+
2808
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#78
2809
+ RuboCop::Cop::Performance::Sum::MSG_IF_NO_INIT_VALUE = T.let(T.unsafe(nil), String)
2810
+
2811
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#80
2812
+ RuboCop::Cop::Performance::Sum::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2813
+
2814
+ # Checks for .times.map calls.
2815
+ # In most cases such calls can be replaced
2816
+ # with an explicit array creation.
2817
+ #
2818
+ # @example
2819
+ # # bad
2820
+ # 9.times.map do |i|
2821
+ # i.to_s
2822
+ # end
2823
+ #
2824
+ # # good
2825
+ # Array.new(9) do |i|
2826
+ # i.to_s
2827
+ # end
2828
+ #
2829
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#32
2830
+ class RuboCop::Cop::Performance::TimesMap < ::RuboCop::Cop::Base
2831
+ extend ::RuboCop::Cop::AutoCorrector
2832
+
2833
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#43
2834
+ def on_block(node); end
2835
+
2836
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#43
2837
+ def on_numblock(node); end
2838
+
2839
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#39
2840
+ def on_send(node); end
2841
+
2842
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#69
2843
+ def times_map_call(param0 = T.unsafe(nil)); end
2844
+
2845
+ private
2846
+
2847
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#50
2848
+ def check(node); end
2849
+
2850
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#60
2851
+ def message(map_or_collect, count); end
2852
+ end
2853
+
2854
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#35
2855
+ RuboCop::Cop::Performance::TimesMap::MESSAGE = T.let(T.unsafe(nil), String)
2856
+
2857
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#36
2858
+ RuboCop::Cop::Performance::TimesMap::MESSAGE_ONLY_IF = T.let(T.unsafe(nil), String)
2859
+
2860
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#37
2861
+ RuboCop::Cop::Performance::TimesMap::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2862
+
2863
+ # In Ruby 2.3 or later, use unary plus operator to unfreeze a string
2864
+ # literal instead of `String#dup` and `String.new`.
2865
+ # Unary plus operator is faster than `String#dup`.
2866
+ #
2867
+ # @example
2868
+ # # bad
2869
+ # ''.dup
2870
+ # "something".dup
2871
+ # String.new
2872
+ # String.new('')
2873
+ # String.new('something')
2874
+ #
2875
+ # # good
2876
+ # +'something'
2877
+ # +''
2878
+ #
2879
+ # source://rubocop-performance//lib/rubocop/cop/performance/unfreeze_string.rb#27
2880
+ class RuboCop::Cop::Performance::UnfreezeString < ::RuboCop::Cop::Base
2881
+ extend ::RuboCop::Cop::AutoCorrector
2882
+
2883
+ # source://rubocop-performance//lib/rubocop/cop/performance/unfreeze_string.rb#33
2884
+ def dup_string?(param0 = T.unsafe(nil)); end
2885
+
2886
+ # source://rubocop-performance//lib/rubocop/cop/performance/unfreeze_string.rb#44
2887
+ def on_send(node); end
2888
+
2889
+ # source://rubocop-performance//lib/rubocop/cop/performance/unfreeze_string.rb#37
2890
+ def string_new?(param0 = T.unsafe(nil)); end
2891
+
2892
+ private
2893
+
2894
+ # source://rubocop-performance//lib/rubocop/cop/performance/unfreeze_string.rb#57
2895
+ def string_value(node); end
2896
+ end
2897
+
2898
+ # source://rubocop-performance//lib/rubocop/cop/performance/unfreeze_string.rb#30
2899
+ RuboCop::Cop::Performance::UnfreezeString::MSG = T.let(T.unsafe(nil), String)
2900
+
2901
+ # source://rubocop-performance//lib/rubocop/cop/performance/unfreeze_string.rb#31
2902
+ RuboCop::Cop::Performance::UnfreezeString::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2903
+
2904
+ # Identifies places where `URI::Parser.new` can be replaced by `URI::DEFAULT_PARSER`.
2905
+ #
2906
+ # @example
2907
+ # # bad
2908
+ # URI::Parser.new
2909
+ #
2910
+ # # good
2911
+ # URI::DEFAULT_PARSER
2912
+ #
2913
+ # source://rubocop-performance//lib/rubocop/cop/performance/uri_default_parser.rb#15
2914
+ class RuboCop::Cop::Performance::UriDefaultParser < ::RuboCop::Cop::Base
2915
+ extend ::RuboCop::Cop::AutoCorrector
2916
+
2917
+ # source://rubocop-performance//lib/rubocop/cop/performance/uri_default_parser.rb#27
2918
+ def on_send(node); end
2919
+
2920
+ # source://rubocop-performance//lib/rubocop/cop/performance/uri_default_parser.rb#21
2921
+ def uri_parser_new?(param0 = T.unsafe(nil)); end
2922
+ end
2923
+
2924
+ # source://rubocop-performance//lib/rubocop/cop/performance/uri_default_parser.rb#18
2925
+ RuboCop::Cop::Performance::UriDefaultParser::MSG = T.let(T.unsafe(nil), String)
2926
+
2927
+ # source://rubocop-performance//lib/rubocop/cop/performance/uri_default_parser.rb#19
2928
+ RuboCop::Cop::Performance::UriDefaultParser::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2929
+
2930
+ # Common functionality for handling regexp metacharacters.
2931
+ #
2932
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#6
2933
+ module RuboCop::Cop::RegexpMetacharacter
2934
+ private
2935
+
2936
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#63
2937
+ def drop_end_metacharacter(regexp_string); end
2938
+
2939
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#55
2940
+ def drop_start_metacharacter(regexp_string); end
2941
+
2942
+ # @return [Boolean]
2943
+ #
2944
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#15
2945
+ def literal_at_end?(regexp); end
2946
+
2947
+ # @return [Boolean]
2948
+ #
2949
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#41
2950
+ def literal_at_end_with_backslash_z?(regex_str); end
2951
+
2952
+ # @return [Boolean]
2953
+ #
2954
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#48
2955
+ def literal_at_end_with_dollar?(regex_str); end
2956
+
2957
+ # @return [Boolean]
2958
+ #
2959
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#9
2960
+ def literal_at_start?(regexp); end
2961
+
2962
+ # @return [Boolean]
2963
+ #
2964
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#21
2965
+ def literal_at_start_with_backslash_a?(regex_str); end
2966
+
2967
+ # @return [Boolean]
2968
+ #
2969
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#31
2970
+ def literal_at_start_with_caret?(regex_str); end
2971
+
2972
+ # @return [Boolean]
2973
+ #
2974
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#71
2975
+ def safe_multiline?; end
2976
+ end
2977
+
2978
+ # Common functionality for cops checking `Enumerable#sort` blocks.
2979
+ #
2980
+ # source://rubocop-performance//lib/rubocop/cop/mixin/sort_block.rb#6
2981
+ module RuboCop::Cop::SortBlock
2982
+ include ::RuboCop::Cop::RangeHelp
2983
+ extend ::RuboCop::AST::NodePattern::Macros
2984
+
2985
+ # source://rubocop-performance//lib/rubocop/cop/mixin/sort_block.rb#24
2986
+ def replaceable_body?(param0 = T.unsafe(nil), param1, param2); end
2987
+
2988
+ # source://rubocop-performance//lib/rubocop/cop/mixin/sort_block.rb#10
2989
+ def sort_with_block?(param0 = T.unsafe(nil)); end
2990
+
2991
+ # source://rubocop-performance//lib/rubocop/cop/mixin/sort_block.rb#17
2992
+ def sort_with_numblock?(param0 = T.unsafe(nil)); end
2993
+
2994
+ private
2995
+
2996
+ # source://rubocop-performance//lib/rubocop/cop/mixin/sort_block.rb#30
2997
+ def sort_range(send, node); end
2998
+ end
2999
+
3000
+ # RuboCop Performance project namespace
3001
+ #
3002
+ # source://rubocop-performance//lib/rubocop/performance.rb#5
3003
+ module RuboCop::Performance; end
3004
+
3005
+ # source://rubocop-performance//lib/rubocop/performance.rb#8
3006
+ RuboCop::Performance::CONFIG = T.let(T.unsafe(nil), Hash)
3007
+
3008
+ # source://rubocop-performance//lib/rubocop/performance.rb#7
3009
+ RuboCop::Performance::CONFIG_DEFAULT = T.let(T.unsafe(nil), Pathname)
3010
+
3011
+ # Because RuboCop doesn't yet support plugins, we have to monkey patch in a
3012
+ # bit of our configuration.
3013
+ #
3014
+ # source://rubocop-performance//lib/rubocop/performance/inject.rb#7
3015
+ module RuboCop::Performance::Inject
3016
+ class << self
3017
+ # source://rubocop-performance//lib/rubocop/performance/inject.rb#8
3018
+ def defaults!; end
3019
+ end
3020
+ end
3021
+
3022
+ # source://rubocop-performance//lib/rubocop/performance.rb#6
3023
+ RuboCop::Performance::PROJECT_ROOT = T.let(T.unsafe(nil), Pathname)
3024
+
3025
+ # This module holds the RuboCop Performance version information.
3026
+ #
3027
+ # source://rubocop-performance//lib/rubocop/performance/version.rb#6
3028
+ module RuboCop::Performance::Version
3029
+ class << self
3030
+ # source://rubocop-performance//lib/rubocop/performance/version.rb#9
3031
+ def document_version; end
3032
+ end
3033
+ end
3034
+
3035
+ # source://rubocop-performance//lib/rubocop/performance/version.rb#7
3036
+ RuboCop::Performance::Version::STRING = T.let(T.unsafe(nil), String)