packwerk 3.3.0 → 3.3.1

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