packwerk-haml 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +75 -0
  4. data/Gemfile +22 -0
  5. data/Gemfile.lock +190 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +32 -0
  8. data/Rakefile +16 -0
  9. data/lib/packwerk_haml/parser.rb +64 -0
  10. data/lib/packwerk_haml/version.rb +6 -0
  11. data/lib/packwerk_haml.rb +8 -0
  12. data/packwerk-haml.gemspec +40 -0
  13. data/sig/packwerk/haml.rbs +4 -0
  14. data/sorbet/config +4 -0
  15. data/sorbet/rbi/annotations/.gitattributes +1 -0
  16. data/sorbet/rbi/annotations/actionview.rbi +75 -0
  17. data/sorbet/rbi/annotations/activesupport.rbi +136 -0
  18. data/sorbet/rbi/annotations/rainbow.rbi +269 -0
  19. data/sorbet/rbi/gems/.gitattributes +1 -0
  20. data/sorbet/rbi/gems/actionview@7.1.1.rbi +15004 -0
  21. data/sorbet/rbi/gems/activesupport@7.1.1.rbi +18784 -0
  22. data/sorbet/rbi/gems/ast@2.4.2.rbi +584 -0
  23. data/sorbet/rbi/gems/base64@0.1.1.rbi +172 -0
  24. data/sorbet/rbi/gems/better_html@2.0.2.rbi +529 -0
  25. data/sorbet/rbi/gems/bigdecimal@3.1.4.rbi +77 -0
  26. data/sorbet/rbi/gems/builder@3.2.4.rbi +8 -0
  27. data/sorbet/rbi/gems/concurrent-ruby@1.2.2.rbi +11545 -0
  28. data/sorbet/rbi/gems/connection_pool@2.4.1.rbi +8 -0
  29. data/sorbet/rbi/gems/constant_resolver@0.2.0.rbi +90 -0
  30. data/sorbet/rbi/gems/crass@1.0.6.rbi +622 -0
  31. data/sorbet/rbi/gems/drb@2.1.1.rbi +1313 -0
  32. data/sorbet/rbi/gems/erubi@1.12.0.rbi +145 -0
  33. data/sorbet/rbi/gems/haml@6.2.3.rbi +1619 -0
  34. data/sorbet/rbi/gems/i18n@1.14.1.rbi +2325 -0
  35. data/sorbet/rbi/gems/json@2.6.3.rbi +1533 -0
  36. data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +14237 -0
  37. data/sorbet/rbi/gems/loofah@2.21.4.rbi +1021 -0
  38. data/sorbet/rbi/gems/m@1.6.2.rbi +257 -0
  39. data/sorbet/rbi/gems/method_source@1.0.0.rbi +8 -0
  40. data/sorbet/rbi/gems/minitest-focus@1.4.0.rbi +91 -0
  41. data/sorbet/rbi/gems/minitest@5.20.0.rbi +1509 -0
  42. data/sorbet/rbi/gems/mutex_m@0.1.2.rbi +91 -0
  43. data/sorbet/rbi/gems/netrc@0.11.0.rbi +158 -0
  44. data/sorbet/rbi/gems/nokogiri@1.15.4.rbi +7317 -0
  45. data/sorbet/rbi/gems/packwerk@3.1.0-752d37add96b9f4bf28492d7db152f6523b1d29c.rbi +2370 -0
  46. data/sorbet/rbi/gems/parallel@1.23.0.rbi +273 -0
  47. data/sorbet/rbi/gems/parser@3.2.2.4.rbi +7253 -0
  48. data/sorbet/rbi/gems/prettier_print@1.2.1.rbi +951 -0
  49. data/sorbet/rbi/gems/racc@1.7.1.rbi +161 -0
  50. data/sorbet/rbi/gems/rails-dom-testing@2.2.0.rbi +8 -0
  51. data/sorbet/rbi/gems/rails-html-sanitizer@1.6.0.rbi +716 -0
  52. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +402 -0
  53. data/sorbet/rbi/gems/rake@13.0.6.rbi +3042 -0
  54. data/sorbet/rbi/gems/rbi@0.1.1.rbi +2926 -0
  55. data/sorbet/rbi/gems/regexp_parser@2.8.2.rbi +3749 -0
  56. data/sorbet/rbi/gems/rexml@3.2.6.rbi +4781 -0
  57. data/sorbet/rbi/gems/rubocop-ast@1.29.0.rbi +7075 -0
  58. data/sorbet/rbi/gems/rubocop-performance@1.19.1.rbi +3208 -0
  59. data/sorbet/rbi/gems/rubocop-shopify@2.14.0.rbi +8 -0
  60. data/sorbet/rbi/gems/rubocop-sorbet@0.7.4.rbi +1442 -0
  61. data/sorbet/rbi/gems/rubocop@1.57.0.rbi +56753 -0
  62. data/sorbet/rbi/gems/ruby-lsp@0.2.4.rbi +11 -0
  63. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1317 -0
  64. data/sorbet/rbi/gems/ruby2_keywords@0.0.5.rbi +8 -0
  65. data/sorbet/rbi/gems/smart_properties@1.17.0.rbi +474 -0
  66. data/sorbet/rbi/gems/spoom@1.2.4.rbi +3777 -0
  67. data/sorbet/rbi/gems/syntax_tree@6.2.0.rbi +23136 -0
  68. data/sorbet/rbi/gems/tapioca@0.11.9.rbi +3498 -0
  69. data/sorbet/rbi/gems/temple@0.10.3.rbi +1738 -0
  70. data/sorbet/rbi/gems/thor@1.2.2.rbi +3965 -0
  71. data/sorbet/rbi/gems/tilt@2.3.0.rbi +925 -0
  72. data/sorbet/rbi/gems/tzinfo@2.0.6.rbi +5917 -0
  73. data/sorbet/rbi/gems/unicode-display_width@2.5.0.rbi +65 -0
  74. data/sorbet/rbi/gems/yard-sorbet@0.8.1.rbi +428 -0
  75. data/sorbet/rbi/gems/yard@0.9.34.rbi +18219 -0
  76. data/sorbet/rbi/gems/yarp@0.13.0.rbi +21646 -0
  77. data/sorbet/rbi/gems/zeitwerk@2.6.12.rbi +997 -0
  78. data/sorbet/tapioca/config.yml +13 -0
  79. data/sorbet/tapioca/require.rb +5 -0
  80. metadata +167 -0
@@ -0,0 +1,3208 @@
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.57.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.57.0/lib/rubocop/cop/lint/unused_method_argument.rb#81
22
+ def autocorrect(corrector, node); end
23
+
24
+ # source://rubocop/1.57.0/lib/rubocop/cop/lint/unused_method_argument.rb#85
25
+ def check_argument(variable); end
26
+
27
+ # source://rubocop/1.57.0/lib/rubocop/cop/lint/unused_method_argument.rb#93
28
+ def ignored_method?(body); end
29
+
30
+ # source://rubocop/1.57.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.57.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#49
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#56
794
+ def count_candidate?(param0 = T.unsafe(nil)); end
795
+
796
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#63
797
+ def on_send(node); end
798
+
799
+ private
800
+
801
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#79
802
+ def autocorrect(corrector, node, selector_node, selector); end
803
+
804
+ # @return [Boolean]
805
+ #
806
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#89
807
+ def eligible_node?(node); end
808
+
809
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#132
810
+ def negate_block_pass_as_inline_block(node); end
811
+
812
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#111
813
+ def negate_block_pass_reject(corrector, node); end
814
+
815
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#118
816
+ def negate_block_reject(corrector, node); end
817
+
818
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#128
819
+ def negate_expression(node); end
820
+
821
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#103
822
+ def negate_reject(corrector, node); end
823
+
824
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#93
825
+ def source_starting_at(node); end
826
+ end
827
+
828
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#53
829
+ RuboCop::Cop::Performance::Count::MSG = T.let(T.unsafe(nil), String)
830
+
831
+ # source://rubocop-performance//lib/rubocop/cop/performance/count.rb#54
832
+ RuboCop::Cop::Performance::Count::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
833
+
834
+ # In Ruby 2.5, `String#delete_prefix` has been added.
835
+ #
836
+ # This cop identifies places where `gsub(/\Aprefix/, '')` and `sub(/\Aprefix/, '')`
837
+ # can be replaced by `delete_prefix('prefix')`.
838
+ #
839
+ # This cop has `SafeMultiline` configuration option that `true` by default because
840
+ # `^prefix` is unsafe as it will behave incompatible with `delete_prefix`
841
+ # for receiver is multiline string.
842
+ #
843
+ # The `delete_prefix('prefix')` method is faster than `gsub(/\Aprefix/, '')`.
844
+ #
845
+ # @example
846
+ #
847
+ # # bad
848
+ # str.gsub(/\Aprefix/, '')
849
+ # str.gsub!(/\Aprefix/, '')
850
+ #
851
+ # str.sub(/\Aprefix/, '')
852
+ # str.sub!(/\Aprefix/, '')
853
+ #
854
+ # # good
855
+ # str.delete_prefix('prefix')
856
+ # str.delete_prefix!('prefix')
857
+ # @example SafeMultiline: true (default)
858
+ #
859
+ # # good
860
+ # str.gsub(/^prefix/, '')
861
+ # str.gsub!(/^prefix/, '')
862
+ # str.sub(/^prefix/, '')
863
+ # str.sub!(/^prefix/, '')
864
+ # @example SafeMultiline: false
865
+ #
866
+ # # bad
867
+ # str.gsub(/^prefix/, '')
868
+ # str.gsub!(/^prefix/, '')
869
+ # str.sub(/^prefix/, '')
870
+ # str.sub!(/^prefix/, '')
871
+ #
872
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_prefix.rb#49
873
+ class RuboCop::Cop::Performance::DeletePrefix < ::RuboCop::Cop::Base
874
+ include ::RuboCop::Cop::RegexpMetacharacter
875
+ extend ::RuboCop::Cop::AutoCorrector
876
+ extend ::RuboCop::Cop::TargetRubyVersion
877
+
878
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_prefix.rb#66
879
+ def delete_prefix_candidate?(param0 = T.unsafe(nil)); end
880
+
881
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_prefix.rb#71
882
+ def on_csend(node); end
883
+
884
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_prefix.rb#71
885
+ def on_send(node); end
886
+ end
887
+
888
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_prefix.rb#56
889
+ RuboCop::Cop::Performance::DeletePrefix::MSG = T.let(T.unsafe(nil), String)
890
+
891
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_prefix.rb#59
892
+ RuboCop::Cop::Performance::DeletePrefix::PREFERRED_METHODS = T.let(T.unsafe(nil), Hash)
893
+
894
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_prefix.rb#57
895
+ RuboCop::Cop::Performance::DeletePrefix::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
896
+
897
+ # In Ruby 2.5, `String#delete_suffix` has been added.
898
+ #
899
+ # This cop identifies places where `gsub(/suffix\z/, '')` and `sub(/suffix\z/, '')`
900
+ # can be replaced by `delete_suffix('suffix')`.
901
+ #
902
+ # This cop has `SafeMultiline` configuration option that `true` by default because
903
+ # `suffix$` is unsafe as it will behave incompatible with `delete_suffix?`
904
+ # for receiver is multiline string.
905
+ #
906
+ # The `delete_suffix('suffix')` method is faster than `gsub(/suffix\z/, '')`.
907
+ #
908
+ # @example
909
+ #
910
+ # # bad
911
+ # str.gsub(/suffix\z/, '')
912
+ # str.gsub!(/suffix\z/, '')
913
+ #
914
+ # str.sub(/suffix\z/, '')
915
+ # str.sub!(/suffix\z/, '')
916
+ #
917
+ # # good
918
+ # str.delete_suffix('suffix')
919
+ # str.delete_suffix!('suffix')
920
+ # @example SafeMultiline: true (default)
921
+ #
922
+ # # good
923
+ # str.gsub(/suffix$/, '')
924
+ # str.gsub!(/suffix$/, '')
925
+ # str.sub(/suffix$/, '')
926
+ # str.sub!(/suffix$/, '')
927
+ # @example SafeMultiline: false
928
+ #
929
+ # # bad
930
+ # str.gsub(/suffix$/, '')
931
+ # str.gsub!(/suffix$/, '')
932
+ # str.sub(/suffix$/, '')
933
+ # str.sub!(/suffix$/, '')
934
+ #
935
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_suffix.rb#49
936
+ class RuboCop::Cop::Performance::DeleteSuffix < ::RuboCop::Cop::Base
937
+ include ::RuboCop::Cop::RegexpMetacharacter
938
+ extend ::RuboCop::Cop::AutoCorrector
939
+ extend ::RuboCop::Cop::TargetRubyVersion
940
+
941
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_suffix.rb#66
942
+ def delete_suffix_candidate?(param0 = T.unsafe(nil)); end
943
+
944
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_suffix.rb#71
945
+ def on_csend(node); end
946
+
947
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_suffix.rb#71
948
+ def on_send(node); end
949
+ end
950
+
951
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_suffix.rb#56
952
+ RuboCop::Cop::Performance::DeleteSuffix::MSG = T.let(T.unsafe(nil), String)
953
+
954
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_suffix.rb#59
955
+ RuboCop::Cop::Performance::DeleteSuffix::PREFERRED_METHODS = T.let(T.unsafe(nil), Hash)
956
+
957
+ # source://rubocop-performance//lib/rubocop/cop/performance/delete_suffix.rb#57
958
+ RuboCop::Cop::Performance::DeleteSuffix::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
959
+
960
+ # Identifies usages of `first`, `last`, `[0]` or `[-1]`
961
+ # chained to `select`, `find_all` or `filter` and change them to use
962
+ # `detect` instead.
963
+ #
964
+ # @example
965
+ # # bad
966
+ # [].select { |item| true }.first
967
+ # [].select { |item| true }.last
968
+ # [].find_all { |item| true }.first
969
+ # [].find_all { |item| true }.last
970
+ # [].filter { |item| true }.first
971
+ # [].filter { |item| true }.last
972
+ # [].filter { |item| true }[0]
973
+ # [].filter { |item| true }[-1]
974
+ #
975
+ # # good
976
+ # [].detect { |item| true }
977
+ # [].reverse.detect { |item| true }
978
+ #
979
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#30
980
+ class RuboCop::Cop::Performance::Detect < ::RuboCop::Cop::Base
981
+ extend ::RuboCop::Cop::AutoCorrector
982
+
983
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#41
984
+ def detect_candidate?(param0 = T.unsafe(nil)); end
985
+
986
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#50
987
+ def on_csend(node); end
988
+
989
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#50
990
+ def on_send(node); end
991
+
992
+ private
993
+
994
+ # @return [Boolean]
995
+ #
996
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#70
997
+ def accept_first_call?(receiver, body); end
998
+
999
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#102
1000
+ def autocorrect(corrector, node, replacement); end
1001
+
1002
+ # @return [Boolean]
1003
+ #
1004
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#128
1005
+ def lazy?(node); end
1006
+
1007
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#113
1008
+ def message_for_method(method, index); end
1009
+
1010
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#124
1011
+ def preferred_method; end
1012
+
1013
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#79
1014
+ def register_offense(node, receiver, second_method, index); end
1015
+
1016
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#94
1017
+ def replacement(method, index); end
1018
+ end
1019
+
1020
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#33
1021
+ RuboCop::Cop::Performance::Detect::CANDIDATE_METHODS = T.let(T.unsafe(nil), Set)
1022
+
1023
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#37
1024
+ RuboCop::Cop::Performance::Detect::INDEX_MSG = T.let(T.unsafe(nil), String)
1025
+
1026
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#38
1027
+ RuboCop::Cop::Performance::Detect::INDEX_REVERSE_MSG = T.let(T.unsafe(nil), String)
1028
+
1029
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#35
1030
+ RuboCop::Cop::Performance::Detect::MSG = T.let(T.unsafe(nil), String)
1031
+
1032
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#39
1033
+ RuboCop::Cop::Performance::Detect::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1034
+
1035
+ # source://rubocop-performance//lib/rubocop/cop/performance/detect.rb#36
1036
+ RuboCop::Cop::Performance::Detect::REVERSE_MSG = T.let(T.unsafe(nil), String)
1037
+
1038
+ # Checks for double `#start_with?` or `#end_with?` calls
1039
+ # separated by `||`. In some cases such calls can be replaced
1040
+ # with an single `#start_with?`/`#end_with?` call.
1041
+ #
1042
+ # `IncludeActiveSupportAliases` configuration option is used to check for
1043
+ # `starts_with?` and `ends_with?`. These methods are defined by Active Support.
1044
+ #
1045
+ # @example
1046
+ # # bad
1047
+ # str.start_with?("a") || str.start_with?(Some::CONST)
1048
+ # str.start_with?("a", "b") || str.start_with?("c")
1049
+ # str.end_with?(var1) || str.end_with?(var2)
1050
+ #
1051
+ # # good
1052
+ # str.start_with?("a", Some::CONST)
1053
+ # str.start_with?("a", "b", "c")
1054
+ # str.end_with?(var1, var2)
1055
+ # @example IncludeActiveSupportAliases: false (default)
1056
+ # # good
1057
+ # str.starts_with?("a", "b") || str.starts_with?("c")
1058
+ # str.ends_with?(var1) || str.ends_with?(var2)
1059
+ #
1060
+ # str.starts_with?("a", "b", "c")
1061
+ # str.ends_with?(var1, var2)
1062
+ # @example IncludeActiveSupportAliases: true
1063
+ # # bad
1064
+ # str.starts_with?("a", "b") || str.starts_with?("c")
1065
+ # str.ends_with?(var1) || str.ends_with?(var2)
1066
+ #
1067
+ # # good
1068
+ # str.starts_with?("a", "b", "c")
1069
+ # str.ends_with?(var1, var2)
1070
+ #
1071
+ # source://rubocop-performance//lib/rubocop/cop/performance/double_start_end_with.rb#41
1072
+ class RuboCop::Cop::Performance::DoubleStartEndWith < ::RuboCop::Cop::Base
1073
+ extend ::RuboCop::Cop::AutoCorrector
1074
+
1075
+ # source://rubocop-performance//lib/rubocop/cop/performance/double_start_end_with.rb#96
1076
+ def check_with_active_support_aliases(param0 = T.unsafe(nil)); end
1077
+
1078
+ # source://rubocop-performance//lib/rubocop/cop/performance/double_start_end_with.rb#46
1079
+ def on_or(node); end
1080
+
1081
+ # source://rubocop-performance//lib/rubocop/cop/performance/double_start_end_with.rb#90
1082
+ def two_start_end_with_calls(param0 = T.unsafe(nil)); end
1083
+
1084
+ private
1085
+
1086
+ # source://rubocop-performance//lib/rubocop/cop/performance/double_start_end_with.rb#60
1087
+ def autocorrect(corrector, first_call_args, second_call_args, combined_args); end
1088
+
1089
+ # @return [Boolean]
1090
+ #
1091
+ # source://rubocop-performance//lib/rubocop/cop/performance/double_start_end_with.rb#86
1092
+ def check_for_active_support_aliases?; end
1093
+
1094
+ # source://rubocop-performance//lib/rubocop/cop/performance/double_start_end_with.rb#82
1095
+ def combine_args(first_call_args, second_call_args); end
1096
+
1097
+ # source://rubocop-performance//lib/rubocop/cop/performance/double_start_end_with.rb#76
1098
+ def message(node, receiver, method, combined_args); end
1099
+
1100
+ # source://rubocop-performance//lib/rubocop/cop/performance/double_start_end_with.rb#68
1101
+ def process_source(node); end
1102
+ end
1103
+
1104
+ # source://rubocop-performance//lib/rubocop/cop/performance/double_start_end_with.rb#44
1105
+ RuboCop::Cop::Performance::DoubleStartEndWith::MSG = T.let(T.unsafe(nil), String)
1106
+
1107
+ # Identifies unnecessary use of a regex where `String#end_with?` would suffice.
1108
+ #
1109
+ # This cop has `SafeMultiline` configuration option that `true` by default because
1110
+ # `end$` is unsafe as it will behave incompatible with `end_with?`
1111
+ # for receiver is multiline string.
1112
+ #
1113
+ # @example
1114
+ # # bad
1115
+ # 'abc'.match?(/bc\Z/)
1116
+ # /bc\Z/.match?('abc')
1117
+ # 'abc' =~ /bc\Z/
1118
+ # /bc\Z/ =~ 'abc'
1119
+ # 'abc'.match(/bc\Z/)
1120
+ # /bc\Z/.match('abc')
1121
+ #
1122
+ # # good
1123
+ # 'abc'.end_with?('bc')
1124
+ # @example SafeMultiline: true (default)
1125
+ #
1126
+ # # good
1127
+ # 'abc'.match?(/bc$/)
1128
+ # /bc$/.match?('abc')
1129
+ # 'abc' =~ /bc$/
1130
+ # /bc$/ =~ 'abc'
1131
+ # 'abc'.match(/bc$/)
1132
+ # /bc$/.match('abc')
1133
+ # @example SafeMultiline: false
1134
+ #
1135
+ # # bad
1136
+ # 'abc'.match?(/bc$/)
1137
+ # /bc$/.match?('abc')
1138
+ # 'abc' =~ /bc$/
1139
+ # /bc$/ =~ 'abc'
1140
+ # 'abc'.match(/bc$/)
1141
+ # /bc$/.match('abc')
1142
+ #
1143
+ # source://rubocop-performance//lib/rubocop/cop/performance/end_with.rb#49
1144
+ class RuboCop::Cop::Performance::EndWith < ::RuboCop::Cop::Base
1145
+ include ::RuboCop::Cop::RegexpMetacharacter
1146
+ extend ::RuboCop::Cop::AutoCorrector
1147
+
1148
+ # source://rubocop-performance//lib/rubocop/cop/performance/end_with.rb#62
1149
+ def on_csend(node); end
1150
+
1151
+ # source://rubocop-performance//lib/rubocop/cop/performance/end_with.rb#62
1152
+ def on_match_with_lvasgn(node); end
1153
+
1154
+ # source://rubocop-performance//lib/rubocop/cop/performance/end_with.rb#62
1155
+ def on_send(node); end
1156
+
1157
+ # source://rubocop-performance//lib/rubocop/cop/performance/end_with.rb#56
1158
+ def redundant_regex?(param0 = T.unsafe(nil)); end
1159
+ end
1160
+
1161
+ # source://rubocop-performance//lib/rubocop/cop/performance/end_with.rb#53
1162
+ RuboCop::Cop::Performance::EndWith::MSG = T.let(T.unsafe(nil), String)
1163
+
1164
+ # source://rubocop-performance//lib/rubocop/cop/performance/end_with.rb#54
1165
+ RuboCop::Cop::Performance::EndWith::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1166
+
1167
+ # Do not compute the size of statically sized objects.
1168
+ #
1169
+ # @example
1170
+ # # String methods
1171
+ # # bad
1172
+ # 'foo'.size
1173
+ # %q[bar].count
1174
+ # %(qux).length
1175
+ #
1176
+ # # Symbol methods
1177
+ # # bad
1178
+ # :fred.size
1179
+ # :'baz'.length
1180
+ #
1181
+ # # Array methods
1182
+ # # bad
1183
+ # [1, 2, thud].count
1184
+ # %W(1, 2, bar).size
1185
+ #
1186
+ # # Hash methods
1187
+ # # bad
1188
+ # { a: corge, b: grault }.length
1189
+ #
1190
+ # # good
1191
+ # foo.size
1192
+ # bar.count
1193
+ # qux.length
1194
+ #
1195
+ # # good
1196
+ # :"#{fred}".size
1197
+ # CONST = :baz.length
1198
+ #
1199
+ # # good
1200
+ # [1, 2, *thud].count
1201
+ # garply = [1, 2, 3]
1202
+ # garply.size
1203
+ #
1204
+ # # good
1205
+ # { a: corge, **grault }.length
1206
+ # waldo = { a: corge, b: grault }
1207
+ # waldo.size
1208
+ #
1209
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#48
1210
+ class RuboCop::Cop::Performance::FixedSize < ::RuboCop::Cop::Base
1211
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#52
1212
+ def counter(param0 = T.unsafe(nil)); end
1213
+
1214
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#56
1215
+ def on_send(node); end
1216
+
1217
+ private
1218
+
1219
+ # @return [Boolean]
1220
+ #
1221
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#72
1222
+ def allowed_argument?(arg); end
1223
+
1224
+ # @return [Boolean]
1225
+ #
1226
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#76
1227
+ def allowed_parent?(node); end
1228
+
1229
+ # @return [Boolean]
1230
+ #
1231
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#68
1232
+ def allowed_variable?(var); end
1233
+
1234
+ # @return [Boolean]
1235
+ #
1236
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#86
1237
+ def contains_double_splat?(node); end
1238
+
1239
+ # @return [Boolean]
1240
+ #
1241
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#80
1242
+ def contains_splat?(node); end
1243
+
1244
+ # @return [Boolean]
1245
+ #
1246
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#92
1247
+ def non_string_argument?(node); end
1248
+ end
1249
+
1250
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#49
1251
+ RuboCop::Cop::Performance::FixedSize::MSG = T.let(T.unsafe(nil), String)
1252
+
1253
+ # source://rubocop-performance//lib/rubocop/cop/performance/fixed_size.rb#50
1254
+ RuboCop::Cop::Performance::FixedSize::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1255
+
1256
+ # Identifies usages of `map { ... }.flatten` and
1257
+ # change them to use `flat_map { ... }` instead.
1258
+ #
1259
+ # @example
1260
+ # # bad
1261
+ # [1, 2, 3, 4].map { |e| [e, e] }.flatten(1)
1262
+ # [1, 2, 3, 4].collect { |e| [e, e] }.flatten(1)
1263
+ #
1264
+ # # good
1265
+ # [1, 2, 3, 4].flat_map { |e| [e, e] }
1266
+ # [1, 2, 3, 4].map { |e| [e, e] }.flatten
1267
+ # [1, 2, 3, 4].collect { |e| [e, e] }.flatten
1268
+ #
1269
+ # source://rubocop-performance//lib/rubocop/cop/performance/flat_map.rb#18
1270
+ class RuboCop::Cop::Performance::FlatMap < ::RuboCop::Cop::Base
1271
+ include ::RuboCop::Cop::RangeHelp
1272
+ extend ::RuboCop::Cop::AutoCorrector
1273
+
1274
+ # source://rubocop-performance//lib/rubocop/cop/performance/flat_map.rb#28
1275
+ def flat_map_candidate?(param0 = T.unsafe(nil)); end
1276
+
1277
+ # source://rubocop-performance//lib/rubocop/cop/performance/flat_map.rb#39
1278
+ def on_send(node); end
1279
+
1280
+ private
1281
+
1282
+ # source://rubocop-performance//lib/rubocop/cop/performance/flat_map.rb#72
1283
+ def autocorrect(corrector, node); end
1284
+
1285
+ # source://rubocop-performance//lib/rubocop/cop/performance/flat_map.rb#52
1286
+ def offense_for_levels(node, map_node, first_method, flatten); end
1287
+
1288
+ # source://rubocop-performance//lib/rubocop/cop/performance/flat_map.rb#58
1289
+ def offense_for_method(node, map_node, first_method, flatten); end
1290
+
1291
+ # source://rubocop-performance//lib/rubocop/cop/performance/flat_map.rb#62
1292
+ def register_offense(node, map_node, first_method, flatten, message); end
1293
+ end
1294
+
1295
+ # source://rubocop-performance//lib/rubocop/cop/performance/flat_map.rb#24
1296
+ RuboCop::Cop::Performance::FlatMap::FLATTEN_MULTIPLE_LEVELS = T.let(T.unsafe(nil), String)
1297
+
1298
+ # source://rubocop-performance//lib/rubocop/cop/performance/flat_map.rb#22
1299
+ RuboCop::Cop::Performance::FlatMap::MSG = T.let(T.unsafe(nil), String)
1300
+
1301
+ # source://rubocop-performance//lib/rubocop/cop/performance/flat_map.rb#23
1302
+ RuboCop::Cop::Performance::FlatMap::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1303
+
1304
+ # Checks for inefficient searching of keys and values within
1305
+ # hashes.
1306
+ #
1307
+ # `Hash#keys.include?` is less efficient than `Hash#key?` because
1308
+ # the former allocates a new array and then performs an O(n) search
1309
+ # through that array, while `Hash#key?` does not allocate any array and
1310
+ # performs a faster O(1) search for the key.
1311
+ #
1312
+ # `Hash#values.include?` is less efficient than `Hash#value?`. While they
1313
+ # both perform an O(n) search through all of the values, calling `values`
1314
+ # allocates a new array while using `value?` does not.
1315
+ #
1316
+ # @example
1317
+ # # bad
1318
+ # { a: 1, b: 2 }.keys.include?(:a)
1319
+ # { a: 1, b: 2 }.keys.include?(:z)
1320
+ # h = { a: 1, b: 2 }; h.keys.include?(100)
1321
+ #
1322
+ # # good
1323
+ # { a: 1, b: 2 }.key?(:a)
1324
+ # { a: 1, b: 2 }.has_key?(:z)
1325
+ # h = { a: 1, b: 2 }; h.key?(100)
1326
+ #
1327
+ # # bad
1328
+ # { a: 1, b: 2 }.values.include?(2)
1329
+ # { a: 1, b: 2 }.values.include?('garbage')
1330
+ # h = { a: 1, b: 2 }; h.values.include?(nil)
1331
+ #
1332
+ # # good
1333
+ # { a: 1, b: 2 }.value?(2)
1334
+ # { a: 1, b: 2 }.has_value?('garbage')
1335
+ # h = { a: 1, b: 2 }; h.value?(nil)
1336
+ #
1337
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#42
1338
+ class RuboCop::Cop::Performance::InefficientHashSearch < ::RuboCop::Cop::Base
1339
+ extend ::RuboCop::Cop::AutoCorrector
1340
+
1341
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#47
1342
+ def inefficient_include?(param0 = T.unsafe(nil)); end
1343
+
1344
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#51
1345
+ def on_csend(node); end
1346
+
1347
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#51
1348
+ def on_send(node); end
1349
+
1350
+ private
1351
+
1352
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#91
1353
+ def correct_argument(node); end
1354
+
1355
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#99
1356
+ def correct_dot(node); end
1357
+
1358
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#95
1359
+ def correct_hash_expression(node); end
1360
+
1361
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#75
1362
+ def correct_method(node); end
1363
+
1364
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#82
1365
+ def current_method(node); end
1366
+
1367
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#67
1368
+ def message(node); end
1369
+
1370
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#71
1371
+ def replacement(node); end
1372
+
1373
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#86
1374
+ def use_long_method; end
1375
+ end
1376
+
1377
+ # source://rubocop-performance//lib/rubocop/cop/performance/inefficient_hash_search.rb#45
1378
+ RuboCop::Cop::Performance::InefficientHashSearch::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1379
+
1380
+ # Identifies places where inefficient `readlines` method
1381
+ # can be replaced by `each_line` to avoid fully loading file content into memory.
1382
+ #
1383
+ # @example
1384
+ #
1385
+ # # bad
1386
+ # File.readlines('testfile').each { |l| puts l }
1387
+ # IO.readlines('testfile', chomp: true).each { |l| puts l }
1388
+ #
1389
+ # conn.readlines(10).map { |l| l.size }
1390
+ # file.readlines.find { |l| l.start_with?('#') }
1391
+ # file.readlines.each { |l| puts l }
1392
+ #
1393
+ # # good
1394
+ # File.open('testfile', 'r').each_line { |l| puts l }
1395
+ # IO.open('testfile').each_line(chomp: true) { |l| puts l }
1396
+ #
1397
+ # conn.each_line(10).map { |l| l.size }
1398
+ # file.each_line.find { |l| l.start_with?('#') }
1399
+ # file.each_line { |l| puts l }
1400
+ #
1401
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#27
1402
+ class RuboCop::Cop::Performance::IoReadlines < ::RuboCop::Cop::Base
1403
+ include ::RuboCop::Cop::RangeHelp
1404
+ extend ::RuboCop::Cop::AutoCorrector
1405
+
1406
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#42
1407
+ def on_send(node); end
1408
+
1409
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#34
1410
+ def readlines_on_class?(param0 = T.unsafe(nil)); end
1411
+
1412
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#38
1413
+ def readlines_on_instance?(param0 = T.unsafe(nil)); end
1414
+
1415
+ private
1416
+
1417
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#58
1418
+ def autocorrect(corrector, enumerable_call, readlines_call, receiver); end
1419
+
1420
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#90
1421
+ def build_bad_method(enumerable_call); end
1422
+
1423
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#106
1424
+ def build_call_args(call_args_node); end
1425
+
1426
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#82
1427
+ def build_good_method(enumerable_call); end
1428
+
1429
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#94
1430
+ def correction_range(enumerable_call, readlines_call); end
1431
+
1432
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#76
1433
+ def offense_range(enumerable_call, readlines_call); end
1434
+ end
1435
+
1436
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#31
1437
+ RuboCop::Cop::Performance::IoReadlines::MSG = T.let(T.unsafe(nil), String)
1438
+
1439
+ # source://rubocop-performance//lib/rubocop/cop/performance/io_readlines.rb#32
1440
+ RuboCop::Cop::Performance::IoReadlines::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1441
+
1442
+ # In Ruby 2.7, `Enumerable#filter_map` has been added.
1443
+ #
1444
+ # This cop identifies places where `map { ... }.compact` can be replaced by `filter_map`.
1445
+ #
1446
+ # [source,ruby]
1447
+ # ----
1448
+ # [true, false, nil].compact #=> [true, false]
1449
+ # [true, false, nil].filter_map(&:itself) #=> [true]
1450
+ # ----
1451
+ #
1452
+ # @example
1453
+ # # bad
1454
+ # ary.map(&:foo).compact
1455
+ # ary.collect(&:foo).compact
1456
+ #
1457
+ # # good
1458
+ # ary.filter_map(&:foo)
1459
+ # ary.map(&:foo).compact!
1460
+ # ary.compact.map(&:foo)
1461
+ #
1462
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#30
1463
+ class RuboCop::Cop::Performance::MapCompact < ::RuboCop::Cop::Base
1464
+ include ::RuboCop::Cop::RangeHelp
1465
+ extend ::RuboCop::Cop::AutoCorrector
1466
+ extend ::RuboCop::Cop::TargetRubyVersion
1467
+
1468
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#40
1469
+ def map_compact(param0 = T.unsafe(nil)); end
1470
+
1471
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#53
1472
+ def on_csend(node); end
1473
+
1474
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#53
1475
+ def on_send(node); end
1476
+
1477
+ private
1478
+
1479
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#94
1480
+ def compact_method_with_final_newline_range(compact_method_range); end
1481
+
1482
+ # @return [Boolean]
1483
+ #
1484
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#90
1485
+ def invoke_method_after_map_compact_on_same_line?(compact_node, chained_method); end
1486
+
1487
+ # @return [Boolean]
1488
+ #
1489
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#86
1490
+ def map_method_and_compact_method_on_same_line?(map_node, compact_node); end
1491
+
1492
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#68
1493
+ def remove_compact_method(corrector, map_node, compact_node, chained_method); end
1494
+
1495
+ # @return [Boolean]
1496
+ #
1497
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#82
1498
+ def use_dot?(node); end
1499
+ end
1500
+
1501
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#35
1502
+ RuboCop::Cop::Performance::MapCompact::MSG = T.let(T.unsafe(nil), String)
1503
+
1504
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_compact.rb#36
1505
+ RuboCop::Cop::Performance::MapCompact::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1506
+
1507
+ # Checks if the map method is used in a chain.
1508
+ #
1509
+ # Autocorrection is not supported because an appropriate block variable name cannot be determined automatically.
1510
+ #
1511
+ # [source,ruby]
1512
+ # ----
1513
+ # class X
1514
+ # def initialize
1515
+ # @@num = 0
1516
+ # end
1517
+ #
1518
+ # def foo
1519
+ # @@num += 1
1520
+ # self
1521
+ # end
1522
+ #
1523
+ # def bar
1524
+ # @@num * 2
1525
+ # end
1526
+ # end
1527
+ #
1528
+ # [X.new, X.new].map(&:foo).map(&:bar) # => [4, 4]
1529
+ # [X.new, X.new].map { |x| x.foo.bar } # => [2, 4]
1530
+ # ----
1531
+ #
1532
+ # @example
1533
+ #
1534
+ # # bad
1535
+ # array.map(&:foo).map(&:bar)
1536
+ #
1537
+ # # good
1538
+ # array.map { |item| item.foo.bar }
1539
+ #
1540
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_method_chain.rb#43
1541
+ class RuboCop::Cop::Performance::MapMethodChain < ::RuboCop::Cop::Base
1542
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_method_chain.rb#49
1543
+ def block_pass_with_symbol_arg?(param0 = T.unsafe(nil)); end
1544
+
1545
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_method_chain.rb#53
1546
+ def on_send(node); end
1547
+
1548
+ private
1549
+
1550
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_method_chain.rb#71
1551
+ def find_begin_of_chained_map_method(node, map_args); end
1552
+ end
1553
+
1554
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_method_chain.rb#46
1555
+ RuboCop::Cop::Performance::MapMethodChain::MSG = T.let(T.unsafe(nil), String)
1556
+
1557
+ # source://rubocop-performance//lib/rubocop/cop/performance/map_method_chain.rb#47
1558
+ RuboCop::Cop::Performance::MapMethodChain::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1559
+
1560
+ # Identifies places where methods are converted to blocks, with the
1561
+ # use of `&method`, and passed as arguments to method calls.
1562
+ # It is faster to replace those with explicit blocks, calling those methods inside.
1563
+ #
1564
+ # @example
1565
+ # # bad
1566
+ # array.map(&method(:do_something))
1567
+ # [1, 2, 3].each(&out.method(:puts))
1568
+ #
1569
+ # # good
1570
+ # array.map { |x| do_something(x) }
1571
+ # [1, 2, 3].each { |x| out.puts(x) }
1572
+ #
1573
+ # source://rubocop-performance//lib/rubocop/cop/performance/method_object_as_block.rb#19
1574
+ class RuboCop::Cop::Performance::MethodObjectAsBlock < ::RuboCop::Cop::Base
1575
+ # source://rubocop-performance//lib/rubocop/cop/performance/method_object_as_block.rb#22
1576
+ def method_object_as_argument?(param0 = T.unsafe(nil)); end
1577
+
1578
+ # source://rubocop-performance//lib/rubocop/cop/performance/method_object_as_block.rb#26
1579
+ def on_block_pass(node); end
1580
+ end
1581
+
1582
+ # source://rubocop-performance//lib/rubocop/cop/performance/method_object_as_block.rb#20
1583
+ RuboCop::Cop::Performance::MethodObjectAsBlock::MSG = T.let(T.unsafe(nil), String)
1584
+
1585
+ # Checks for `OpenStruct.new` calls.
1586
+ # Instantiation of an `OpenStruct` invalidates
1587
+ # Ruby global method cache as it causes dynamic method
1588
+ # definition during program runtime.
1589
+ # This could have an effect on performance,
1590
+ # especially in case of single-threaded
1591
+ # applications with multiple `OpenStruct` instantiations.
1592
+ #
1593
+ # @example
1594
+ # # bad
1595
+ # class MyClass
1596
+ # def my_method
1597
+ # OpenStruct.new(my_key1: 'my_value1', my_key2: 'my_value2')
1598
+ # end
1599
+ # end
1600
+ #
1601
+ # # good
1602
+ # class MyClass
1603
+ # MyStruct = Struct.new(:my_key1, :my_key2)
1604
+ # def my_method
1605
+ # MyStruct.new('my_value1', 'my_value2')
1606
+ # end
1607
+ # end
1608
+ #
1609
+ # source://rubocop-performance//lib/rubocop/cop/performance/open_struct.rb#34
1610
+ class RuboCop::Cop::Performance::OpenStruct < ::RuboCop::Cop::Base
1611
+ # source://rubocop-performance//lib/rubocop/cop/performance/open_struct.rb#42
1612
+ def on_send(node); end
1613
+
1614
+ # source://rubocop-performance//lib/rubocop/cop/performance/open_struct.rb#38
1615
+ def open_struct(param0 = T.unsafe(nil)); end
1616
+ end
1617
+
1618
+ # source://rubocop-performance//lib/rubocop/cop/performance/open_struct.rb#35
1619
+ RuboCop::Cop::Performance::OpenStruct::MSG = T.let(T.unsafe(nil), String)
1620
+
1621
+ # source://rubocop-performance//lib/rubocop/cop/performance/open_struct.rb#36
1622
+ RuboCop::Cop::Performance::OpenStruct::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1623
+
1624
+ # Identifies uses of `Range#include?` and `Range#member?`, which iterates over each
1625
+ # item in a `Range` to see if a specified item is there. In contrast,
1626
+ # `Range#cover?` simply compares the target item with the beginning and
1627
+ # end points of the `Range`. In a great majority of cases, this is what
1628
+ # is wanted.
1629
+ #
1630
+ # @example
1631
+ # # bad
1632
+ # ('a'..'z').include?('b') # => true
1633
+ # ('a'..'z').member?('b') # => true
1634
+ #
1635
+ # # good
1636
+ # ('a'..'z').cover?('b') # => true
1637
+ #
1638
+ # source://rubocop-performance//lib/rubocop/cop/performance/range_include.rb#29
1639
+ class RuboCop::Cop::Performance::RangeInclude < ::RuboCop::Cop::Base
1640
+ extend ::RuboCop::Cop::AutoCorrector
1641
+
1642
+ # source://rubocop-performance//lib/rubocop/cop/performance/range_include.rb#44
1643
+ def on_send(node); end
1644
+
1645
+ # source://rubocop-performance//lib/rubocop/cop/performance/range_include.rb#40
1646
+ def range_include(param0 = T.unsafe(nil)); end
1647
+ end
1648
+
1649
+ # source://rubocop-performance//lib/rubocop/cop/performance/range_include.rb#32
1650
+ RuboCop::Cop::Performance::RangeInclude::MSG = T.let(T.unsafe(nil), String)
1651
+
1652
+ # source://rubocop-performance//lib/rubocop/cop/performance/range_include.rb#33
1653
+ RuboCop::Cop::Performance::RangeInclude::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1654
+
1655
+ # Identifies the use of a `&block` parameter and `block.call`
1656
+ # where `yield` would do just as well.
1657
+ #
1658
+ # @example
1659
+ # # bad
1660
+ # def method(&block)
1661
+ # block.call
1662
+ # end
1663
+ # def another(&func)
1664
+ # func.call 1, 2, 3
1665
+ # end
1666
+ #
1667
+ # # good
1668
+ # def method
1669
+ # yield
1670
+ # end
1671
+ # def another
1672
+ # yield 1, 2, 3
1673
+ # end
1674
+ #
1675
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#25
1676
+ class RuboCop::Cop::Performance::RedundantBlockCall < ::RuboCop::Cop::Base
1677
+ extend ::RuboCop::Cop::AutoCorrector
1678
+
1679
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#43
1680
+ def blockarg_assigned?(param0, param1); end
1681
+
1682
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#39
1683
+ def blockarg_calls(param0, param1); end
1684
+
1685
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#34
1686
+ def blockarg_def(param0 = T.unsafe(nil)); end
1687
+
1688
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#47
1689
+ def on_def(node); end
1690
+
1691
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#47
1692
+ def on_defs(node); end
1693
+
1694
+ private
1695
+
1696
+ # @return [Boolean]
1697
+ #
1698
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#97
1699
+ def args_include_block_pass?(blockcall); end
1700
+
1701
+ # offenses are registered on the `block.call` nodes
1702
+ #
1703
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#63
1704
+ def autocorrect(corrector, node); end
1705
+
1706
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#81
1707
+ def calls_to_report(argname, body); end
1708
+
1709
+ # @return [Boolean]
1710
+ #
1711
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#91
1712
+ def shadowed_block_argument?(body, block_argument_of_method_signature); end
1713
+ end
1714
+
1715
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#31
1716
+ RuboCop::Cop::Performance::RedundantBlockCall::CLOSE_PAREN = T.let(T.unsafe(nil), String)
1717
+
1718
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#28
1719
+ RuboCop::Cop::Performance::RedundantBlockCall::MSG = T.let(T.unsafe(nil), String)
1720
+
1721
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#30
1722
+ RuboCop::Cop::Performance::RedundantBlockCall::OPEN_PAREN = T.let(T.unsafe(nil), String)
1723
+
1724
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#32
1725
+ RuboCop::Cop::Performance::RedundantBlockCall::SPACE = T.let(T.unsafe(nil), String)
1726
+
1727
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_block_call.rb#29
1728
+ RuboCop::Cop::Performance::RedundantBlockCall::YIELD = T.let(T.unsafe(nil), String)
1729
+
1730
+ # Checks for uses `Enumerable#all?`, `Enumerable#any?`, `Enumerable#one?`,
1731
+ # and `Enumerable#none?` are compared with `===` or similar methods in block.
1732
+ #
1733
+ # By default, `Object#===` behaves the same as `Object#==`, but this
1734
+ # behavior is appropriately overridden in subclass. For example,
1735
+ # `Range#===` returns `true` when argument is within the range.
1736
+ #
1737
+ # This cop has `AllowRegexpMatch` option and it is true by default because
1738
+ # `regexp.match?('string')` often used in block changes to the opposite result:
1739
+ #
1740
+ # [source,ruby]
1741
+ # ----
1742
+ # [/pattern/].all? { |regexp| regexp.match?('pattern') } # => true
1743
+ # [/pattern/].all? { |regexp| regexp =~ 'pattern' } # => true
1744
+ # [/pattern/].all?('pattern') # => false
1745
+ # ----
1746
+ #
1747
+ # @example
1748
+ # # bad
1749
+ # items.all? { |item| pattern === item }
1750
+ # items.all? { |item| item == other }
1751
+ # items.all? { |item| item.is_a?(Klass) }
1752
+ # items.all? { |item| item.kind_of?(Klass) }
1753
+ #
1754
+ # # good
1755
+ # items.all?(pattern)
1756
+ # items.all?(Klass)
1757
+ # @example AllowRegexpMatch: true (default)
1758
+ #
1759
+ # # good
1760
+ # items.all? { |item| item =~ pattern }
1761
+ # items.all? { |item| item.match?(pattern) }
1762
+ # @example AllowRegexpMatch: false
1763
+ #
1764
+ # # bad
1765
+ # items.all? { |item| item =~ pattern }
1766
+ # items.all? { |item| item.match?(pattern) }
1767
+ #
1768
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#49
1769
+ class RuboCop::Cop::Performance::RedundantEqualityComparisonBlock < ::RuboCop::Cop::Base
1770
+ extend ::RuboCop::Cop::AutoCorrector
1771
+ extend ::RuboCop::Cop::TargetRubyVersion
1772
+
1773
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#62
1774
+ def on_block(node); end
1775
+
1776
+ private
1777
+
1778
+ # @return [Boolean]
1779
+ #
1780
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#131
1781
+ def allow_regexp_match?; end
1782
+
1783
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#104
1784
+ def new_argument(block_argument, block_body); end
1785
+
1786
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#127
1787
+ def offense_range(node); end
1788
+
1789
+ # @return [Boolean]
1790
+ #
1791
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#82
1792
+ def one_block_argument?(block_arguments); end
1793
+
1794
+ # @return [Boolean]
1795
+ #
1796
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#94
1797
+ def same_block_argument_and_is_a_argument?(block_body, block_argument); end
1798
+
1799
+ # @return [Boolean]
1800
+ #
1801
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#118
1802
+ def use_block_argument_in_method_argument_of_operand?(block_argument, operand); end
1803
+
1804
+ # @return [Boolean]
1805
+ #
1806
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#86
1807
+ def use_equality_comparison_block?(block_body); end
1808
+ end
1809
+
1810
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#58
1811
+ RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::COMPARISON_METHODS = T.let(T.unsafe(nil), Array)
1812
+
1813
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#60
1814
+ RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::IS_A_METHODS = T.let(T.unsafe(nil), Array)
1815
+
1816
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#55
1817
+ RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::MSG = T.let(T.unsafe(nil), String)
1818
+
1819
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#59
1820
+ RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::REGEXP_METHODS = T.let(T.unsafe(nil), Array)
1821
+
1822
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_equality_comparison_block.rb#57
1823
+ RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::TARGET_METHODS = T.let(T.unsafe(nil), Array)
1824
+
1825
+ # Identifies the use of `Regexp#match` or `String#match`, which
1826
+ # returns `#<MatchData>`/`nil`. The return value of `=~` is an integral
1827
+ # index/`nil` and is more performant.
1828
+ #
1829
+ # @example
1830
+ # # bad
1831
+ # do_something if str.match(/regex/)
1832
+ # while regex.match('str')
1833
+ # do_something
1834
+ # end
1835
+ #
1836
+ # # good
1837
+ # method(str =~ /regex/)
1838
+ # return value unless regex =~ 'str'
1839
+ #
1840
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#20
1841
+ class RuboCop::Cop::Performance::RedundantMatch < ::RuboCop::Cop::Base
1842
+ extend ::RuboCop::Cop::AutoCorrector
1843
+
1844
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#30
1845
+ def match_call?(param0 = T.unsafe(nil)); end
1846
+
1847
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#39
1848
+ def on_send(node); end
1849
+
1850
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#35
1851
+ def only_truthiness_matters?(param0 = T.unsafe(nil)); end
1852
+
1853
+ private
1854
+
1855
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#51
1856
+ def autocorrect(corrector, node); end
1857
+
1858
+ # @return [Boolean]
1859
+ #
1860
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#57
1861
+ def autocorrectable?(node); end
1862
+
1863
+ # @return [Boolean]
1864
+ #
1865
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#86
1866
+ def call_like?(arg); end
1867
+
1868
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#63
1869
+ def replacement(node); end
1870
+
1871
+ # @return [Boolean]
1872
+ #
1873
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#73
1874
+ def requires_parentheses?(arg); end
1875
+
1876
+ # @return [Boolean]
1877
+ #
1878
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#80
1879
+ def requires_parentheses_for_call_like?(arg); end
1880
+ end
1881
+
1882
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#26
1883
+ RuboCop::Cop::Performance::RedundantMatch::HIGHER_PRECEDENCE_OPERATOR_METHODS = T.let(T.unsafe(nil), Array)
1884
+
1885
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#23
1886
+ RuboCop::Cop::Performance::RedundantMatch::MSG = T.let(T.unsafe(nil), String)
1887
+
1888
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_match.rb#24
1889
+ RuboCop::Cop::Performance::RedundantMatch::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1890
+
1891
+ # Identifies places where `Hash#merge!` can be replaced by `Hash#[]=`.
1892
+ # You can set the maximum number of key-value pairs to consider
1893
+ # an offense with `MaxKeyValuePairs`.
1894
+ #
1895
+ # @example
1896
+ # # bad
1897
+ # hash.merge!(a: 1)
1898
+ # hash.merge!({'key' => 'value'})
1899
+ #
1900
+ # # good
1901
+ # hash[:a] = 1
1902
+ # hash['key'] = 'value'
1903
+ # @example MaxKeyValuePairs: 2 (default)
1904
+ # # bad
1905
+ # hash.merge!(a: 1, b: 2)
1906
+ #
1907
+ # # good
1908
+ # hash[:a] = 1
1909
+ # hash[:b] = 2
1910
+ #
1911
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#30
1912
+ class RuboCop::Cop::Performance::RedundantMerge < ::RuboCop::Cop::Base
1913
+ include ::RuboCop::Cop::Alignment
1914
+ extend ::RuboCop::Cop::AutoCorrector
1915
+
1916
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#48
1917
+ def modifier_flow_control?(param0 = T.unsafe(nil)); end
1918
+
1919
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#52
1920
+ def on_send(node); end
1921
+
1922
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#44
1923
+ def redundant_merge_candidate(param0 = T.unsafe(nil)); end
1924
+
1925
+ private
1926
+
1927
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#106
1928
+ def correct_multiple_elements(corrector, node, parent, new_source); end
1929
+
1930
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#118
1931
+ def correct_single_element(corrector, node, new_source); end
1932
+
1933
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#79
1934
+ def each_redundant_merge(node); end
1935
+
1936
+ # @return [Boolean]
1937
+ #
1938
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#98
1939
+ def kwsplat_used?(pairs); end
1940
+
1941
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#144
1942
+ def leading_spaces(node); end
1943
+
1944
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#148
1945
+ def max_key_value_pairs; end
1946
+
1947
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#71
1948
+ def message(node); end
1949
+
1950
+ # @return [Boolean]
1951
+ #
1952
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#87
1953
+ def non_redundant_merge?(node, receiver, pairs); end
1954
+
1955
+ # @return [Boolean]
1956
+ #
1957
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#94
1958
+ def non_redundant_pairs?(receiver, pairs); end
1959
+
1960
+ # @return [Boolean]
1961
+ #
1962
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#102
1963
+ def non_redundant_value_used?(receiver, node); end
1964
+
1965
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#132
1966
+ def rewrite_with_modifier(node, parent, new_source); end
1967
+
1968
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#122
1969
+ def to_assignments(receiver, pairs); end
1970
+ end
1971
+
1972
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#34
1973
+ RuboCop::Cop::Performance::RedundantMerge::AREF_ASGN = T.let(T.unsafe(nil), String)
1974
+
1975
+ # A utility class for checking the use of values within an
1976
+ # `each_with_object` call.
1977
+ #
1978
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#154
1979
+ class RuboCop::Cop::Performance::RedundantMerge::EachWithObjectInspector
1980
+ extend ::RuboCop::AST::NodePattern::Macros
1981
+
1982
+ # @return [EachWithObjectInspector] a new instance of EachWithObjectInspector
1983
+ #
1984
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#157
1985
+ def initialize(node, receiver); end
1986
+
1987
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#188
1988
+ def each_with_object_node(param0 = T.unsafe(nil)); end
1989
+
1990
+ # @return [Boolean]
1991
+ #
1992
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#162
1993
+ def value_used?; end
1994
+
1995
+ private
1996
+
1997
+ # @return [Boolean]
1998
+ #
1999
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#172
2000
+ def eligible_receiver?; end
2001
+
2002
+ # Returns the value of attribute node.
2003
+ #
2004
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#170
2005
+ def node; end
2006
+
2007
+ # Returns the value of attribute receiver.
2008
+ #
2009
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#170
2010
+ def receiver; end
2011
+
2012
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#176
2013
+ def second_argument; end
2014
+
2015
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#183
2016
+ def unwind(receiver); end
2017
+ end
2018
+
2019
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#35
2020
+ RuboCop::Cop::Performance::RedundantMerge::MSG = T.let(T.unsafe(nil), String)
2021
+
2022
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#36
2023
+ RuboCop::Cop::Performance::RedundantMerge::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2024
+
2025
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_merge.rb#38
2026
+ RuboCop::Cop::Performance::RedundantMerge::WITH_MODIFIER_CORRECTION = T.let(T.unsafe(nil), String)
2027
+
2028
+ # Identifies places where `sort { |a, b| a <=> b }` can be replaced with `sort`.
2029
+ #
2030
+ # @example
2031
+ # # bad
2032
+ # array.sort { |a, b| a <=> b }
2033
+ #
2034
+ # # good
2035
+ # array.sort
2036
+ #
2037
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_sort_block.rb#15
2038
+ class RuboCop::Cop::Performance::RedundantSortBlock < ::RuboCop::Cop::Base
2039
+ include ::RuboCop::Cop::RangeHelp
2040
+ include ::RuboCop::Cop::SortBlock
2041
+ extend ::RuboCop::Cop::AutoCorrector
2042
+
2043
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_sort_block.rb#21
2044
+ def on_block(node); end
2045
+
2046
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_sort_block.rb#29
2047
+ def on_numblock(node); end
2048
+
2049
+ private
2050
+
2051
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_sort_block.rb#40
2052
+ def register_offense(send, node); end
2053
+ end
2054
+
2055
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_sort_block.rb#19
2056
+ RuboCop::Cop::Performance::RedundantSortBlock::MSG = T.let(T.unsafe(nil), String)
2057
+
2058
+ # Identifies places where `split` argument can be replaced from
2059
+ # a deterministic regexp to a string.
2060
+ #
2061
+ # @example
2062
+ # # bad
2063
+ # 'a,b,c'.split(/,/)
2064
+ #
2065
+ # # good
2066
+ # 'a,b,c'.split(',')
2067
+ #
2068
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#15
2069
+ class RuboCop::Cop::Performance::RedundantSplitRegexpArgument < ::RuboCop::Cop::Base
2070
+ extend ::RuboCop::Cop::AutoCorrector
2071
+
2072
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#27
2073
+ def on_csend(node); end
2074
+
2075
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#27
2076
+ def on_send(node); end
2077
+
2078
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#23
2079
+ def split_call_with_regexp?(param0 = T.unsafe(nil)); end
2080
+
2081
+ private
2082
+
2083
+ # @return [Boolean]
2084
+ #
2085
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#42
2086
+ def determinist_regexp?(regexp_node); end
2087
+
2088
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#46
2089
+ def replacement(regexp_node); end
2090
+ end
2091
+
2092
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#20
2093
+ RuboCop::Cop::Performance::RedundantSplitRegexpArgument::DETERMINISTIC_REGEX = T.let(T.unsafe(nil), Regexp)
2094
+
2095
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#18
2096
+ RuboCop::Cop::Performance::RedundantSplitRegexpArgument::MSG = T.let(T.unsafe(nil), String)
2097
+
2098
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#19
2099
+ RuboCop::Cop::Performance::RedundantSplitRegexpArgument::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2100
+
2101
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_split_regexp_argument.rb#21
2102
+ RuboCop::Cop::Performance::RedundantSplitRegexpArgument::STR_SPECIAL_CHARS = T.let(T.unsafe(nil), Array)
2103
+
2104
+ # Checks for redundant `String#chars`.
2105
+ #
2106
+ # @example
2107
+ # # bad
2108
+ # str.chars[0..2]
2109
+ # str.chars.slice(0..2)
2110
+ # str.chars.last
2111
+ #
2112
+ # # good
2113
+ # str[0..2].chars
2114
+ #
2115
+ # # bad
2116
+ # str.chars.first
2117
+ # str.chars.first(2)
2118
+ #
2119
+ # # good
2120
+ # str[0]
2121
+ # str[0...2].chars
2122
+ # str[-1]
2123
+ #
2124
+ # # bad
2125
+ # str.chars.take(2)
2126
+ # str.chars.length
2127
+ # str.chars.size
2128
+ # str.chars.empty?
2129
+ #
2130
+ # # good
2131
+ # str[0...2].chars
2132
+ # str.length
2133
+ # str.size
2134
+ # str.empty?
2135
+ #
2136
+ # # For example, if the receiver is an empty string, it will be incompatible.
2137
+ # # If a negative value is specified for the receiver, `nil` is returned.
2138
+ # str.chars.last(2) # Incompatible with `str[-2..-1].chars`.
2139
+ # str.chars.drop(2) # Incompatible with `str[2..-1].chars`.
2140
+ #
2141
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#43
2142
+ class RuboCop::Cop::Performance::RedundantStringChars < ::RuboCop::Cop::Base
2143
+ include ::RuboCop::Cop::RangeHelp
2144
+ extend ::RuboCop::Cop::AutoCorrector
2145
+
2146
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#54
2147
+ def on_send(node); end
2148
+
2149
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#50
2150
+ def redundant_chars_call?(param0 = T.unsafe(nil)); end
2151
+
2152
+ private
2153
+
2154
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#112
2155
+ def build_bad_method(method, args); end
2156
+
2157
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#125
2158
+ def build_call_args(call_args_node); end
2159
+
2160
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#85
2161
+ def build_good_method(method, args); end
2162
+
2163
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#100
2164
+ def build_good_method_for_brackets_or_first_method(method, args); end
2165
+
2166
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#79
2167
+ def build_message(method, args); end
2168
+
2169
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#75
2170
+ def correction_range(receiver, node); end
2171
+
2172
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#71
2173
+ def offense_range(receiver, node); end
2174
+ end
2175
+
2176
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#47
2177
+ RuboCop::Cop::Performance::RedundantStringChars::MSG = T.let(T.unsafe(nil), String)
2178
+
2179
+ # source://rubocop-performance//lib/rubocop/cop/performance/redundant_string_chars.rb#48
2180
+ RuboCop::Cop::Performance::RedundantStringChars::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2181
+
2182
+ # In Ruby 2.4, `String#match?`, `Regexp#match?`, and `Symbol#match?`
2183
+ # have been added. The methods are faster than `match`.
2184
+ # Because the methods avoid creating a `MatchData` object or saving
2185
+ # backref.
2186
+ # So, when `MatchData` is not used, use `match?` instead of `match`.
2187
+ #
2188
+ # @example
2189
+ # # bad
2190
+ # def foo
2191
+ # if x =~ /re/
2192
+ # do_something
2193
+ # end
2194
+ # end
2195
+ #
2196
+ # # bad
2197
+ # def foo
2198
+ # if x !~ /re/
2199
+ # do_something
2200
+ # end
2201
+ # end
2202
+ #
2203
+ # # bad
2204
+ # def foo
2205
+ # if x.match(/re/)
2206
+ # do_something
2207
+ # end
2208
+ # end
2209
+ #
2210
+ # # bad
2211
+ # def foo
2212
+ # if /re/ === x
2213
+ # do_something
2214
+ # end
2215
+ # end
2216
+ #
2217
+ # # good
2218
+ # def foo
2219
+ # if x.match?(/re/)
2220
+ # do_something
2221
+ # end
2222
+ # end
2223
+ #
2224
+ # # good
2225
+ # def foo
2226
+ # if !x.match?(/re/)
2227
+ # do_something
2228
+ # end
2229
+ # end
2230
+ #
2231
+ # # good
2232
+ # def foo
2233
+ # if x =~ /re/
2234
+ # do_something(Regexp.last_match)
2235
+ # end
2236
+ # end
2237
+ #
2238
+ # # good
2239
+ # def foo
2240
+ # if x.match(/re/)
2241
+ # do_something($~)
2242
+ # end
2243
+ # end
2244
+ #
2245
+ # # good
2246
+ # def foo
2247
+ # if /re/ === x
2248
+ # do_something($~)
2249
+ # end
2250
+ # end
2251
+ #
2252
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#75
2253
+ class RuboCop::Cop::Performance::RegexpMatch < ::RuboCop::Cop::Base
2254
+ extend ::RuboCop::Cop::AutoCorrector
2255
+ extend ::RuboCop::Cop::TargetRubyVersion
2256
+
2257
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#125
2258
+ def last_matches(param0); end
2259
+
2260
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#86
2261
+ def match_method?(param0 = T.unsafe(nil)); end
2262
+
2263
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#122
2264
+ def match_node?(param0 = T.unsafe(nil)); end
2265
+
2266
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#97
2267
+ def match_operator?(param0 = T.unsafe(nil)); end
2268
+
2269
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#101
2270
+ def match_threequals?(param0 = T.unsafe(nil)); end
2271
+
2272
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#93
2273
+ def match_with_int_arg_method?(param0 = T.unsafe(nil)); end
2274
+
2275
+ # @return [Boolean]
2276
+ #
2277
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#105
2278
+ def match_with_lvasgn?(node); end
2279
+
2280
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#142
2281
+ def on_case(node); end
2282
+
2283
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#138
2284
+ def on_if(node); end
2285
+
2286
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#123
2287
+ def search_match_nodes(param0); end
2288
+
2289
+ private
2290
+
2291
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#165
2292
+ def autocorrect(corrector, node); end
2293
+
2294
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#154
2295
+ def check_condition(cond); end
2296
+
2297
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#250
2298
+ def correct_operator(corrector, recv, arg, oper = T.unsafe(nil)); end
2299
+
2300
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#275
2301
+ def correction_range(recv, arg); end
2302
+
2303
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#221
2304
+ def find_last_match(body, range, scope_root); end
2305
+
2306
+ # @return [Boolean]
2307
+ #
2308
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#181
2309
+ def last_match_used?(match_node); end
2310
+
2311
+ # @return [Boolean]
2312
+ #
2313
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#246
2314
+ def match_gvar?(sym); end
2315
+
2316
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#177
2317
+ def message(node); end
2318
+
2319
+ # @return [Boolean]
2320
+ #
2321
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#217
2322
+ def modifier_form?(match_node); end
2323
+
2324
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#203
2325
+ def next_match_pos(body, match_node_pos, scope_root); end
2326
+
2327
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#190
2328
+ def range_to_search_for_last_matches(match_node, body, scope_root); end
2329
+
2330
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#259
2331
+ def replace_with_match_predicate_method(corrector, recv, arg, op_range); end
2332
+
2333
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#228
2334
+ def scope_body(node); end
2335
+
2336
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#240
2337
+ def scope_root(node); end
2338
+
2339
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#270
2340
+ def swap_receiver_and_arg(corrector, recv, arg); end
2341
+
2342
+ class << self
2343
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#134
2344
+ def autocorrect_incompatible_with; end
2345
+ end
2346
+ end
2347
+
2348
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#112
2349
+ RuboCop::Cop::Performance::RegexpMatch::MATCH_NODE_PATTERN = T.let(T.unsafe(nil), String)
2350
+
2351
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#84
2352
+ RuboCop::Cop::Performance::RegexpMatch::MSG = T.let(T.unsafe(nil), String)
2353
+
2354
+ # Constants are included in this list because it is unlikely that
2355
+ # someone will store `nil` as a constant and then use it for comparison
2356
+ #
2357
+ # source://rubocop-performance//lib/rubocop/cop/performance/regexp_match.rb#83
2358
+ RuboCop::Cop::Performance::RegexpMatch::TYPES_IMPLEMENTING_MATCH = T.let(T.unsafe(nil), Array)
2359
+
2360
+ # Identifies usages of `reverse.each` and change them to use `reverse_each` instead.
2361
+ #
2362
+ # If the return value is used, it will not be detected because the result will be different.
2363
+ #
2364
+ # [source,ruby]
2365
+ # ----
2366
+ # [1, 2, 3].reverse.each {} #=> [3, 2, 1]
2367
+ # [1, 2, 3].reverse_each {} #=> [1, 2, 3]
2368
+ # ----
2369
+ #
2370
+ # @example
2371
+ # # bad
2372
+ # items.reverse.each
2373
+ #
2374
+ # # good
2375
+ # items.reverse_each
2376
+ #
2377
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#22
2378
+ class RuboCop::Cop::Performance::ReverseEach < ::RuboCop::Cop::Base
2379
+ include ::RuboCop::Cop::RangeHelp
2380
+ extend ::RuboCop::Cop::AutoCorrector
2381
+
2382
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#33
2383
+ def on_csend(node); end
2384
+
2385
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#33
2386
+ def on_send(node); end
2387
+
2388
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#29
2389
+ def reverse_each?(param0 = T.unsafe(nil)); end
2390
+
2391
+ private
2392
+
2393
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#54
2394
+ def offense_range(node); end
2395
+
2396
+ # @return [Boolean]
2397
+ #
2398
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#48
2399
+ def use_return_value?(node); end
2400
+ end
2401
+
2402
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#26
2403
+ RuboCop::Cop::Performance::ReverseEach::MSG = T.let(T.unsafe(nil), String)
2404
+
2405
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_each.rb#27
2406
+ RuboCop::Cop::Performance::ReverseEach::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2407
+
2408
+ # Identifies places where `reverse.first(n)` and `reverse.first`
2409
+ # can be replaced by `last(n).reverse` and `last`.
2410
+ #
2411
+ # @example
2412
+ #
2413
+ # # bad
2414
+ # array.reverse.first(5)
2415
+ # array.reverse.first
2416
+ #
2417
+ # # good
2418
+ # array.last(5).reverse
2419
+ # array.last
2420
+ #
2421
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#19
2422
+ class RuboCop::Cop::Performance::ReverseFirst < ::RuboCop::Cop::Base
2423
+ include ::RuboCop::Cop::RangeHelp
2424
+ extend ::RuboCop::Cop::AutoCorrector
2425
+
2426
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#30
2427
+ def on_csend(node); end
2428
+
2429
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#30
2430
+ def on_send(node); end
2431
+
2432
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#26
2433
+ def reverse_first_candidate?(param0 = T.unsafe(nil)); end
2434
+
2435
+ private
2436
+
2437
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#64
2438
+ def build_bad_method(node); end
2439
+
2440
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#56
2441
+ def build_good_method(node); end
2442
+
2443
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#50
2444
+ def build_message(node); end
2445
+
2446
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#46
2447
+ def correction_range(receiver, node); end
2448
+ end
2449
+
2450
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#23
2451
+ RuboCop::Cop::Performance::ReverseFirst::MSG = T.let(T.unsafe(nil), String)
2452
+
2453
+ # source://rubocop-performance//lib/rubocop/cop/performance/reverse_first.rb#24
2454
+ RuboCop::Cop::Performance::ReverseFirst::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2455
+
2456
+ # In Ruby 2.7, `Enumerable#filter_map` has been added.
2457
+ #
2458
+ # This cop identifies places where `select.map` can be replaced by `filter_map`.
2459
+ #
2460
+ # @example
2461
+ # # bad
2462
+ # ary.select(&:foo).map(&:bar)
2463
+ # ary.filter(&:foo).map(&:bar)
2464
+ #
2465
+ # # good
2466
+ # ary.filter_map { |o| o.bar if o.foo }
2467
+ #
2468
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#18
2469
+ class RuboCop::Cop::Performance::SelectMap < ::RuboCop::Cop::Base
2470
+ include ::RuboCop::Cop::RangeHelp
2471
+ extend ::RuboCop::Cop::TargetRubyVersion
2472
+
2473
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#27
2474
+ def bad_method?(param0 = T.unsafe(nil)); end
2475
+
2476
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#31
2477
+ def on_csend(node); end
2478
+
2479
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#31
2480
+ def on_send(node); end
2481
+
2482
+ private
2483
+
2484
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#45
2485
+ def map_method_candidate(node); end
2486
+
2487
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#55
2488
+ def offense_range(node, map_method); end
2489
+ end
2490
+
2491
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#24
2492
+ RuboCop::Cop::Performance::SelectMap::MSG = T.let(T.unsafe(nil), String)
2493
+
2494
+ # source://rubocop-performance//lib/rubocop/cop/performance/select_map.rb#25
2495
+ RuboCop::Cop::Performance::SelectMap::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2496
+
2497
+ # Identifies usages of `count` on an `Array` and `Hash` and change them to `size`.
2498
+ #
2499
+ # TODO: Add advanced detection of variables that could
2500
+ # have been assigned to an array or a hash.
2501
+ #
2502
+ # @example
2503
+ # # bad
2504
+ # [1, 2, 3].count
2505
+ # (1..3).to_a.count
2506
+ # Array[*1..3].count
2507
+ # Array(1..3).count
2508
+ #
2509
+ # # bad
2510
+ # {a: 1, b: 2, c: 3}.count
2511
+ # [[:foo, :bar], [1, 2]].to_h.count
2512
+ # Hash[*('a'..'z')].count
2513
+ # Hash(key: :value).count
2514
+ #
2515
+ # # good
2516
+ # [1, 2, 3].size
2517
+ # (1..3).to_a.size
2518
+ # Array[*1..3].size
2519
+ # Array(1..3).size
2520
+ #
2521
+ # # good
2522
+ # {a: 1, b: 2, c: 3}.size
2523
+ # [[:foo, :bar], [1, 2]].to_h.size
2524
+ # Hash[*('a'..'z')].size
2525
+ # Hash(key: :value).size
2526
+ #
2527
+ # # good
2528
+ # [1, 2, 3].count { |e| e > 2 }
2529
+ #
2530
+ # source://rubocop-performance//lib/rubocop/cop/performance/size.rb#37
2531
+ class RuboCop::Cop::Performance::Size < ::RuboCop::Cop::Base
2532
+ extend ::RuboCop::Cop::AutoCorrector
2533
+
2534
+ # source://rubocop-performance//lib/rubocop/cop/performance/size.rb#43
2535
+ def array?(param0 = T.unsafe(nil)); end
2536
+
2537
+ # source://rubocop-performance//lib/rubocop/cop/performance/size.rb#61
2538
+ def count?(param0 = T.unsafe(nil)); end
2539
+
2540
+ # source://rubocop-performance//lib/rubocop/cop/performance/size.rb#52
2541
+ def hash?(param0 = T.unsafe(nil)); end
2542
+
2543
+ # source://rubocop-performance//lib/rubocop/cop/performance/size.rb#65
2544
+ def on_send(node); end
2545
+ end
2546
+
2547
+ # source://rubocop-performance//lib/rubocop/cop/performance/size.rb#40
2548
+ RuboCop::Cop::Performance::Size::MSG = T.let(T.unsafe(nil), String)
2549
+
2550
+ # source://rubocop-performance//lib/rubocop/cop/performance/size.rb#41
2551
+ RuboCop::Cop::Performance::Size::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2552
+
2553
+ # Identifies places where `sort { |a, b| b <=> a }`
2554
+ # can be replaced by a faster `sort.reverse`.
2555
+ #
2556
+ # @example
2557
+ # # bad
2558
+ # array.sort { |a, b| b <=> a }
2559
+ #
2560
+ # # good
2561
+ # array.sort.reverse
2562
+ #
2563
+ # source://rubocop-performance//lib/rubocop/cop/performance/sort_reverse.rb#16
2564
+ class RuboCop::Cop::Performance::SortReverse < ::RuboCop::Cop::Base
2565
+ include ::RuboCop::Cop::RangeHelp
2566
+ include ::RuboCop::Cop::SortBlock
2567
+ extend ::RuboCop::Cop::AutoCorrector
2568
+
2569
+ # source://rubocop-performance//lib/rubocop/cop/performance/sort_reverse.rb#22
2570
+ def on_block(node); end
2571
+
2572
+ # source://rubocop-performance//lib/rubocop/cop/performance/sort_reverse.rb#30
2573
+ def on_numblock(node); end
2574
+
2575
+ private
2576
+
2577
+ # source://rubocop-performance//lib/rubocop/cop/performance/sort_reverse.rb#42
2578
+ def register_offense(send, node); end
2579
+ end
2580
+
2581
+ # source://rubocop-performance//lib/rubocop/cop/performance/sort_reverse.rb#20
2582
+ RuboCop::Cop::Performance::SortReverse::MSG = T.let(T.unsafe(nil), String)
2583
+
2584
+ # Identifies places where `gsub(/a+/, 'a')` and `gsub!(/a+/, 'a')`
2585
+ # can be replaced by `squeeze('a')` and `squeeze!('a')`.
2586
+ #
2587
+ # The `squeeze('a')` method is faster than `gsub(/a+/, 'a')`.
2588
+ #
2589
+ # @example
2590
+ #
2591
+ # # bad
2592
+ # str.gsub(/a+/, 'a')
2593
+ # str.gsub!(/a+/, 'a')
2594
+ #
2595
+ # # good
2596
+ # str.squeeze('a')
2597
+ # str.squeeze!('a')
2598
+ #
2599
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#21
2600
+ class RuboCop::Cop::Performance::Squeeze < ::RuboCop::Cop::Base
2601
+ extend ::RuboCop::Cop::AutoCorrector
2602
+
2603
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#39
2604
+ def on_csend(node); end
2605
+
2606
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#39
2607
+ def on_send(node); end
2608
+
2609
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#29
2610
+ def squeeze_candidate?(param0 = T.unsafe(nil)); end
2611
+
2612
+ private
2613
+
2614
+ # @return [Boolean]
2615
+ #
2616
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#61
2617
+ def repeating_literal?(regex_str); end
2618
+ end
2619
+
2620
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#24
2621
+ RuboCop::Cop::Performance::Squeeze::MSG = T.let(T.unsafe(nil), String)
2622
+
2623
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#27
2624
+ RuboCop::Cop::Performance::Squeeze::PREFERRED_METHODS = T.let(T.unsafe(nil), Hash)
2625
+
2626
+ # source://rubocop-performance//lib/rubocop/cop/performance/squeeze.rb#25
2627
+ RuboCop::Cop::Performance::Squeeze::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2628
+
2629
+ # Identifies unnecessary use of a regex where `String#start_with?` would suffice.
2630
+ #
2631
+ # This cop has `SafeMultiline` configuration option that `true` by default because
2632
+ # `^start` is unsafe as it will behave incompatible with `start_with?`
2633
+ # for receiver is multiline string.
2634
+ #
2635
+ # @example
2636
+ # # bad
2637
+ # 'abc'.match?(/\Aab/)
2638
+ # /\Aab/.match?('abc')
2639
+ # 'abc' =~ /\Aab/
2640
+ # /\Aab/ =~ 'abc'
2641
+ # 'abc'.match(/\Aab/)
2642
+ # /\Aab/.match('abc')
2643
+ #
2644
+ # # good
2645
+ # 'abc'.start_with?('ab')
2646
+ # @example SafeMultiline: true (default)
2647
+ #
2648
+ # # good
2649
+ # 'abc'.match?(/^ab/)
2650
+ # /^ab/.match?('abc')
2651
+ # 'abc' =~ /^ab/
2652
+ # /^ab/ =~ 'abc'
2653
+ # 'abc'.match(/^ab/)
2654
+ # /^ab/.match('abc')
2655
+ # @example SafeMultiline: false
2656
+ #
2657
+ # # bad
2658
+ # 'abc'.match?(/^ab/)
2659
+ # /^ab/.match?('abc')
2660
+ # 'abc' =~ /^ab/
2661
+ # /^ab/ =~ 'abc'
2662
+ # 'abc'.match(/^ab/)
2663
+ # /^ab/.match('abc')
2664
+ #
2665
+ # source://rubocop-performance//lib/rubocop/cop/performance/start_with.rb#49
2666
+ class RuboCop::Cop::Performance::StartWith < ::RuboCop::Cop::Base
2667
+ include ::RuboCop::Cop::RegexpMetacharacter
2668
+ extend ::RuboCop::Cop::AutoCorrector
2669
+
2670
+ # source://rubocop-performance//lib/rubocop/cop/performance/start_with.rb#62
2671
+ def on_csend(node); end
2672
+
2673
+ # source://rubocop-performance//lib/rubocop/cop/performance/start_with.rb#62
2674
+ def on_match_with_lvasgn(node); end
2675
+
2676
+ # source://rubocop-performance//lib/rubocop/cop/performance/start_with.rb#62
2677
+ def on_send(node); end
2678
+
2679
+ # source://rubocop-performance//lib/rubocop/cop/performance/start_with.rb#56
2680
+ def redundant_regex?(param0 = T.unsafe(nil)); end
2681
+ end
2682
+
2683
+ # source://rubocop-performance//lib/rubocop/cop/performance/start_with.rb#53
2684
+ RuboCop::Cop::Performance::StartWith::MSG = T.let(T.unsafe(nil), String)
2685
+
2686
+ # source://rubocop-performance//lib/rubocop/cop/performance/start_with.rb#54
2687
+ RuboCop::Cop::Performance::StartWith::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2688
+
2689
+ # Identifies places where string identifier argument can be replaced
2690
+ # by symbol identifier argument.
2691
+ # It prevents the redundancy of the internal string-to-symbol conversion.
2692
+ #
2693
+ # This cop targets methods that take identifier (e.g. method name) argument
2694
+ # and the following examples are parts of it.
2695
+ #
2696
+ # @example
2697
+ #
2698
+ # # bad
2699
+ # send('do_something')
2700
+ # attr_accessor 'do_something'
2701
+ # instance_variable_get('@ivar')
2702
+ #
2703
+ # # good
2704
+ # send(:do_something)
2705
+ # attr_accessor :do_something
2706
+ # instance_variable_get(:@ivar)
2707
+ #
2708
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_identifier_argument.rb#25
2709
+ class RuboCop::Cop::Performance::StringIdentifierArgument < ::RuboCop::Cop::Base
2710
+ extend ::RuboCop::Cop::AutoCorrector
2711
+
2712
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_identifier_argument.rb#48
2713
+ def on_send(node); end
2714
+ end
2715
+
2716
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_identifier_argument.rb#30
2717
+ RuboCop::Cop::Performance::StringIdentifierArgument::COMMAND_METHODS = T.let(T.unsafe(nil), Array)
2718
+
2719
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_identifier_argument.rb#28
2720
+ RuboCop::Cop::Performance::StringIdentifierArgument::MSG = T.let(T.unsafe(nil), String)
2721
+
2722
+ # NOTE: `attr` method is not included in this list as it can cause false positives in Nokogiri API.
2723
+ # And `attr` may not be used because `Style/Attr` registers an offense.
2724
+ # https://github.com/rubocop/rubocop-performance/issues/278
2725
+ #
2726
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_identifier_argument.rb#38
2727
+ RuboCop::Cop::Performance::StringIdentifierArgument::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2728
+
2729
+ # Identifies unnecessary use of a regex where `String#include?` would suffice.
2730
+ #
2731
+ # @example
2732
+ # # bad
2733
+ # str.match?(/ab/)
2734
+ # /ab/.match?(str)
2735
+ # str =~ /ab/
2736
+ # /ab/ =~ str
2737
+ # str.match(/ab/)
2738
+ # /ab/.match(str)
2739
+ #
2740
+ # # good
2741
+ # str.include?('ab')
2742
+ #
2743
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#22
2744
+ class RuboCop::Cop::Performance::StringInclude < ::RuboCop::Cop::Base
2745
+ extend ::RuboCop::Cop::AutoCorrector
2746
+
2747
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#35
2748
+ def on_csend(node); end
2749
+
2750
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#35
2751
+ def on_match_with_lvasgn(node); end
2752
+
2753
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#35
2754
+ def on_send(node); end
2755
+
2756
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#28
2757
+ def redundant_regex?(param0 = T.unsafe(nil)); end
2758
+
2759
+ private
2760
+
2761
+ # @return [Boolean]
2762
+ #
2763
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#57
2764
+ def literal?(regex_str); end
2765
+ end
2766
+
2767
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#25
2768
+ RuboCop::Cop::Performance::StringInclude::MSG = T.let(T.unsafe(nil), String)
2769
+
2770
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_include.rb#26
2771
+ RuboCop::Cop::Performance::StringInclude::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2772
+
2773
+ # Identifies places where `gsub` can be replaced by `tr` or `delete`.
2774
+ #
2775
+ # @example
2776
+ # # bad
2777
+ # 'abc'.gsub('b', 'd')
2778
+ # 'abc'.gsub('a', '')
2779
+ # 'abc'.gsub(/a/, 'd')
2780
+ # 'abc'.gsub!('a', 'd')
2781
+ #
2782
+ # # good
2783
+ # 'abc'.gsub(/.*/, 'a')
2784
+ # 'abc'.gsub(/a+/, 'd')
2785
+ # 'abc'.tr('b', 'd')
2786
+ # 'a b c'.delete(' ')
2787
+ #
2788
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#20
2789
+ class RuboCop::Cop::Performance::StringReplacement < ::RuboCop::Cop::Base
2790
+ include ::RuboCop::Cop::RangeHelp
2791
+ extend ::RuboCop::Cop::AutoCorrector
2792
+
2793
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#37
2794
+ def on_csend(node); end
2795
+
2796
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#37
2797
+ def on_send(node); end
2798
+
2799
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#31
2800
+ def string_replacement?(param0 = T.unsafe(nil)); end
2801
+
2802
+ private
2803
+
2804
+ # @return [Boolean]
2805
+ #
2806
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#84
2807
+ def accept_first_param?(first_param); end
2808
+
2809
+ # @return [Boolean]
2810
+ #
2811
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#79
2812
+ def accept_second_param?(second_param); end
2813
+
2814
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#60
2815
+ def autocorrect(corrector, node); end
2816
+
2817
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#100
2818
+ def first_source(first_param); end
2819
+
2820
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#143
2821
+ def message(node, first_source, second_source); end
2822
+
2823
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#149
2824
+ def method_suffix(node); end
2825
+
2826
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#49
2827
+ def offense(node, first_param, second_param); end
2828
+
2829
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#129
2830
+ def range(node); end
2831
+
2832
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#153
2833
+ def remove_second_param(corrector, node, first_param); end
2834
+
2835
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#70
2836
+ def replace_method(corrector, node, first_source, second_source, first_param); end
2837
+
2838
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#133
2839
+ def replacement_method(node, first_source, second_source); end
2840
+
2841
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#118
2842
+ def source_from_regex_constructor(node); end
2843
+
2844
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#111
2845
+ def source_from_regex_literal(node); end
2846
+ end
2847
+
2848
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#29
2849
+ RuboCop::Cop::Performance::StringReplacement::BANG = T.let(T.unsafe(nil), String)
2850
+
2851
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#27
2852
+ RuboCop::Cop::Performance::StringReplacement::DELETE = T.let(T.unsafe(nil), String)
2853
+
2854
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#26
2855
+ RuboCop::Cop::Performance::StringReplacement::DETERMINISTIC_REGEX = T.let(T.unsafe(nil), Regexp)
2856
+
2857
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#24
2858
+ RuboCop::Cop::Performance::StringReplacement::MSG = T.let(T.unsafe(nil), String)
2859
+
2860
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#25
2861
+ RuboCop::Cop::Performance::StringReplacement::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2862
+
2863
+ # source://rubocop-performance//lib/rubocop/cop/performance/string_replacement.rb#28
2864
+ RuboCop::Cop::Performance::StringReplacement::TR = T.let(T.unsafe(nil), String)
2865
+
2866
+ # Identifies places where custom code finding the sum of elements
2867
+ # in some Enumerable object can be replaced by `Enumerable#sum` method.
2868
+ #
2869
+ # @example OnlySumOrWithInitialValue: false (default)
2870
+ # # bad
2871
+ # [1, 2, 3].inject(:+) # Autocorrections for cases without initial value are unsafe
2872
+ # [1, 2, 3].inject(&:+) # and will only be performed when using the `-A` option.
2873
+ # [1, 2, 3].reduce { |acc, elem| acc + elem } # They can be prohibited completely using `SafeAutoCorrect: true`.
2874
+ # [1, 2, 3].reduce(10, :+)
2875
+ # [1, 2, 3].map { |elem| elem ** 2 }.sum
2876
+ # [1, 2, 3].collect(&:count).sum(10)
2877
+ #
2878
+ # # good
2879
+ # [1, 2, 3].sum
2880
+ # [1, 2, 3].sum(10)
2881
+ # [1, 2, 3].sum { |elem| elem ** 2 }
2882
+ # [1, 2, 3].sum(10, &:count)
2883
+ # @example OnlySumOrWithInitialValue: true
2884
+ # # bad
2885
+ # [1, 2, 3].reduce(10, :+)
2886
+ # [1, 2, 3].map { |elem| elem ** 2 }.sum
2887
+ # [1, 2, 3].collect(&:count).sum(10)
2888
+ #
2889
+ # # good
2890
+ # [1, 2, 3].sum(10)
2891
+ # [1, 2, 3].sum { |elem| elem ** 2 }
2892
+ # [1, 2, 3].sum(10, &:count)
2893
+ #
2894
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#70
2895
+ class RuboCop::Cop::Performance::Sum < ::RuboCop::Cop::Base
2896
+ include ::RuboCop::Cop::RangeHelp
2897
+ extend ::RuboCop::Cop::AutoCorrector
2898
+ extend ::RuboCop::Cop::TargetRubyVersion
2899
+
2900
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#102
2901
+ def acc_plus_elem?(param0 = T.unsafe(nil), param1, param2); end
2902
+
2903
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#102
2904
+ def elem_plus_acc?(param0 = T.unsafe(nil), param1, param2); end
2905
+
2906
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#114
2907
+ def on_block(node); end
2908
+
2909
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#107
2910
+ def on_send(node); end
2911
+
2912
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#82
2913
+ def sum_candidate?(param0 = T.unsafe(nil)); end
2914
+
2915
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#86
2916
+ def sum_map_candidate?(param0 = T.unsafe(nil)); end
2917
+
2918
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#95
2919
+ def sum_with_block_candidate?(param0 = T.unsafe(nil)); end
2920
+
2921
+ private
2922
+
2923
+ # @return [Boolean]
2924
+ #
2925
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#159
2926
+ def array_literal?(node); end
2927
+
2928
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#164
2929
+ def autocorrect(corrector, init, range); end
2930
+
2931
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#172
2932
+ def autocorrect_sum_map(corrector, sum, map, init); end
2933
+
2934
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#248
2935
+ def build_block_bad_method(method, init, var_acc, var_elem, body); end
2936
+
2937
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#215
2938
+ def build_block_message(send, init, var_acc, var_elem, body); end
2939
+
2940
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#221
2941
+ def build_good_method(init, block_pass = T.unsafe(nil)); end
2942
+
2943
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#234
2944
+ def build_method_bad_method(init, method, operation); end
2945
+
2946
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#197
2947
+ def build_method_message(node, method, init, operation); end
2948
+
2949
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#208
2950
+ def build_sum_map_message(method, init); end
2951
+
2952
+ # @return [Boolean]
2953
+ #
2954
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#154
2955
+ def empty_array_literal?(node); end
2956
+
2957
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#129
2958
+ def handle_sum_candidate(node); end
2959
+
2960
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#142
2961
+ def handle_sum_map_candidate(node); end
2962
+
2963
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#259
2964
+ def method_call_with_args_range(node); end
2965
+
2966
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#193
2967
+ def sum_block_range(send, node); end
2968
+
2969
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#189
2970
+ def sum_map_range(map, sum); end
2971
+
2972
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#185
2973
+ def sum_method_range(node); end
2974
+ end
2975
+
2976
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#77
2977
+ RuboCop::Cop::Performance::Sum::MSG = T.let(T.unsafe(nil), String)
2978
+
2979
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#78
2980
+ RuboCop::Cop::Performance::Sum::MSG_IF_NO_INIT_VALUE = T.let(T.unsafe(nil), String)
2981
+
2982
+ # source://rubocop-performance//lib/rubocop/cop/performance/sum.rb#80
2983
+ RuboCop::Cop::Performance::Sum::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2984
+
2985
+ # Checks for .times.map calls.
2986
+ # In most cases such calls can be replaced
2987
+ # with an explicit array creation.
2988
+ #
2989
+ # @example
2990
+ # # bad
2991
+ # 9.times.map do |i|
2992
+ # i.to_s
2993
+ # end
2994
+ #
2995
+ # # good
2996
+ # Array.new(9) do |i|
2997
+ # i.to_s
2998
+ # end
2999
+ #
3000
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#32
3001
+ class RuboCop::Cop::Performance::TimesMap < ::RuboCop::Cop::Base
3002
+ extend ::RuboCop::Cop::AutoCorrector
3003
+
3004
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#43
3005
+ def on_block(node); end
3006
+
3007
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#43
3008
+ def on_numblock(node); end
3009
+
3010
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#39
3011
+ def on_send(node); end
3012
+
3013
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#69
3014
+ def times_map_call(param0 = T.unsafe(nil)); end
3015
+
3016
+ private
3017
+
3018
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#50
3019
+ def check(node); end
3020
+
3021
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#60
3022
+ def message(map_or_collect, count); end
3023
+ end
3024
+
3025
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#35
3026
+ RuboCop::Cop::Performance::TimesMap::MESSAGE = T.let(T.unsafe(nil), String)
3027
+
3028
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#36
3029
+ RuboCop::Cop::Performance::TimesMap::MESSAGE_ONLY_IF = T.let(T.unsafe(nil), String)
3030
+
3031
+ # source://rubocop-performance//lib/rubocop/cop/performance/times_map.rb#37
3032
+ RuboCop::Cop::Performance::TimesMap::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
3033
+
3034
+ # In Ruby 2.3 or later, use unary plus operator to unfreeze a string
3035
+ # literal instead of `String#dup` and `String.new`.
3036
+ # Unary plus operator is faster than `String#dup`.
3037
+ #
3038
+ # @example
3039
+ # # bad
3040
+ # ''.dup
3041
+ # "something".dup
3042
+ # String.new
3043
+ # String.new('')
3044
+ # String.new('something')
3045
+ #
3046
+ # # good
3047
+ # +'something'
3048
+ # +''
3049
+ #
3050
+ # source://rubocop-performance//lib/rubocop/cop/performance/unfreeze_string.rb#27
3051
+ class RuboCop::Cop::Performance::UnfreezeString < ::RuboCop::Cop::Base
3052
+ extend ::RuboCop::Cop::AutoCorrector
3053
+ extend ::RuboCop::Cop::TargetRubyVersion
3054
+
3055
+ # source://rubocop-performance//lib/rubocop/cop/performance/unfreeze_string.rb#36
3056
+ def dup_string?(param0 = T.unsafe(nil)); end
3057
+
3058
+ # source://rubocop-performance//lib/rubocop/cop/performance/unfreeze_string.rb#47
3059
+ def on_send(node); end
3060
+
3061
+ # source://rubocop-performance//lib/rubocop/cop/performance/unfreeze_string.rb#40
3062
+ def string_new?(param0 = T.unsafe(nil)); end
3063
+
3064
+ private
3065
+
3066
+ # source://rubocop-performance//lib/rubocop/cop/performance/unfreeze_string.rb#60
3067
+ def string_value(node); end
3068
+ end
3069
+
3070
+ # source://rubocop-performance//lib/rubocop/cop/performance/unfreeze_string.rb#33
3071
+ RuboCop::Cop::Performance::UnfreezeString::MSG = T.let(T.unsafe(nil), String)
3072
+
3073
+ # source://rubocop-performance//lib/rubocop/cop/performance/unfreeze_string.rb#34
3074
+ RuboCop::Cop::Performance::UnfreezeString::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
3075
+
3076
+ # Identifies places where `URI::Parser.new` can be replaced by `URI::DEFAULT_PARSER`.
3077
+ #
3078
+ # @example
3079
+ # # bad
3080
+ # URI::Parser.new
3081
+ #
3082
+ # # good
3083
+ # URI::DEFAULT_PARSER
3084
+ #
3085
+ # source://rubocop-performance//lib/rubocop/cop/performance/uri_default_parser.rb#15
3086
+ class RuboCop::Cop::Performance::UriDefaultParser < ::RuboCop::Cop::Base
3087
+ extend ::RuboCop::Cop::AutoCorrector
3088
+
3089
+ # source://rubocop-performance//lib/rubocop/cop/performance/uri_default_parser.rb#27
3090
+ def on_send(node); end
3091
+
3092
+ # source://rubocop-performance//lib/rubocop/cop/performance/uri_default_parser.rb#21
3093
+ def uri_parser_new?(param0 = T.unsafe(nil)); end
3094
+ end
3095
+
3096
+ # source://rubocop-performance//lib/rubocop/cop/performance/uri_default_parser.rb#18
3097
+ RuboCop::Cop::Performance::UriDefaultParser::MSG = T.let(T.unsafe(nil), String)
3098
+
3099
+ # source://rubocop-performance//lib/rubocop/cop/performance/uri_default_parser.rb#19
3100
+ RuboCop::Cop::Performance::UriDefaultParser::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
3101
+
3102
+ # Common functionality for handling regexp metacharacters.
3103
+ #
3104
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#6
3105
+ module RuboCop::Cop::RegexpMetacharacter
3106
+ private
3107
+
3108
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#63
3109
+ def drop_end_metacharacter(regexp_string); end
3110
+
3111
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#55
3112
+ def drop_start_metacharacter(regexp_string); end
3113
+
3114
+ # @return [Boolean]
3115
+ #
3116
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#15
3117
+ def literal_at_end?(regexp); end
3118
+
3119
+ # @return [Boolean]
3120
+ #
3121
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#41
3122
+ def literal_at_end_with_backslash_z?(regex_str); end
3123
+
3124
+ # @return [Boolean]
3125
+ #
3126
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#48
3127
+ def literal_at_end_with_dollar?(regex_str); end
3128
+
3129
+ # @return [Boolean]
3130
+ #
3131
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#9
3132
+ def literal_at_start?(regexp); end
3133
+
3134
+ # @return [Boolean]
3135
+ #
3136
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#21
3137
+ def literal_at_start_with_backslash_a?(regex_str); end
3138
+
3139
+ # @return [Boolean]
3140
+ #
3141
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#31
3142
+ def literal_at_start_with_caret?(regex_str); end
3143
+
3144
+ # @return [Boolean]
3145
+ #
3146
+ # source://rubocop-performance//lib/rubocop/cop/mixin/regexp_metacharacter.rb#71
3147
+ def safe_multiline?; end
3148
+ end
3149
+
3150
+ # Common functionality for cops checking `Enumerable#sort` blocks.
3151
+ #
3152
+ # source://rubocop-performance//lib/rubocop/cop/mixin/sort_block.rb#6
3153
+ module RuboCop::Cop::SortBlock
3154
+ include ::RuboCop::Cop::RangeHelp
3155
+ extend ::RuboCop::AST::NodePattern::Macros
3156
+
3157
+ # source://rubocop-performance//lib/rubocop/cop/mixin/sort_block.rb#24
3158
+ def replaceable_body?(param0 = T.unsafe(nil), param1, param2); end
3159
+
3160
+ # source://rubocop-performance//lib/rubocop/cop/mixin/sort_block.rb#10
3161
+ def sort_with_block?(param0 = T.unsafe(nil)); end
3162
+
3163
+ # source://rubocop-performance//lib/rubocop/cop/mixin/sort_block.rb#17
3164
+ def sort_with_numblock?(param0 = T.unsafe(nil)); end
3165
+
3166
+ private
3167
+
3168
+ # source://rubocop-performance//lib/rubocop/cop/mixin/sort_block.rb#30
3169
+ def sort_range(send, node); end
3170
+ end
3171
+
3172
+ # RuboCop Performance project namespace
3173
+ #
3174
+ # source://rubocop-performance//lib/rubocop/performance.rb#5
3175
+ module RuboCop::Performance; end
3176
+
3177
+ # source://rubocop-performance//lib/rubocop/performance.rb#8
3178
+ RuboCop::Performance::CONFIG = T.let(T.unsafe(nil), Hash)
3179
+
3180
+ # source://rubocop-performance//lib/rubocop/performance.rb#7
3181
+ RuboCop::Performance::CONFIG_DEFAULT = T.let(T.unsafe(nil), Pathname)
3182
+
3183
+ # Because RuboCop doesn't yet support plugins, we have to monkey patch in a
3184
+ # bit of our configuration.
3185
+ #
3186
+ # source://rubocop-performance//lib/rubocop/performance/inject.rb#7
3187
+ module RuboCop::Performance::Inject
3188
+ class << self
3189
+ # source://rubocop-performance//lib/rubocop/performance/inject.rb#8
3190
+ def defaults!; end
3191
+ end
3192
+ end
3193
+
3194
+ # source://rubocop-performance//lib/rubocop/performance.rb#6
3195
+ RuboCop::Performance::PROJECT_ROOT = T.let(T.unsafe(nil), Pathname)
3196
+
3197
+ # This module holds the RuboCop Performance version information.
3198
+ #
3199
+ # source://rubocop-performance//lib/rubocop/performance/version.rb#6
3200
+ module RuboCop::Performance::Version
3201
+ class << self
3202
+ # source://rubocop-performance//lib/rubocop/performance/version.rb#9
3203
+ def document_version; end
3204
+ end
3205
+ end
3206
+
3207
+ # source://rubocop-performance//lib/rubocop/performance/version.rb#7
3208
+ RuboCop::Performance::Version::STRING = T.let(T.unsafe(nil), String)