shotgrid_api_ruby 0.2.0.4 → 0.2.0.6

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