web-author 0.1.0

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