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