m2m_keygen 0.4.9 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. checksums.yaml +4 -4
  2. data/.overcommit.yml +4 -7
  3. data/.rubocop.yml +19 -16
  4. data/.ruby-version +1 -1
  5. data/.streerc +1 -0
  6. data/.tool-versions +1 -1
  7. data/CHANGELOG.md +60 -1
  8. data/Gemfile +2 -2
  9. data/Gemfile.lock +135 -158
  10. data/README.md +64 -78
  11. data/docs/MIGRATING.md +69 -0
  12. data/docs/SPEC.md +245 -0
  13. data/examples/nonce_store/postgres.rb +40 -0
  14. data/examples/nonce_store/redis.rb +23 -0
  15. data/gemfiles/rack_2.gemfile +5 -0
  16. data/gemfiles/rack_3.gemfile +5 -0
  17. data/lib/m2m_keygen/canonicalizer.rb +57 -0
  18. data/lib/m2m_keygen/nonce_store/disabled.rb +19 -0
  19. data/lib/m2m_keygen/nonce_store/memory.rb +64 -0
  20. data/lib/m2m_keygen/nonce_store.rb +18 -0
  21. data/lib/m2m_keygen/rack_validator.rb +72 -19
  22. data/lib/m2m_keygen/request_signer/signed_request.rb +10 -0
  23. data/lib/m2m_keygen/request_signer.rb +118 -0
  24. data/lib/m2m_keygen/signature.rb +41 -39
  25. data/lib/m2m_keygen/types/params_type.rb +6 -17
  26. data/lib/m2m_keygen/version.rb +1 -1
  27. data/lib/m2m_keygen.rb +6 -0
  28. data/m2m_keygen.gemspec +12 -14
  29. data/sorbet/config +1 -0
  30. data/sorbet/rbi/gems/.gitattributes +1 -0
  31. data/sorbet/rbi/gems/{ast@2.4.2.rbi → ast@2.4.3.rbi} +45 -79
  32. data/sorbet/rbi/gems/{benchmark@0.2.0.rbi → benchmark@0.5.0.rbi} +91 -58
  33. data/sorbet/rbi/gems/bundler-audit@0.9.3.rbi +397 -0
  34. data/sorbet/rbi/gems/byebug@13.0.0.rbi +3651 -0
  35. data/sorbet/rbi/gems/childprocess@5.1.0.rbi +336 -0
  36. data/sorbet/rbi/gems/concurrent-ruby@1.3.7.rbi +384 -0
  37. data/sorbet/rbi/gems/{diff-lcs@1.5.0.rbi → diff-lcs@1.6.2.rbi} +189 -199
  38. data/sorbet/rbi/gems/{docile@1.4.0.rbi → docile@1.4.1.rbi} +147 -147
  39. data/sorbet/rbi/gems/dotenv@3.2.0.rbi +267 -0
  40. data/sorbet/rbi/gems/erubi@1.13.1.rbi +155 -0
  41. data/sorbet/rbi/gems/{faker@2.22.0.rbi → faker@3.8.0.rbi} +8468 -3829
  42. data/sorbet/rbi/gems/{ffi@1.15.5.rbi → ffi@1.17.4.rbi} +1 -0
  43. data/sorbet/rbi/gems/{formatador@1.1.0.rbi → formatador@1.2.3.rbi} +1 -0
  44. data/sorbet/rbi/gems/{guard@2.18.0.rbi → guard@2.20.1.rbi} +1 -0
  45. data/sorbet/rbi/gems/{i18n@1.12.0.rbi → i18n@1.15.2.rbi} +687 -827
  46. data/sorbet/rbi/gems/io-console@0.8.2.rbi +9 -0
  47. data/sorbet/rbi/gems/{json@2.6.2.rbi → json@2.20.0.rbi} +994 -252
  48. data/sorbet/rbi/gems/language_server-protocol@3.17.0.5.rbi +9 -0
  49. data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +189 -0
  50. data/sorbet/rbi/gems/listen@3.10.0.rbi +9 -0
  51. data/sorbet/rbi/gems/logger@1.7.0.rbi +896 -0
  52. data/sorbet/rbi/gems/{lumberjack@1.2.8.rbi → lumberjack@1.4.2.rbi} +1 -0
  53. data/sorbet/rbi/gems/{method_source@1.0.0.rbi → method_source@1.1.0.rbi} +111 -90
  54. data/sorbet/rbi/gems/{overcommit@0.59.1.rbi → overcommit@0.71.0.rbi} +503 -647
  55. data/sorbet/rbi/gems/parallel@2.1.0.rbi +321 -0
  56. data/sorbet/rbi/gems/parser@3.3.11.1.rbi +5229 -0
  57. data/sorbet/rbi/gems/prettier_print@1.2.1.rbi +878 -0
  58. data/sorbet/rbi/gems/prism@1.9.0.rbi +42224 -0
  59. data/sorbet/rbi/gems/pry-byebug@3.12.0.rbi +481 -0
  60. data/sorbet/rbi/gems/{pry@0.14.1.rbi → pry@0.16.0.rbi} +2567 -3550
  61. data/sorbet/rbi/gems/{racc@1.6.0.rbi → racc@1.8.1.rbi} +54 -40
  62. data/sorbet/rbi/gems/rack@3.2.6.rbi +4653 -0
  63. data/sorbet/rbi/gems/{rake@13.0.6.rbi → rake@13.4.2.rbi} +963 -732
  64. data/sorbet/rbi/gems/{rb-inotify@0.10.1.rbi → rb-inotify@0.11.1.rbi} +1 -0
  65. data/sorbet/rbi/gems/rbi@0.3.14.rbi +5519 -0
  66. data/sorbet/rbi/gems/rbs@4.0.3.rbi +6908 -0
  67. data/sorbet/rbi/gems/regexp_parser@2.12.0.rbi +3398 -0
  68. data/sorbet/rbi/gems/reline@0.6.3.rbi +2446 -0
  69. data/sorbet/rbi/gems/require-hooks@0.4.0.rbi +152 -0
  70. data/sorbet/rbi/gems/{rexml@3.2.5.rbi → rexml@3.4.4.rbi} +1085 -894
  71. data/sorbet/rbi/gems/rspec-core@3.13.6.rbi +9475 -0
  72. data/sorbet/rbi/gems/rspec-expectations@3.13.5.rbi +6108 -0
  73. data/sorbet/rbi/gems/rspec-mocks@3.13.8.rbi +4787 -0
  74. data/sorbet/rbi/gems/rspec-support@3.13.7.rbi +1274 -0
  75. data/sorbet/rbi/gems/rspec@3.13.2.rbi +15 -0
  76. data/sorbet/rbi/gems/rspec_in_context@1.2.2.rbi +294 -0
  77. data/sorbet/rbi/gems/rubocop-ast@1.49.1.rbi +7140 -0
  78. data/sorbet/rbi/gems/rubocop-faker@1.3.0.rbi +88 -0
  79. data/sorbet/rbi/gems/rubocop-performance@1.26.1.rbi +3403 -0
  80. data/sorbet/rbi/gems/rubocop-sorbet@0.12.0.rbi +2448 -0
  81. data/sorbet/rbi/gems/rubocop@1.88.1.rbi +63103 -0
  82. data/sorbet/rbi/gems/ruby-lsp@0.26.9.rbi +28 -0
  83. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +988 -0
  84. data/sorbet/rbi/gems/rubydex@0.2.7.rbi +836 -0
  85. data/sorbet/rbi/gems/simplecov-html@0.13.2.rbi +90 -0
  86. data/sorbet/rbi/gems/{simplecov@0.21.2.rbi → simplecov@0.22.0.rbi} +438 -578
  87. data/sorbet/rbi/gems/spoom@1.8.2.rbi +6691 -0
  88. data/sorbet/rbi/gems/syntax_tree@6.3.0.rbi +22090 -0
  89. data/sorbet/rbi/gems/tapioca@0.19.2.rbi +3597 -0
  90. data/sorbet/rbi/gems/{thor@1.2.1.rbi → thor@1.5.0.rbi} +1085 -1171
  91. data/sorbet/rbi/gems/tsort@0.2.0.rbi +389 -0
  92. data/sorbet/rbi/gems/unicode-display_width@3.2.0.rbi +130 -0
  93. data/sorbet/rbi/gems/unicode-emoji@4.2.0.rbi +332 -0
  94. data/sorbet/rbi/gems/{yard-sorbet@0.7.0.rbi → yard-sorbet@0.9.0.rbi} +142 -99
  95. data/sorbet/rbi/gems/{yard@0.9.28.rbi → yard@0.9.44.rbi} +5350 -6316
  96. data/sorbet/rbi/gems/zeitwerk@2.8.2.rbi +1178 -0
  97. metadata +105 -111
  98. data/.prettierrc.js +0 -4
  99. data/docs/M2mKeygen/Error.html +0 -135
  100. data/docs/M2mKeygen/ParamsEncoder.html +0 -321
  101. data/docs/M2mKeygen/RackValidator.html +0 -533
  102. data/docs/M2mKeygen/Signature.html +0 -680
  103. data/docs/M2mKeygen/Types.html +0 -147
  104. data/docs/M2mKeygen.html +0 -157
  105. data/docs/_index.html +0 -182
  106. data/docs/class_list.html +0 -51
  107. data/docs/css/common.css +0 -1
  108. data/docs/css/full_list.css +0 -58
  109. data/docs/css/style.css +0 -497
  110. data/docs/file.README.html +0 -230
  111. data/docs/file_list.html +0 -56
  112. data/docs/frames.html +0 -17
  113. data/docs/index.html +0 -230
  114. data/docs/js/app.js +0 -314
  115. data/docs/js/full_list.js +0 -216
  116. data/docs/js/jquery.js +0 -4
  117. data/docs/method_list.html +0 -139
  118. data/docs/top-level-namespace.html +0 -110
  119. data/lib/m2m_keygen/params_encoder.rb +0 -56
  120. data/package.json +0 -12
  121. data/sig/m2m_keygen.rbs +0 -4
  122. data/sorbet/rbi/gems/activesupport@7.0.3.1.rbi +0 -18608
  123. data/sorbet/rbi/gems/backport@1.2.0.rbi +0 -522
  124. data/sorbet/rbi/gems/bundler-audit@0.9.1.rbi +0 -308
  125. data/sorbet/rbi/gems/byebug@11.1.3.rbi +0 -3603
  126. data/sorbet/rbi/gems/childprocess@4.1.0.rbi +0 -401
  127. data/sorbet/rbi/gems/concurrent-ruby@1.1.10.rbi +0 -11581
  128. data/sorbet/rbi/gems/dotenv@2.8.1.rbi +0 -234
  129. data/sorbet/rbi/gems/e2mmap@0.1.0.rbi +0 -8
  130. data/sorbet/rbi/gems/haml@5.2.2.rbi +0 -3190
  131. data/sorbet/rbi/gems/jaro_winkler@1.5.4.rbi +0 -19
  132. data/sorbet/rbi/gems/kramdown-parser-gfm@1.1.0.rbi +0 -133
  133. data/sorbet/rbi/gems/kramdown@2.4.0.rbi +0 -3261
  134. data/sorbet/rbi/gems/listen@3.7.1.rbi +0 -1181
  135. data/sorbet/rbi/gems/minitest@5.16.3.rbi +0 -1459
  136. data/sorbet/rbi/gems/nokogiri@1.13.8.rbi +0 -6514
  137. data/sorbet/rbi/gems/parallel@1.22.1.rbi +0 -277
  138. data/sorbet/rbi/gems/parser@3.1.2.1.rbi +0 -6826
  139. data/sorbet/rbi/gems/prettier@3.2.0.rbi +0 -22
  140. data/sorbet/rbi/gems/prettier_print@0.1.0.rbi +0 -8
  141. data/sorbet/rbi/gems/pry-byebug@3.10.1.rbi +0 -1222
  142. data/sorbet/rbi/gems/rack@2.2.4.rbi +0 -5630
  143. data/sorbet/rbi/gems/rbi@0.0.15.rbi +0 -3007
  144. data/sorbet/rbi/gems/rbs@2.6.0.rbi +0 -8
  145. data/sorbet/rbi/gems/regexp_parser@2.5.0.rbi +0 -3366
  146. data/sorbet/rbi/gems/reverse_markdown@2.1.1.rbi +0 -389
  147. data/sorbet/rbi/gems/rspec-core@3.11.0.rbi +0 -10786
  148. data/sorbet/rbi/gems/rspec-expectations@3.11.0.rbi +0 -8170
  149. data/sorbet/rbi/gems/rspec-mocks@3.11.1.rbi +0 -5385
  150. data/sorbet/rbi/gems/rspec-support@3.11.0.rbi +0 -1746
  151. data/sorbet/rbi/gems/rspec@3.11.0.rbi +0 -187
  152. data/sorbet/rbi/gems/rspec_in_context@1.1.0.3.rbi +0 -1113
  153. data/sorbet/rbi/gems/rubocop-ast@1.21.0.rbi +0 -7044
  154. data/sorbet/rbi/gems/rubocop-faker@1.1.0.rbi +0 -106
  155. data/sorbet/rbi/gems/rubocop-performance@1.14.3.rbi +0 -2982
  156. data/sorbet/rbi/gems/rubocop-sorbet@0.6.11.rbi +0 -990
  157. data/sorbet/rbi/gems/rubocop@1.35.1.rbi +0 -52002
  158. data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +0 -1239
  159. data/sorbet/rbi/gems/simplecov-html@0.12.3.rbi +0 -219
  160. data/sorbet/rbi/gems/solargraph@0.46.0.rbi +0 -9075
  161. data/sorbet/rbi/gems/spoom@1.1.12.rbi +0 -2369
  162. data/sorbet/rbi/gems/syntax_tree-haml@1.3.1.rbi +0 -8
  163. data/sorbet/rbi/gems/syntax_tree-rbs@0.5.0.rbi +0 -8
  164. data/sorbet/rbi/gems/syntax_tree@3.5.0.rbi +0 -8
  165. data/sorbet/rbi/gems/tapioca@0.9.4.rbi +0 -2946
  166. data/sorbet/rbi/gems/temple@0.8.2.rbi +0 -1712
  167. data/sorbet/rbi/gems/tilt@2.0.11.rbi +0 -742
  168. data/sorbet/rbi/gems/tzinfo@2.0.5.rbi +0 -5914
  169. data/sorbet/rbi/gems/unicode-display_width@2.2.0.rbi +0 -48
  170. data/sorbet/rbi/gems/unparser@0.6.5.rbi +0 -4529
  171. data/sorbet/rbi/gems/webrick@1.7.0.rbi +0 -2553
  172. data/sorbet/rbi/gems/zeitwerk@2.6.0.rbi +0 -867
  173. data/sorbet/rbi/manual.rbi +0 -7
  174. data/yarn.lock +0 -20
@@ -1,2982 +0,0 @@
1
- # typed: true
2
-
3
- # DO NOT EDIT MANUALLY
4
- # This is an autogenerated file for types exported from the `rubocop-performance` gem.
5
- # Please instead update this file by running `bin/tapioca gem rubocop-performance`.
6
-
7
- # source://rubocop-performance-1.14.3/lib/rubocop/performance.rb:3
8
- module RuboCop; end
9
-
10
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/mixin/regexp_metacharacter.rb:4
11
- module RuboCop::Cop; end
12
-
13
- # source://rubocop-1.35.1/lib/rubocop/cop/mixin/allowed_methods.rb:33
14
- RuboCop::Cop::IgnoredMethods = RuboCop::Cop::AllowedMethods
15
-
16
- # source://rubocop-1.35.1/lib/rubocop/cop/mixin/allowed_pattern.rb:46
17
- RuboCop::Cop::IgnoredPattern = RuboCop::Cop::AllowedPattern
18
-
19
- # source://rubocop-performance-1.14.3/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-1.14.3/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-1.14.3/lib/rubocop/cop/performance/ancestors_include.rb:26
37
- def ancestors_include_candidate?(param0 = T.unsafe(nil)); end
38
-
39
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/ancestors_include.rb:30
40
- def on_send(node); end
41
-
42
- private
43
-
44
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/ancestors_include.rb:43
45
- def range(node); end
46
- end
47
-
48
- # source://rubocop-performance-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/lib/rubocop/cop/performance/big_decimal_with_numeric_argument.rb:37
129
- def on_send(node); end
130
-
131
- # source://rubocop-performance-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/lib/rubocop/cop/performance/bind_call.rb:33
164
- def bind_with_call_method?(param0 = T.unsafe(nil)); end
165
-
166
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/bind_call.rb:41
167
- def on_send(node); end
168
-
169
- private
170
-
171
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/bind_call.rb:72
172
- def build_call_args(call_args_node); end
173
-
174
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/bind_call.rb:65
175
- def correction_range(receiver, node); end
176
-
177
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/bind_call.rb:59
178
- def message(bind_arg, call_args); end
179
- end
180
-
181
- # source://rubocop-performance-1.14.3/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-1.14.3/lib/rubocop/cop/performance/bind_call.rb:31
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-1.14.3/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-1.14.3/lib/rubocop/cop/performance/block_given_with_explicit_block.rb:35
213
- def on_send(node); end
214
-
215
- # source://rubocop-performance-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/lib/rubocop/cop/performance/caller.rb:33
245
- def caller_with_scope_method?(param0 = T.unsafe(nil)); end
246
-
247
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/caller.rb:40
248
- def on_send(node); end
249
-
250
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/caller.rb:26
251
- def slow_caller?(param0 = T.unsafe(nil)); end
252
-
253
- private
254
-
255
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/caller.rb:61
256
- def int_value(node); end
257
- end
258
-
259
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/caller.rb:23
260
- RuboCop::Cop::Performance::Caller::MSG = T.let(T.unsafe(nil), String)
261
-
262
- # source://rubocop-performance-1.14.3/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-1.14.3/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-1.14.3/lib/rubocop/cop/performance/case_when_splat.rb:66
317
- def on_case(case_node); end
318
-
319
- private
320
-
321
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/case_when_splat.rb:83
322
- def autocorrect(corrector, when_node); end
323
-
324
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/case_when_splat.rb:144
325
- def indent_for(node); end
326
-
327
- # source://rubocop-performance-1.14.3/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-1.14.3/lib/rubocop/cop/performance/case_when_splat.rb:169
333
- def needs_reorder?(when_node); end
334
-
335
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/case_when_splat.rb:140
336
- def new_branch_without_then(node, new_condition); end
337
-
338
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/case_when_splat.rb:136
339
- def new_condition_with_then(node, new_condition); end
340
-
341
- # @return [Boolean]
342
- #
343
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/case_when_splat.rb:162
344
- def non_splat?(condition); end
345
-
346
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/case_when_splat.rb:91
347
- def range(node); end
348
-
349
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/case_when_splat.rb:108
350
- def reorder_condition(corrector, when_node); end
351
-
352
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/case_when_splat.rb:118
353
- def reordering_correction(when_node); end
354
-
355
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/case_when_splat.rb:95
356
- def replacement(conditions); end
357
-
358
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/case_when_splat.rb:148
359
- def splat_offenses(when_conditions); end
360
-
361
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/case_when_splat.rb:128
362
- def when_branch_range(when_node); end
363
- end
364
-
365
- # source://rubocop-performance-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/lib/rubocop/cop/performance/casecmp.rb:45
391
- def downcase_downcase(param0 = T.unsafe(nil)); end
392
-
393
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/casecmp.rb:31
394
- def downcase_eq(param0 = T.unsafe(nil)); end
395
-
396
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/casecmp.rb:38
397
- def eq_downcase(param0 = T.unsafe(nil)); end
398
-
399
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/casecmp.rb:52
400
- def on_send(node); end
401
-
402
- private
403
-
404
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/casecmp.rb:84
405
- def autocorrect(corrector, node, replacement); end
406
-
407
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/casecmp.rb:88
408
- def build_good_method(method, arg, variable); end
409
-
410
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/casecmp.rb:67
411
- def take_method_apart(node); end
412
- end
413
-
414
- # source://rubocop-performance-1.14.3/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-1.14.3/lib/rubocop/cop/performance/casecmp.rb:27
418
- RuboCop::Cop::Performance::Casecmp::MSG = T.let(T.unsafe(nil), String)
419
-
420
- # source://rubocop-performance-1.14.3/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-1.14.3/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-1.14.3/lib/rubocop/cop/performance/chain_array_allocation.rb:54
444
- def chain_array_allocation?(param0 = T.unsafe(nil)); end
445
-
446
- # source://rubocop-performance-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/lib/rubocop/cop/performance/collection_literal_in_loop.rb:34
509
- class RuboCop::Cop::Performance::CollectionLiteralInLoop < ::RuboCop::Cop::Base
510
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/collection_literal_in_loop.rb:74
511
- def enumerable_loop?(param0 = T.unsafe(nil)); end
512
-
513
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/collection_literal_in_loop.rb:68
514
- def kernel_loop?(param0 = T.unsafe(nil)); end
515
-
516
- # source://rubocop-performance-1.14.3/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-1.14.3/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-1.14.3/lib/rubocop/cop/performance/collection_literal_in_loop.rb:130
529
- def enumerable_method?(method_name); end
530
-
531
- # @return [Boolean]
532
- #
533
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/collection_literal_in_loop.rb:112
534
- def keyword_loop?(type); end
535
-
536
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/collection_literal_in_loop.rb:122
537
- def literal_class(node); end
538
-
539
- # @return [Boolean]
540
- #
541
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/collection_literal_in_loop.rb:106
542
- def loop?(ancestor, node); end
543
-
544
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/collection_literal_in_loop.rb:134
545
- def min_size; end
546
-
547
- # @return [Boolean]
548
- #
549
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/collection_literal_in_loop.rb:116
550
- def node_within_enumerable_loop?(node, ancestor); end
551
-
552
- # @return [Boolean]
553
- #
554
- # source://rubocop-performance-1.14.3/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-1.14.3/lib/rubocop/cop/performance/collection_literal_in_loop.rb:102
560
- def parent_is_loop?(node); end
561
- end
562
-
563
- # source://rubocop-performance-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/lib/rubocop/cop/performance/compare_with_block.rb:34
614
- def compare?(param0 = T.unsafe(nil)); end
615
-
616
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/compare_with_block.rb:48
617
- def on_block(node); end
618
-
619
- # source://rubocop-performance-1.14.3/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-1.14.3/lib/rubocop/cop/performance/compare_with_block.rb:105
625
- def compare_range(send, node); end
626
-
627
- # source://rubocop-performance-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/lib/rubocop/cop/performance/concurrent_monotonic_time.rb:23
655
- def concurrent_monotonic_time?(param0 = T.unsafe(nil)); end
656
-
657
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/concurrent_monotonic_time.rb:28
658
- def on_send(node); end
659
- end
660
-
661
- # source://rubocop-performance-1.14.3/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-1.14.3/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-1.14.3/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-1.14.3/lib/rubocop/cop/performance/constant_regexp.rb:41
702
- def on_regexp(node); end
703
-
704
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/constant_regexp.rb:57
705
- def regexp_escape?(param0 = T.unsafe(nil)); end
706
-
707
- private
708
-
709
- # @return [Boolean]
710
- #
711
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/constant_regexp.rb:62
712
- def include_interpolated_const?(node); end
713
-
714
- # @return [Boolean]
715
- #
716
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/constant_regexp.rb:53
717
- def within_allowed_assignment?(node); end
718
- end
719
-
720
- # source://rubocop-performance-1.14.3/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-1.14.3/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-1.14.3/lib/rubocop/cop/performance/count.rb:56
751
- def count_candidate?(param0 = T.unsafe(nil)); end
752
-
753
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/count.rb:63
754
- def on_send(node); end
755
-
756
- private
757
-
758
- # source://rubocop-performance-1.14.3/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-1.14.3/lib/rubocop/cop/performance/count.rb:90
764
- def eligible_node?(node); end
765
-
766
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/count.rb:94
767
- def source_starting_at(node); end
768
- end
769
-
770
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/count.rb:53
771
- RuboCop::Cop::Performance::Count::MSG = T.let(T.unsafe(nil), String)
772
-
773
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/count.rb:54
774
- RuboCop::Cop::Performance::Count::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
775
-
776
- # In Ruby 2.5, `String#delete_prefix` has been added.
777
- #
778
- # This cop identifies places where `gsub(/\Aprefix/, '')` and `sub(/\Aprefix/, '')`
779
- # can be replaced by `delete_prefix('prefix')`.
780
- #
781
- # This cop has `SafeMultiline` configuration option that `true` by default because
782
- # `^prefix` is unsafe as it will behave incompatible with `delete_prefix`
783
- # for receiver is multiline string.
784
- #
785
- # The `delete_prefix('prefix')` method is faster than `gsub(/\Aprefix/, '')`.
786
- #
787
- # @example
788
- #
789
- # # bad
790
- # str.gsub(/\Aprefix/, '')
791
- # str.gsub!(/\Aprefix/, '')
792
- #
793
- # str.sub(/\Aprefix/, '')
794
- # str.sub!(/\Aprefix/, '')
795
- #
796
- # # good
797
- # str.delete_prefix('prefix')
798
- # str.delete_prefix!('prefix')
799
- # @example SafeMultiline: true (default)
800
- #
801
- # # good
802
- # str.gsub(/^prefix/, '')
803
- # str.gsub!(/^prefix/, '')
804
- # str.sub(/^prefix/, '')
805
- # str.sub!(/^prefix/, '')
806
- # @example SafeMultiline: false
807
- #
808
- # # bad
809
- # str.gsub(/^prefix/, '')
810
- # str.gsub!(/^prefix/, '')
811
- # str.sub(/^prefix/, '')
812
- # str.sub!(/^prefix/, '')
813
- #
814
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/delete_prefix.rb:49
815
- class RuboCop::Cop::Performance::DeletePrefix < ::RuboCop::Cop::Base
816
- include ::RuboCop::Cop::RegexpMetacharacter
817
- extend ::RuboCop::Cop::AutoCorrector
818
- extend ::RuboCop::Cop::TargetRubyVersion
819
-
820
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/delete_prefix.rb:66
821
- def delete_prefix_candidate?(param0 = T.unsafe(nil)); end
822
-
823
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/delete_prefix.rb:70
824
- def on_send(node); end
825
- end
826
-
827
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/delete_prefix.rb:56
828
- RuboCop::Cop::Performance::DeletePrefix::MSG = T.let(T.unsafe(nil), String)
829
-
830
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/delete_prefix.rb:59
831
- RuboCop::Cop::Performance::DeletePrefix::PREFERRED_METHODS = T.let(T.unsafe(nil), Hash)
832
-
833
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/delete_prefix.rb:57
834
- RuboCop::Cop::Performance::DeletePrefix::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
835
-
836
- # In Ruby 2.5, `String#delete_suffix` has been added.
837
- #
838
- # This cop identifies places where `gsub(/suffix\z/, '')` and `sub(/suffix\z/, '')`
839
- # can be replaced by `delete_suffix('suffix')`.
840
- #
841
- # This cop has `SafeMultiline` configuration option that `true` by default because
842
- # `suffix$` is unsafe as it will behave incompatible with `delete_suffix?`
843
- # for receiver is multiline string.
844
- #
845
- # The `delete_suffix('suffix')` method is faster than `gsub(/suffix\z/, '')`.
846
- #
847
- # @example
848
- #
849
- # # bad
850
- # str.gsub(/suffix\z/, '')
851
- # str.gsub!(/suffix\z/, '')
852
- #
853
- # str.sub(/suffix\z/, '')
854
- # str.sub!(/suffix\z/, '')
855
- #
856
- # # good
857
- # str.delete_suffix('suffix')
858
- # str.delete_suffix!('suffix')
859
- # @example SafeMultiline: true (default)
860
- #
861
- # # good
862
- # str.gsub(/suffix$/, '')
863
- # str.gsub!(/suffix$/, '')
864
- # str.sub(/suffix$/, '')
865
- # str.sub!(/suffix$/, '')
866
- # @example SafeMultiline: false
867
- #
868
- # # bad
869
- # str.gsub(/suffix$/, '')
870
- # str.gsub!(/suffix$/, '')
871
- # str.sub(/suffix$/, '')
872
- # str.sub!(/suffix$/, '')
873
- #
874
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/delete_suffix.rb:49
875
- class RuboCop::Cop::Performance::DeleteSuffix < ::RuboCop::Cop::Base
876
- include ::RuboCop::Cop::RegexpMetacharacter
877
- extend ::RuboCop::Cop::AutoCorrector
878
- extend ::RuboCop::Cop::TargetRubyVersion
879
-
880
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/delete_suffix.rb:66
881
- def delete_suffix_candidate?(param0 = T.unsafe(nil)); end
882
-
883
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/delete_suffix.rb:70
884
- def on_send(node); end
885
- end
886
-
887
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/delete_suffix.rb:56
888
- RuboCop::Cop::Performance::DeleteSuffix::MSG = T.let(T.unsafe(nil), String)
889
-
890
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/delete_suffix.rb:59
891
- RuboCop::Cop::Performance::DeleteSuffix::PREFERRED_METHODS = T.let(T.unsafe(nil), Hash)
892
-
893
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/delete_suffix.rb:57
894
- RuboCop::Cop::Performance::DeleteSuffix::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
895
-
896
- # Identifies usages of `first`, `last`, `[0]` or `[-1]`
897
- # chained to `select`, `find_all` or `filter` and change them to use
898
- # `detect` instead.
899
- #
900
- # @example
901
- # # bad
902
- # [].select { |item| true }.first
903
- # [].select { |item| true }.last
904
- # [].find_all { |item| true }.first
905
- # [].find_all { |item| true }.last
906
- # [].filter { |item| true }.first
907
- # [].filter { |item| true }.last
908
- # [].filter { |item| true }[0]
909
- # [].filter { |item| true }[-1]
910
- #
911
- # # good
912
- # [].detect { |item| true }
913
- # [].reverse.detect { |item| true }
914
- #
915
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/detect.rb:30
916
- class RuboCop::Cop::Performance::Detect < ::RuboCop::Cop::Base
917
- extend ::RuboCop::Cop::AutoCorrector
918
-
919
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/detect.rb:41
920
- def detect_candidate?(param0 = T.unsafe(nil)); end
921
-
922
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/detect.rb:50
923
- def on_send(node); end
924
-
925
- private
926
-
927
- # @return [Boolean]
928
- #
929
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/detect.rb:69
930
- def accept_first_call?(receiver, body); end
931
-
932
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/detect.rb:101
933
- def autocorrect(corrector, node, replacement); end
934
-
935
- # @return [Boolean]
936
- #
937
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/detect.rb:127
938
- def lazy?(node); end
939
-
940
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/detect.rb:112
941
- def message_for_method(method, index); end
942
-
943
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/detect.rb:123
944
- def preferred_method; end
945
-
946
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/detect.rb:78
947
- def register_offense(node, receiver, second_method, index); end
948
-
949
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/detect.rb:93
950
- def replacement(method, index); end
951
- end
952
-
953
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/detect.rb:33
954
- RuboCop::Cop::Performance::Detect::CANDIDATE_METHODS = T.let(T.unsafe(nil), Set)
955
-
956
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/detect.rb:37
957
- RuboCop::Cop::Performance::Detect::INDEX_MSG = T.let(T.unsafe(nil), String)
958
-
959
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/detect.rb:38
960
- RuboCop::Cop::Performance::Detect::INDEX_REVERSE_MSG = T.let(T.unsafe(nil), String)
961
-
962
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/detect.rb:35
963
- RuboCop::Cop::Performance::Detect::MSG = T.let(T.unsafe(nil), String)
964
-
965
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/detect.rb:39
966
- RuboCop::Cop::Performance::Detect::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
967
-
968
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/detect.rb:36
969
- RuboCop::Cop::Performance::Detect::REVERSE_MSG = T.let(T.unsafe(nil), String)
970
-
971
- # Checks for double `#start_with?` or `#end_with?` calls
972
- # separated by `||`. In some cases such calls can be replaced
973
- # with an single `#start_with?`/`#end_with?` call.
974
- #
975
- # `IncludeActiveSupportAliases` configuration option is used to check for
976
- # `starts_with?` and `ends_with?`. These methods are defined by Active Support.
977
- #
978
- # @example
979
- # # bad
980
- # str.start_with?("a") || str.start_with?(Some::CONST)
981
- # str.start_with?("a", "b") || str.start_with?("c")
982
- # str.end_with?(var1) || str.end_with?(var2)
983
- #
984
- # # good
985
- # str.start_with?("a", Some::CONST)
986
- # str.start_with?("a", "b", "c")
987
- # str.end_with?(var1, var2)
988
- # @example IncludeActiveSupportAliases: false (default)
989
- # # good
990
- # str.starts_with?("a", "b") || str.starts_with?("c")
991
- # str.ends_with?(var1) || str.ends_with?(var2)
992
- #
993
- # str.starts_with?("a", "b", "c")
994
- # str.ends_with?(var1, var2)
995
- # @example IncludeActiveSupportAliases: true
996
- # # bad
997
- # str.starts_with?("a", "b") || str.starts_with?("c")
998
- # str.ends_with?(var1) || str.ends_with?(var2)
999
- #
1000
- # # good
1001
- # str.starts_with?("a", "b", "c")
1002
- # str.ends_with?(var1, var2)
1003
- #
1004
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/double_start_end_with.rb:41
1005
- class RuboCop::Cop::Performance::DoubleStartEndWith < ::RuboCop::Cop::Base
1006
- extend ::RuboCop::Cop::AutoCorrector
1007
-
1008
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/double_start_end_with.rb:97
1009
- def check_with_active_support_aliases(param0 = T.unsafe(nil)); end
1010
-
1011
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/double_start_end_with.rb:47
1012
- def on_or(node); end
1013
-
1014
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/double_start_end_with.rb:91
1015
- def two_start_end_with_calls(param0 = T.unsafe(nil)); end
1016
-
1017
- private
1018
-
1019
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/double_start_end_with.rb:61
1020
- def autocorrect(corrector, first_call_args, second_call_args, combined_args); end
1021
-
1022
- # @return [Boolean]
1023
- #
1024
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/double_start_end_with.rb:87
1025
- def check_for_active_support_aliases?; end
1026
-
1027
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/double_start_end_with.rb:83
1028
- def combine_args(first_call_args, second_call_args); end
1029
-
1030
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/double_start_end_with.rb:77
1031
- def message(node, receiver, method, combined_args); end
1032
-
1033
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/double_start_end_with.rb:69
1034
- def process_source(node); end
1035
- end
1036
-
1037
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/double_start_end_with.rb:44
1038
- RuboCop::Cop::Performance::DoubleStartEndWith::MSG = T.let(T.unsafe(nil), String)
1039
-
1040
- # Identifies unnecessary use of a regex where `String#end_with?` would suffice.
1041
- #
1042
- # This cop has `SafeMultiline` configuration option that `true` by default because
1043
- # `end$` is unsafe as it will behave incompatible with `end_with?`
1044
- # for receiver is multiline string.
1045
- #
1046
- # @example
1047
- # # bad
1048
- # 'abc'.match?(/bc\Z/)
1049
- # /bc\Z/.match?('abc')
1050
- # 'abc' =~ /bc\Z/
1051
- # /bc\Z/ =~ 'abc'
1052
- # 'abc'.match(/bc\Z/)
1053
- # /bc\Z/.match('abc')
1054
- #
1055
- # # good
1056
- # 'abc'.end_with?('bc')
1057
- # @example SafeMultiline: true (default)
1058
- #
1059
- # # good
1060
- # 'abc'.match?(/bc$/)
1061
- # /bc$/.match?('abc')
1062
- # 'abc' =~ /bc$/
1063
- # /bc$/ =~ 'abc'
1064
- # 'abc'.match(/bc$/)
1065
- # /bc$/.match('abc')
1066
- # @example SafeMultiline: false
1067
- #
1068
- # # bad
1069
- # 'abc'.match?(/bc$/)
1070
- # /bc$/.match?('abc')
1071
- # 'abc' =~ /bc$/
1072
- # /bc$/ =~ 'abc'
1073
- # 'abc'.match(/bc$/)
1074
- # /bc$/.match('abc')
1075
- #
1076
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/end_with.rb:49
1077
- class RuboCop::Cop::Performance::EndWith < ::RuboCop::Cop::Base
1078
- include ::RuboCop::Cop::RegexpMetacharacter
1079
- extend ::RuboCop::Cop::AutoCorrector
1080
-
1081
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/end_with.rb:63
1082
- def on_match_with_lvasgn(node); end
1083
-
1084
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/end_with.rb:63
1085
- def on_send(node); end
1086
-
1087
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/end_with.rb:57
1088
- def redundant_regex?(param0 = T.unsafe(nil)); end
1089
- end
1090
-
1091
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/end_with.rb:53
1092
- RuboCop::Cop::Performance::EndWith::MSG = T.let(T.unsafe(nil), String)
1093
-
1094
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/end_with.rb:55
1095
- RuboCop::Cop::Performance::EndWith::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1096
-
1097
- # Do not compute the size of statically sized objects.
1098
- #
1099
- # @example
1100
- # # String methods
1101
- # # bad
1102
- # 'foo'.size
1103
- # %q[bar].count
1104
- # %(qux).length
1105
- #
1106
- # # Symbol methods
1107
- # # bad
1108
- # :fred.size
1109
- # :'baz'.length
1110
- #
1111
- # # Array methods
1112
- # # bad
1113
- # [1, 2, thud].count
1114
- # %W(1, 2, bar).size
1115
- #
1116
- # # Hash methods
1117
- # # bad
1118
- # { a: corge, b: grault }.length
1119
- #
1120
- # # good
1121
- # foo.size
1122
- # bar.count
1123
- # qux.length
1124
- #
1125
- # # good
1126
- # :"#{fred}".size
1127
- # CONST = :baz.length
1128
- #
1129
- # # good
1130
- # [1, 2, *thud].count
1131
- # garply = [1, 2, 3]
1132
- # garply.size
1133
- #
1134
- # # good
1135
- # { a: corge, **grault }.length
1136
- # waldo = { a: corge, b: grault }
1137
- # waldo.size
1138
- #
1139
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/fixed_size.rb:48
1140
- class RuboCop::Cop::Performance::FixedSize < ::RuboCop::Cop::Base
1141
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/fixed_size.rb:52
1142
- def counter(param0 = T.unsafe(nil)); end
1143
-
1144
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/fixed_size.rb:56
1145
- def on_send(node); end
1146
-
1147
- private
1148
-
1149
- # @return [Boolean]
1150
- #
1151
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/fixed_size.rb:72
1152
- def allowed_argument?(arg); end
1153
-
1154
- # @return [Boolean]
1155
- #
1156
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/fixed_size.rb:76
1157
- def allowed_parent?(node); end
1158
-
1159
- # @return [Boolean]
1160
- #
1161
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/fixed_size.rb:68
1162
- def allowed_variable?(var); end
1163
-
1164
- # @return [Boolean]
1165
- #
1166
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/fixed_size.rb:86
1167
- def contains_double_splat?(node); end
1168
-
1169
- # @return [Boolean]
1170
- #
1171
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/fixed_size.rb:80
1172
- def contains_splat?(node); end
1173
-
1174
- # @return [Boolean]
1175
- #
1176
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/fixed_size.rb:92
1177
- def non_string_argument?(node); end
1178
- end
1179
-
1180
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/fixed_size.rb:49
1181
- RuboCop::Cop::Performance::FixedSize::MSG = T.let(T.unsafe(nil), String)
1182
-
1183
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/fixed_size.rb:50
1184
- RuboCop::Cop::Performance::FixedSize::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1185
-
1186
- # Identifies usages of `map { ... }.flatten` and
1187
- # change them to use `flat_map { ... }` instead.
1188
- #
1189
- # @example
1190
- # # bad
1191
- # [1, 2, 3, 4].map { |e| [e, e] }.flatten(1)
1192
- # [1, 2, 3, 4].collect { |e| [e, e] }.flatten(1)
1193
- #
1194
- # # good
1195
- # [1, 2, 3, 4].flat_map { |e| [e, e] }
1196
- # [1, 2, 3, 4].map { |e| [e, e] }.flatten
1197
- # [1, 2, 3, 4].collect { |e| [e, e] }.flatten
1198
- #
1199
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/flat_map.rb:18
1200
- class RuboCop::Cop::Performance::FlatMap < ::RuboCop::Cop::Base
1201
- include ::RuboCop::Cop::RangeHelp
1202
- extend ::RuboCop::Cop::AutoCorrector
1203
-
1204
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/flat_map.rb:28
1205
- def flat_map_candidate?(param0 = T.unsafe(nil)); end
1206
-
1207
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/flat_map.rb:39
1208
- def on_send(node); end
1209
-
1210
- private
1211
-
1212
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/flat_map.rb:71
1213
- def autocorrect(corrector, node); end
1214
-
1215
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/flat_map.rb:52
1216
- def offense_for_levels(node, map_node, first_method, flatten); end
1217
-
1218
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/flat_map.rb:58
1219
- def offense_for_method(node, map_node, first_method, flatten); end
1220
-
1221
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/flat_map.rb:62
1222
- def register_offense(node, map_node, first_method, flatten, message); end
1223
- end
1224
-
1225
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/flat_map.rb:24
1226
- RuboCop::Cop::Performance::FlatMap::FLATTEN_MULTIPLE_LEVELS = T.let(T.unsafe(nil), String)
1227
-
1228
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/flat_map.rb:22
1229
- RuboCop::Cop::Performance::FlatMap::MSG = T.let(T.unsafe(nil), String)
1230
-
1231
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/flat_map.rb:23
1232
- RuboCop::Cop::Performance::FlatMap::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1233
-
1234
- # Checks for inefficient searching of keys and values within
1235
- # hashes.
1236
- #
1237
- # `Hash#keys.include?` is less efficient than `Hash#key?` because
1238
- # the former allocates a new array and then performs an O(n) search
1239
- # through that array, while `Hash#key?` does not allocate any array and
1240
- # performs a faster O(1) search for the key.
1241
- #
1242
- # `Hash#values.include?` is less efficient than `Hash#value?`. While they
1243
- # both perform an O(n) search through all of the values, calling `values`
1244
- # allocates a new array while using `value?` does not.
1245
- #
1246
- # @example
1247
- # # bad
1248
- # { a: 1, b: 2 }.keys.include?(:a)
1249
- # { a: 1, b: 2 }.keys.include?(:z)
1250
- # h = { a: 1, b: 2 }; h.keys.include?(100)
1251
- #
1252
- # # good
1253
- # { a: 1, b: 2 }.key?(:a)
1254
- # { a: 1, b: 2 }.has_key?(:z)
1255
- # h = { a: 1, b: 2 }; h.key?(100)
1256
- #
1257
- # # bad
1258
- # { a: 1, b: 2 }.values.include?(2)
1259
- # { a: 1, b: 2 }.values.include?('garbage')
1260
- # h = { a: 1, b: 2 }; h.values.include?(nil)
1261
- #
1262
- # # good
1263
- # { a: 1, b: 2 }.value?(2)
1264
- # { a: 1, b: 2 }.has_value?('garbage')
1265
- # h = { a: 1, b: 2 }; h.value?(nil)
1266
- #
1267
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/inefficient_hash_search.rb:42
1268
- class RuboCop::Cop::Performance::InefficientHashSearch < ::RuboCop::Cop::Base
1269
- extend ::RuboCop::Cop::AutoCorrector
1270
-
1271
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/inefficient_hash_search.rb:47
1272
- def inefficient_include?(param0 = T.unsafe(nil)); end
1273
-
1274
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/inefficient_hash_search.rb:51
1275
- def on_send(node); end
1276
-
1277
- private
1278
-
1279
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/inefficient_hash_search.rb:91
1280
- def autocorrect_argument(node); end
1281
-
1282
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/inefficient_hash_search.rb:95
1283
- def autocorrect_hash_expression(node); end
1284
-
1285
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/inefficient_hash_search.rb:73
1286
- def autocorrect_method(node); end
1287
-
1288
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/inefficient_hash_search.rb:80
1289
- def current_method(node); end
1290
-
1291
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/inefficient_hash_search.rb:69
1292
- def message(node); end
1293
-
1294
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/inefficient_hash_search.rb:84
1295
- def use_long_method; end
1296
- end
1297
-
1298
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/inefficient_hash_search.rb:45
1299
- RuboCop::Cop::Performance::InefficientHashSearch::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1300
-
1301
- # Identifies places where inefficient `readlines` method
1302
- # can be replaced by `each_line` to avoid fully loading file content into memory.
1303
- #
1304
- # @example
1305
- #
1306
- # # bad
1307
- # File.readlines('testfile').each { |l| puts l }
1308
- # IO.readlines('testfile', chomp: true).each { |l| puts l }
1309
- #
1310
- # conn.readlines(10).map { |l| l.size }
1311
- # file.readlines.find { |l| l.start_with?('#') }
1312
- # file.readlines.each { |l| puts l }
1313
- #
1314
- # # good
1315
- # File.open('testfile', 'r').each_line { |l| puts l }
1316
- # IO.open('testfile').each_line(chomp: true) { |l| puts l }
1317
- #
1318
- # conn.each_line(10).map { |l| l.size }
1319
- # file.each_line.find { |l| l.start_with?('#') }
1320
- # file.each_line { |l| puts l }
1321
- #
1322
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/io_readlines.rb:27
1323
- class RuboCop::Cop::Performance::IoReadlines < ::RuboCop::Cop::Base
1324
- include ::RuboCop::Cop::RangeHelp
1325
- extend ::RuboCop::Cop::AutoCorrector
1326
-
1327
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/io_readlines.rb:42
1328
- def on_send(node); end
1329
-
1330
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/io_readlines.rb:34
1331
- def readlines_on_class?(param0 = T.unsafe(nil)); end
1332
-
1333
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/io_readlines.rb:38
1334
- def readlines_on_instance?(param0 = T.unsafe(nil)); end
1335
-
1336
- private
1337
-
1338
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/io_readlines.rb:58
1339
- def autocorrect(corrector, enumerable_call, readlines_call, receiver); end
1340
-
1341
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/io_readlines.rb:90
1342
- def build_bad_method(enumerable_call); end
1343
-
1344
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/io_readlines.rb:106
1345
- def build_call_args(call_args_node); end
1346
-
1347
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/io_readlines.rb:82
1348
- def build_good_method(enumerable_call); end
1349
-
1350
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/io_readlines.rb:94
1351
- def correction_range(enumerable_call, readlines_call); end
1352
-
1353
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/io_readlines.rb:76
1354
- def offense_range(enumerable_call, readlines_call); end
1355
- end
1356
-
1357
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/io_readlines.rb:31
1358
- RuboCop::Cop::Performance::IoReadlines::MSG = T.let(T.unsafe(nil), String)
1359
-
1360
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/io_readlines.rb:32
1361
- RuboCop::Cop::Performance::IoReadlines::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1362
-
1363
- # In Ruby 2.7, `Enumerable#filter_map` has been added.
1364
- #
1365
- # This cop identifies places where `map { ... }.compact` can be replaced by `filter_map`.
1366
- #
1367
- # [source,ruby]
1368
- # ----
1369
- # [true, false, nil].compact #=> [true, false]
1370
- # [true, false, nil].filter_map(&:itself) #=> [true]
1371
- # ----
1372
- #
1373
- # @example
1374
- # # bad
1375
- # ary.map(&:foo).compact
1376
- # ary.collect(&:foo).compact
1377
- #
1378
- # # good
1379
- # ary.filter_map(&:foo)
1380
- # ary.map(&:foo).compact!
1381
- # ary.compact.map(&:foo)
1382
- #
1383
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/map_compact.rb:30
1384
- class RuboCop::Cop::Performance::MapCompact < ::RuboCop::Cop::Base
1385
- include ::RuboCop::Cop::RangeHelp
1386
- extend ::RuboCop::Cop::AutoCorrector
1387
- extend ::RuboCop::Cop::TargetRubyVersion
1388
-
1389
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/map_compact.rb:40
1390
- def map_compact(param0 = T.unsafe(nil)); end
1391
-
1392
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/map_compact.rb:53
1393
- def on_send(node); end
1394
-
1395
- private
1396
-
1397
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/map_compact.rb:89
1398
- def compact_method_with_final_newline_range(compact_method_range); end
1399
-
1400
- # @return [Boolean]
1401
- #
1402
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/map_compact.rb:85
1403
- def invoke_method_after_map_compact_on_same_line?(compact_node, chained_method); end
1404
-
1405
- # @return [Boolean]
1406
- #
1407
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/map_compact.rb:81
1408
- def map_method_and_compact_method_on_same_line?(map_node, compact_node); end
1409
-
1410
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/map_compact.rb:67
1411
- def remove_compact_method(corrector, map_node, compact_node, chained_method); end
1412
- end
1413
-
1414
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/map_compact.rb:35
1415
- RuboCop::Cop::Performance::MapCompact::MSG = T.let(T.unsafe(nil), String)
1416
-
1417
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/map_compact.rb:36
1418
- RuboCop::Cop::Performance::MapCompact::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1419
-
1420
- # Identifies places where methods are converted to blocks, with the
1421
- # use of `&method`, and passed as arguments to method calls.
1422
- # It is faster to replace those with explicit blocks, calling those methods inside.
1423
- #
1424
- # @example
1425
- # # bad
1426
- # array.map(&method(:do_something))
1427
- # [1, 2, 3].each(&out.method(:puts))
1428
- #
1429
- # # good
1430
- # array.map { |x| do_something(x) }
1431
- # [1, 2, 3].each { |x| out.puts(x) }
1432
- #
1433
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/method_object_as_block.rb:19
1434
- class RuboCop::Cop::Performance::MethodObjectAsBlock < ::RuboCop::Cop::Base
1435
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/method_object_as_block.rb:22
1436
- def method_object_as_argument?(param0 = T.unsafe(nil)); end
1437
-
1438
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/method_object_as_block.rb:26
1439
- def on_block_pass(node); end
1440
- end
1441
-
1442
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/method_object_as_block.rb:20
1443
- RuboCop::Cop::Performance::MethodObjectAsBlock::MSG = T.let(T.unsafe(nil), String)
1444
-
1445
- # Checks for `OpenStruct.new` calls.
1446
- # Instantiation of an `OpenStruct` invalidates
1447
- # Ruby global method cache as it causes dynamic method
1448
- # definition during program runtime.
1449
- # This could have an effect on performance,
1450
- # especially in case of single-threaded
1451
- # applications with multiple `OpenStruct` instantiations.
1452
- #
1453
- # @example
1454
- # # bad
1455
- # class MyClass
1456
- # def my_method
1457
- # OpenStruct.new(my_key1: 'my_value1', my_key2: 'my_value2')
1458
- # end
1459
- # end
1460
- #
1461
- # # good
1462
- # class MyClass
1463
- # MyStruct = Struct.new(:my_key1, :my_key2)
1464
- # def my_method
1465
- # MyStruct.new('my_value1', 'my_value2')
1466
- # end
1467
- # end
1468
- #
1469
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/open_struct.rb:34
1470
- class RuboCop::Cop::Performance::OpenStruct < ::RuboCop::Cop::Base
1471
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/open_struct.rb:43
1472
- def on_send(node); end
1473
-
1474
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/open_struct.rb:39
1475
- def open_struct(param0 = T.unsafe(nil)); end
1476
- end
1477
-
1478
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/open_struct.rb:35
1479
- RuboCop::Cop::Performance::OpenStruct::MSG = T.let(T.unsafe(nil), String)
1480
-
1481
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/open_struct.rb:37
1482
- RuboCop::Cop::Performance::OpenStruct::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1483
-
1484
- # Identifies uses of `Range#include?` and `Range#member?`, which iterates over each
1485
- # item in a `Range` to see if a specified item is there. In contrast,
1486
- # `Range#cover?` simply compares the target item with the beginning and
1487
- # end points of the `Range`. In a great majority of cases, this is what
1488
- # is wanted.
1489
- #
1490
- # @example
1491
- # # bad
1492
- # ('a'..'z').include?('b') # => true
1493
- # ('a'..'z').member?('b') # => true
1494
- #
1495
- # # good
1496
- # ('a'..'z').cover?('b') # => true
1497
- #
1498
- # # Example of a case where `Range#cover?` may not provide
1499
- # # the desired result:
1500
- #
1501
- # ('a'..'z').cover?('yellow') # => true
1502
- #
1503
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/range_include.rb:28
1504
- class RuboCop::Cop::Performance::RangeInclude < ::RuboCop::Cop::Base
1505
- extend ::RuboCop::Cop::AutoCorrector
1506
-
1507
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/range_include.rb:43
1508
- def on_send(node); end
1509
-
1510
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/range_include.rb:39
1511
- def range_include(param0 = T.unsafe(nil)); end
1512
- end
1513
-
1514
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/range_include.rb:31
1515
- RuboCop::Cop::Performance::RangeInclude::MSG = T.let(T.unsafe(nil), String)
1516
-
1517
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/range_include.rb:32
1518
- RuboCop::Cop::Performance::RangeInclude::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1519
-
1520
- # Identifies the use of a `&block` parameter and `block.call`
1521
- # where `yield` would do just as well.
1522
- #
1523
- # @example
1524
- # # bad
1525
- # def method(&block)
1526
- # block.call
1527
- # end
1528
- # def another(&func)
1529
- # func.call 1, 2, 3
1530
- # end
1531
- #
1532
- # # good
1533
- # def method
1534
- # yield
1535
- # end
1536
- # def another
1537
- # yield 1, 2, 3
1538
- # end
1539
- #
1540
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_block_call.rb:25
1541
- class RuboCop::Cop::Performance::RedundantBlockCall < ::RuboCop::Cop::Base
1542
- extend ::RuboCop::Cop::AutoCorrector
1543
-
1544
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_block_call.rb:43
1545
- def blockarg_assigned?(param0, param1); end
1546
-
1547
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_block_call.rb:39
1548
- def blockarg_calls(param0, param1); end
1549
-
1550
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_block_call.rb:34
1551
- def blockarg_def(param0 = T.unsafe(nil)); end
1552
-
1553
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_block_call.rb:47
1554
- def on_def(node); end
1555
-
1556
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_block_call.rb:47
1557
- def on_defs(node); end
1558
-
1559
- private
1560
-
1561
- # @return [Boolean]
1562
- #
1563
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_block_call.rb:97
1564
- def args_include_block_pass?(blockcall); end
1565
-
1566
- # offenses are registered on the `block.call` nodes
1567
- #
1568
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_block_call.rb:63
1569
- def autocorrect(corrector, node); end
1570
-
1571
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_block_call.rb:81
1572
- def calls_to_report(argname, body); end
1573
-
1574
- # @return [Boolean]
1575
- #
1576
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_block_call.rb:91
1577
- def shadowed_block_argument?(body, block_argument_of_method_signature); end
1578
- end
1579
-
1580
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_block_call.rb:31
1581
- RuboCop::Cop::Performance::RedundantBlockCall::CLOSE_PAREN = T.let(T.unsafe(nil), String)
1582
-
1583
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_block_call.rb:28
1584
- RuboCop::Cop::Performance::RedundantBlockCall::MSG = T.let(T.unsafe(nil), String)
1585
-
1586
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_block_call.rb:30
1587
- RuboCop::Cop::Performance::RedundantBlockCall::OPEN_PAREN = T.let(T.unsafe(nil), String)
1588
-
1589
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_block_call.rb:32
1590
- RuboCop::Cop::Performance::RedundantBlockCall::SPACE = T.let(T.unsafe(nil), String)
1591
-
1592
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_block_call.rb:29
1593
- RuboCop::Cop::Performance::RedundantBlockCall::YIELD = T.let(T.unsafe(nil), String)
1594
-
1595
- # Checks for uses `Enumerable#all?`, `Enumerable#any?`, `Enumerable#one?`,
1596
- # and `Enumerable#none?` are compared with `===` or similar methods in block.
1597
- #
1598
- # By default, `Object#===` behaves the same as `Object#==`, but this
1599
- # behavior is appropriately overridden in subclass. For example,
1600
- # `Range#===` returns `true` when argument is within the range.
1601
- #
1602
- # @example
1603
- # # bad
1604
- # items.all? { |item| pattern === item }
1605
- # items.all? { |item| item == other }
1606
- # items.all? { |item| item.is_a?(Klass) }
1607
- # items.all? { |item| item.kind_of?(Klass) }
1608
- #
1609
- # # good
1610
- # items.all?(pattern)
1611
- #
1612
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_equality_comparison_block.rb:26
1613
- class RuboCop::Cop::Performance::RedundantEqualityComparisonBlock < ::RuboCop::Cop::Base
1614
- extend ::RuboCop::Cop::AutoCorrector
1615
- extend ::RuboCop::Cop::TargetRubyVersion
1616
-
1617
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_equality_comparison_block.rb:38
1618
- def on_block(node); end
1619
-
1620
- private
1621
-
1622
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_equality_comparison_block.rb:76
1623
- def new_argument(block_argument, block_body); end
1624
-
1625
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_equality_comparison_block.rb:99
1626
- def offense_range(node); end
1627
-
1628
- # @return [Boolean]
1629
- #
1630
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_equality_comparison_block.rb:58
1631
- def one_block_argument?(block_arguments); end
1632
-
1633
- # @return [Boolean]
1634
- #
1635
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_equality_comparison_block.rb:66
1636
- def same_block_argument_and_is_a_argument?(block_body, block_argument); end
1637
-
1638
- # @return [Boolean]
1639
- #
1640
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_equality_comparison_block.rb:90
1641
- def use_block_argument_in_method_argument_of_operand?(block_argument, operand); end
1642
-
1643
- # @return [Boolean]
1644
- #
1645
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_equality_comparison_block.rb:62
1646
- def use_equality_comparison_block?(block_body); end
1647
- end
1648
-
1649
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_equality_comparison_block.rb:35
1650
- RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::COMPARISON_METHODS = T.let(T.unsafe(nil), Array)
1651
-
1652
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_equality_comparison_block.rb:36
1653
- RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::IS_A_METHODS = T.let(T.unsafe(nil), Array)
1654
-
1655
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_equality_comparison_block.rb:32
1656
- RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::MSG = T.let(T.unsafe(nil), String)
1657
-
1658
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_equality_comparison_block.rb:34
1659
- RuboCop::Cop::Performance::RedundantEqualityComparisonBlock::TARGET_METHODS = T.let(T.unsafe(nil), Array)
1660
-
1661
- # Identifies the use of `Regexp#match` or `String#match`, which
1662
- # returns `#<MatchData>`/`nil`. The return value of `=~` is an integral
1663
- # index/`nil` and is more performant.
1664
- #
1665
- # @example
1666
- # # bad
1667
- # do_something if str.match(/regex/)
1668
- # while regex.match('str')
1669
- # do_something
1670
- # end
1671
- #
1672
- # # good
1673
- # method(str =~ /regex/)
1674
- # return value unless regex =~ 'str'
1675
- #
1676
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_match.rb:20
1677
- class RuboCop::Cop::Performance::RedundantMatch < ::RuboCop::Cop::Base
1678
- extend ::RuboCop::Cop::AutoCorrector
1679
-
1680
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_match.rb:29
1681
- def match_call?(param0 = T.unsafe(nil)); end
1682
-
1683
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_match.rb:38
1684
- def on_send(node); end
1685
-
1686
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_match.rb:34
1687
- def only_truthiness_matters?(param0 = T.unsafe(nil)); end
1688
-
1689
- private
1690
-
1691
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_match.rb:50
1692
- def autocorrect(corrector, node); end
1693
- end
1694
-
1695
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_match.rb:23
1696
- RuboCop::Cop::Performance::RedundantMatch::MSG = T.let(T.unsafe(nil), String)
1697
-
1698
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_match.rb:25
1699
- RuboCop::Cop::Performance::RedundantMatch::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1700
-
1701
- # Identifies places where `Hash#merge!` can be replaced by `Hash#[]=`.
1702
- # You can set the maximum number of key-value pairs to consider
1703
- # an offense with `MaxKeyValuePairs`.
1704
- #
1705
- # @example
1706
- # # bad
1707
- # hash.merge!(a: 1)
1708
- # hash.merge!({'key' => 'value'})
1709
- #
1710
- # # good
1711
- # hash[:a] = 1
1712
- # hash['key'] = 'value'
1713
- # @example MaxKeyValuePairs: 2 (default)
1714
- # # bad
1715
- # hash.merge!(a: 1, b: 2)
1716
- #
1717
- # # good
1718
- # hash[:a] = 1
1719
- # hash[:b] = 2
1720
- #
1721
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:30
1722
- class RuboCop::Cop::Performance::RedundantMerge < ::RuboCop::Cop::Base
1723
- extend ::RuboCop::Cop::AutoCorrector
1724
-
1725
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:47
1726
- def modifier_flow_control?(param0 = T.unsafe(nil)); end
1727
-
1728
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:51
1729
- def on_send(node); end
1730
-
1731
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:43
1732
- def redundant_merge_candidate(param0 = T.unsafe(nil)); end
1733
-
1734
- private
1735
-
1736
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:106
1737
- def correct_multiple_elements(corrector, node, parent, new_source); end
1738
-
1739
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:118
1740
- def correct_single_element(corrector, node, new_source); end
1741
-
1742
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:78
1743
- def each_redundant_merge(node); end
1744
-
1745
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:150
1746
- def indent_width; end
1747
-
1748
- # @return [Boolean]
1749
- #
1750
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:97
1751
- def kwsplat_used?(pairs); end
1752
-
1753
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:146
1754
- def leading_spaces(node); end
1755
-
1756
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:154
1757
- def max_key_value_pairs; end
1758
-
1759
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:70
1760
- def message(node); end
1761
-
1762
- # @return [Boolean]
1763
- #
1764
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:86
1765
- def non_redundant_merge?(node, receiver, pairs); end
1766
-
1767
- # @return [Boolean]
1768
- #
1769
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:93
1770
- def non_redundant_pairs?(receiver, pairs); end
1771
-
1772
- # @return [Boolean]
1773
- #
1774
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:101
1775
- def non_redundant_value_used?(receiver, node); end
1776
-
1777
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:134
1778
- def rewrite_with_modifier(node, parent, new_source); end
1779
-
1780
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:122
1781
- def to_assignments(receiver, pairs); end
1782
- end
1783
-
1784
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:33
1785
- RuboCop::Cop::Performance::RedundantMerge::AREF_ASGN = T.let(T.unsafe(nil), String)
1786
-
1787
- # A utility class for checking the use of values within an
1788
- # `each_with_object` call.
1789
- #
1790
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:160
1791
- class RuboCop::Cop::Performance::RedundantMerge::EachWithObjectInspector
1792
- extend ::RuboCop::AST::NodePattern::Macros
1793
-
1794
- # @return [EachWithObjectInspector] a new instance of EachWithObjectInspector
1795
- #
1796
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:163
1797
- def initialize(node, receiver); end
1798
-
1799
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:194
1800
- def each_with_object_node(param0 = T.unsafe(nil)); end
1801
-
1802
- # @return [Boolean]
1803
- #
1804
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:168
1805
- def value_used?; end
1806
-
1807
- private
1808
-
1809
- # @return [Boolean]
1810
- #
1811
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:178
1812
- def eligible_receiver?; end
1813
-
1814
- # Returns the value of attribute node.
1815
- #
1816
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:176
1817
- def node; end
1818
-
1819
- # Returns the value of attribute receiver.
1820
- #
1821
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:176
1822
- def receiver; end
1823
-
1824
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:182
1825
- def second_argument; end
1826
-
1827
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:189
1828
- def unwind(receiver); end
1829
- end
1830
-
1831
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:34
1832
- RuboCop::Cop::Performance::RedundantMerge::MSG = T.let(T.unsafe(nil), String)
1833
-
1834
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:35
1835
- RuboCop::Cop::Performance::RedundantMerge::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1836
-
1837
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_merge.rb:37
1838
- RuboCop::Cop::Performance::RedundantMerge::WITH_MODIFIER_CORRECTION = T.let(T.unsafe(nil), String)
1839
-
1840
- # Identifies places where `sort { |a, b| a <=> b }` can be replaced with `sort`.
1841
- #
1842
- # @example
1843
- # # bad
1844
- # array.sort { |a, b| a <=> b }
1845
- #
1846
- # # good
1847
- # array.sort
1848
- #
1849
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_sort_block.rb:15
1850
- class RuboCop::Cop::Performance::RedundantSortBlock < ::RuboCop::Cop::Base
1851
- include ::RuboCop::Cop::RangeHelp
1852
- include ::RuboCop::Cop::SortBlock
1853
- extend ::RuboCop::Cop::AutoCorrector
1854
-
1855
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_sort_block.rb:21
1856
- def on_block(node); end
1857
-
1858
- private
1859
-
1860
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_sort_block.rb:35
1861
- def message(var_a, var_b); end
1862
- end
1863
-
1864
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_sort_block.rb:19
1865
- RuboCop::Cop::Performance::RedundantSortBlock::MSG = T.let(T.unsafe(nil), String)
1866
-
1867
- # Identifies places where `split` argument can be replaced from
1868
- # a deterministic regexp to a string.
1869
- #
1870
- # @example
1871
- # # bad
1872
- # 'a,b,c'.split(/,/)
1873
- #
1874
- # # good
1875
- # 'a,b,c'.split(',')
1876
- #
1877
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_split_regexp_argument.rb:15
1878
- class RuboCop::Cop::Performance::RedundantSplitRegexpArgument < ::RuboCop::Cop::Base
1879
- extend ::RuboCop::Cop::AutoCorrector
1880
-
1881
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_split_regexp_argument.rb:27
1882
- def on_send(node); end
1883
-
1884
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_split_regexp_argument.rb:23
1885
- def split_call_with_regexp?(param0 = T.unsafe(nil)); end
1886
-
1887
- private
1888
-
1889
- # @return [Boolean]
1890
- #
1891
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_split_regexp_argument.rb:41
1892
- def determinist_regexp?(regexp_node); end
1893
-
1894
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_split_regexp_argument.rb:45
1895
- def replacement(regexp_node); end
1896
- end
1897
-
1898
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_split_regexp_argument.rb:20
1899
- RuboCop::Cop::Performance::RedundantSplitRegexpArgument::DETERMINISTIC_REGEX = T.let(T.unsafe(nil), Regexp)
1900
-
1901
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_split_regexp_argument.rb:18
1902
- RuboCop::Cop::Performance::RedundantSplitRegexpArgument::MSG = T.let(T.unsafe(nil), String)
1903
-
1904
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_split_regexp_argument.rb:19
1905
- RuboCop::Cop::Performance::RedundantSplitRegexpArgument::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1906
-
1907
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_split_regexp_argument.rb:21
1908
- RuboCop::Cop::Performance::RedundantSplitRegexpArgument::STR_SPECIAL_CHARS = T.let(T.unsafe(nil), Array)
1909
-
1910
- # Checks for redundant `String#chars`.
1911
- #
1912
- # @example
1913
- # # bad
1914
- # str.chars[0..2]
1915
- # str.chars.slice(0..2)
1916
- #
1917
- # # good
1918
- # str[0..2].chars
1919
- #
1920
- # # bad
1921
- # str.chars.first
1922
- # str.chars.first(2)
1923
- #
1924
- # # good
1925
- # str[0]
1926
- # str[0...2].chars
1927
- #
1928
- # # bad
1929
- # str.chars.take(2)
1930
- # str.chars.length
1931
- # str.chars.size
1932
- # str.chars.empty?
1933
- #
1934
- # # good
1935
- # str[0...2].chars
1936
- # str.length
1937
- # str.size
1938
- # str.empty?
1939
- #
1940
- # # For example, if the receiver is a blank string, it will be incompatible.
1941
- # # If a negative value is specified for the receiver, `nil` is returned.
1942
- # str.chars.last # Incompatible with `str[-1]`.
1943
- # str.chars.last(2) # Incompatible with `str[-2..-1].chars`.
1944
- # str.chars.drop(2) # Incompatible with `str[2..-1].chars`.
1945
- #
1946
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_string_chars.rb:42
1947
- class RuboCop::Cop::Performance::RedundantStringChars < ::RuboCop::Cop::Base
1948
- include ::RuboCop::Cop::RangeHelp
1949
- extend ::RuboCop::Cop::AutoCorrector
1950
-
1951
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_string_chars.rb:53
1952
- def on_send(node); end
1953
-
1954
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_string_chars.rb:49
1955
- def redundant_chars_call?(param0 = T.unsafe(nil)); end
1956
-
1957
- private
1958
-
1959
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_string_chars.rb:108
1960
- def build_bad_method(method, args); end
1961
-
1962
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_string_chars.rb:121
1963
- def build_call_args(call_args_node); end
1964
-
1965
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_string_chars.rb:83
1966
- def build_good_method(method, args); end
1967
-
1968
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_string_chars.rb:96
1969
- def build_good_method_for_brackets_or_first_method(method, args); end
1970
-
1971
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_string_chars.rb:77
1972
- def build_message(method, args); end
1973
-
1974
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_string_chars.rb:73
1975
- def correction_range(receiver, node); end
1976
-
1977
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_string_chars.rb:69
1978
- def offense_range(receiver, node); end
1979
- end
1980
-
1981
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_string_chars.rb:46
1982
- RuboCop::Cop::Performance::RedundantStringChars::MSG = T.let(T.unsafe(nil), String)
1983
-
1984
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/redundant_string_chars.rb:47
1985
- RuboCop::Cop::Performance::RedundantStringChars::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
1986
-
1987
- # In Ruby 2.4, `String#match?`, `Regexp#match?`, and `Symbol#match?`
1988
- # have been added. The methods are faster than `match`.
1989
- # Because the methods avoid creating a `MatchData` object or saving
1990
- # backref.
1991
- # So, when `MatchData` is not used, use `match?` instead of `match`.
1992
- #
1993
- # @example
1994
- # # bad
1995
- # def foo
1996
- # if x =~ /re/
1997
- # do_something
1998
- # end
1999
- # end
2000
- #
2001
- # # bad
2002
- # def foo
2003
- # if x !~ /re/
2004
- # do_something
2005
- # end
2006
- # end
2007
- #
2008
- # # bad
2009
- # def foo
2010
- # if x.match(/re/)
2011
- # do_something
2012
- # end
2013
- # end
2014
- #
2015
- # # bad
2016
- # def foo
2017
- # if /re/ === x
2018
- # do_something
2019
- # end
2020
- # end
2021
- #
2022
- # # good
2023
- # def foo
2024
- # if x.match?(/re/)
2025
- # do_something
2026
- # end
2027
- # end
2028
- #
2029
- # # good
2030
- # def foo
2031
- # if !x.match?(/re/)
2032
- # do_something
2033
- # end
2034
- # end
2035
- #
2036
- # # good
2037
- # def foo
2038
- # if x =~ /re/
2039
- # do_something(Regexp.last_match)
2040
- # end
2041
- # end
2042
- #
2043
- # # good
2044
- # def foo
2045
- # if x.match(/re/)
2046
- # do_something($~)
2047
- # end
2048
- # end
2049
- #
2050
- # # good
2051
- # def foo
2052
- # if /re/ === x
2053
- # do_something($~)
2054
- # end
2055
- # end
2056
- #
2057
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:75
2058
- class RuboCop::Cop::Performance::RegexpMatch < ::RuboCop::Cop::Base
2059
- extend ::RuboCop::Cop::AutoCorrector
2060
- extend ::RuboCop::Cop::TargetRubyVersion
2061
-
2062
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:125
2063
- def last_matches(param0); end
2064
-
2065
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:86
2066
- def match_method?(param0 = T.unsafe(nil)); end
2067
-
2068
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:122
2069
- def match_node?(param0 = T.unsafe(nil)); end
2070
-
2071
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:97
2072
- def match_operator?(param0 = T.unsafe(nil)); end
2073
-
2074
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:101
2075
- def match_threequals?(param0 = T.unsafe(nil)); end
2076
-
2077
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:93
2078
- def match_with_int_arg_method?(param0 = T.unsafe(nil)); end
2079
-
2080
- # @return [Boolean]
2081
- #
2082
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:105
2083
- def match_with_lvasgn?(node); end
2084
-
2085
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:138
2086
- def on_case(node); end
2087
-
2088
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:134
2089
- def on_if(node); end
2090
-
2091
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:123
2092
- def search_match_nodes(param0); end
2093
-
2094
- private
2095
-
2096
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:161
2097
- def autocorrect(corrector, node); end
2098
-
2099
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:150
2100
- def check_condition(cond); end
2101
-
2102
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:254
2103
- def correct_operator(corrector, recv, arg, oper = T.unsafe(nil)); end
2104
-
2105
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:279
2106
- def correction_range(recv, arg); end
2107
-
2108
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:217
2109
- def find_last_match(body, range, scope_root); end
2110
-
2111
- # @return [Boolean]
2112
- #
2113
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:177
2114
- def last_match_used?(match_node); end
2115
-
2116
- # @return [Boolean]
2117
- #
2118
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:243
2119
- def match_gvar?(sym); end
2120
-
2121
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:173
2122
- def message(node); end
2123
-
2124
- # @return [Boolean]
2125
- #
2126
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:213
2127
- def modifier_form?(match_node); end
2128
-
2129
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:199
2130
- def next_match_pos(body, match_node_pos, scope_root); end
2131
-
2132
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:186
2133
- def range_to_search_for_last_matches(match_node, body, scope_root); end
2134
-
2135
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:263
2136
- def replace_with_match_predicate_method(corrector, recv, arg, op_range); end
2137
-
2138
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:225
2139
- def scope_body(node); end
2140
-
2141
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:237
2142
- def scope_root(node); end
2143
-
2144
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:274
2145
- def swap_receiver_and_arg(corrector, recv, arg); end
2146
- end
2147
-
2148
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:112
2149
- RuboCop::Cop::Performance::RegexpMatch::MATCH_NODE_PATTERN = T.let(T.unsafe(nil), String)
2150
-
2151
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:84
2152
- RuboCop::Cop::Performance::RegexpMatch::MSG = T.let(T.unsafe(nil), String)
2153
-
2154
- # Constants are included in this list because it is unlikely that
2155
- # someone will store `nil` as a constant and then use it for comparison
2156
- #
2157
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/regexp_match.rb:83
2158
- RuboCop::Cop::Performance::RegexpMatch::TYPES_IMPLEMENTING_MATCH = T.let(T.unsafe(nil), Array)
2159
-
2160
- # Identifies usages of `reverse.each` and change them to use `reverse_each` instead.
2161
- #
2162
- # If the return value is used, it will not be detected because the result will be different.
2163
- #
2164
- # [source,ruby]
2165
- # ----
2166
- # [1, 2, 3].reverse.each {} #=> [3, 2, 1]
2167
- # [1, 2, 3].reverse_each {} #=> [1, 2, 3]
2168
- # ----
2169
- #
2170
- # @example
2171
- # # bad
2172
- # items.reverse.each
2173
- #
2174
- # # good
2175
- # items.reverse_each
2176
- #
2177
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/reverse_each.rb:22
2178
- class RuboCop::Cop::Performance::ReverseEach < ::RuboCop::Cop::Base
2179
- include ::RuboCop::Cop::RangeHelp
2180
- extend ::RuboCop::Cop::AutoCorrector
2181
-
2182
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/reverse_each.rb:33
2183
- def on_send(node); end
2184
-
2185
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/reverse_each.rb:29
2186
- def reverse_each?(param0 = T.unsafe(nil)); end
2187
-
2188
- private
2189
-
2190
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/reverse_each.rb:53
2191
- def offense_range(node); end
2192
-
2193
- # @return [Boolean]
2194
- #
2195
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/reverse_each.rb:47
2196
- def use_return_value?(node); end
2197
- end
2198
-
2199
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/reverse_each.rb:26
2200
- RuboCop::Cop::Performance::ReverseEach::MSG = T.let(T.unsafe(nil), String)
2201
-
2202
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/reverse_each.rb:27
2203
- RuboCop::Cop::Performance::ReverseEach::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2204
-
2205
- # Identifies places where `reverse.first(n)` and `reverse.first`
2206
- # can be replaced by `last(n).reverse` and `last`.
2207
- #
2208
- # @example
2209
- #
2210
- # # bad
2211
- # array.reverse.first(5)
2212
- # array.reverse.first
2213
- #
2214
- # # good
2215
- # array.last(5).reverse
2216
- # array.last
2217
- #
2218
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/reverse_first.rb:19
2219
- class RuboCop::Cop::Performance::ReverseFirst < ::RuboCop::Cop::Base
2220
- include ::RuboCop::Cop::RangeHelp
2221
- extend ::RuboCop::Cop::AutoCorrector
2222
-
2223
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/reverse_first.rb:30
2224
- def on_send(node); end
2225
-
2226
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/reverse_first.rb:26
2227
- def reverse_first_candidate?(param0 = T.unsafe(nil)); end
2228
-
2229
- private
2230
-
2231
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/reverse_first.rb:63
2232
- def build_bad_method(node); end
2233
-
2234
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/reverse_first.rb:55
2235
- def build_good_method(node); end
2236
-
2237
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/reverse_first.rb:49
2238
- def build_message(node); end
2239
-
2240
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/reverse_first.rb:45
2241
- def correction_range(receiver, node); end
2242
- end
2243
-
2244
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/reverse_first.rb:23
2245
- RuboCop::Cop::Performance::ReverseFirst::MSG = T.let(T.unsafe(nil), String)
2246
-
2247
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/reverse_first.rb:24
2248
- RuboCop::Cop::Performance::ReverseFirst::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2249
-
2250
- # In Ruby 2.7, `Enumerable#filter_map` has been added.
2251
- #
2252
- # This cop identifies places where `select.map` can be replaced by `filter_map`.
2253
- #
2254
- # @example
2255
- # # bad
2256
- # ary.select(&:foo).map(&:bar)
2257
- # ary.filter(&:foo).map(&:bar)
2258
- #
2259
- # # good
2260
- # ary.filter_map { |o| o.bar if o.foo }
2261
- #
2262
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/select_map.rb:18
2263
- class RuboCop::Cop::Performance::SelectMap < ::RuboCop::Cop::Base
2264
- include ::RuboCop::Cop::RangeHelp
2265
- extend ::RuboCop::Cop::TargetRubyVersion
2266
-
2267
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/select_map.rb:27
2268
- def bad_method?(param0 = T.unsafe(nil)); end
2269
-
2270
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/select_map.rb:31
2271
- def on_send(node); end
2272
-
2273
- private
2274
-
2275
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/select_map.rb:44
2276
- def map_method_candidate(node); end
2277
-
2278
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/select_map.rb:54
2279
- def offense_range(node, map_method); end
2280
- end
2281
-
2282
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/select_map.rb:24
2283
- RuboCop::Cop::Performance::SelectMap::MSG = T.let(T.unsafe(nil), String)
2284
-
2285
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/select_map.rb:25
2286
- RuboCop::Cop::Performance::SelectMap::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2287
-
2288
- # Identifies usages of `count` on an `Array` and `Hash` and change them to `size`.
2289
- #
2290
- # TODO: Add advanced detection of variables that could
2291
- # have been assigned to an array or a hash.
2292
- #
2293
- # @example
2294
- # # bad
2295
- # [1, 2, 3].count
2296
- # (1..3).to_a.count
2297
- # Array[*1..3].count
2298
- # Array(1..3).count
2299
- #
2300
- # # bad
2301
- # {a: 1, b: 2, c: 3}.count
2302
- # [[:foo, :bar], [1, 2]].to_h.count
2303
- # Hash[*('a'..'z')].count
2304
- # Hash(key: :value).count
2305
- #
2306
- # # good
2307
- # [1, 2, 3].size
2308
- # (1..3).to_a.size
2309
- # Array[*1..3].size
2310
- # Array(1..3).size
2311
- #
2312
- # # good
2313
- # {a: 1, b: 2, c: 3}.size
2314
- # [[:foo, :bar], [1, 2]].to_h.size
2315
- # Hash[*('a'..'z')].size
2316
- # Hash(key: :value).size
2317
- #
2318
- # # good
2319
- # [1, 2, 3].count { |e| e > 2 }
2320
- #
2321
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/size.rb:37
2322
- class RuboCop::Cop::Performance::Size < ::RuboCop::Cop::Base
2323
- extend ::RuboCop::Cop::AutoCorrector
2324
-
2325
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/size.rb:43
2326
- def array?(param0 = T.unsafe(nil)); end
2327
-
2328
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/size.rb:61
2329
- def count?(param0 = T.unsafe(nil)); end
2330
-
2331
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/size.rb:52
2332
- def hash?(param0 = T.unsafe(nil)); end
2333
-
2334
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/size.rb:65
2335
- def on_send(node); end
2336
- end
2337
-
2338
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/size.rb:40
2339
- RuboCop::Cop::Performance::Size::MSG = T.let(T.unsafe(nil), String)
2340
-
2341
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/size.rb:41
2342
- RuboCop::Cop::Performance::Size::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2343
-
2344
- # Identifies places where `sort { |a, b| b <=> a }`
2345
- # can be replaced by a faster `sort.reverse`.
2346
- #
2347
- # @example
2348
- # # bad
2349
- # array.sort { |a, b| b <=> a }
2350
- #
2351
- # # good
2352
- # array.sort.reverse
2353
- #
2354
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sort_reverse.rb:16
2355
- class RuboCop::Cop::Performance::SortReverse < ::RuboCop::Cop::Base
2356
- include ::RuboCop::Cop::RangeHelp
2357
- include ::RuboCop::Cop::SortBlock
2358
- extend ::RuboCop::Cop::AutoCorrector
2359
-
2360
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sort_reverse.rb:22
2361
- def on_block(node); end
2362
-
2363
- private
2364
-
2365
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sort_reverse.rb:38
2366
- def message(var_a, var_b); end
2367
- end
2368
-
2369
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sort_reverse.rb:20
2370
- RuboCop::Cop::Performance::SortReverse::MSG = T.let(T.unsafe(nil), String)
2371
-
2372
- # Identifies places where `gsub(/a+/, 'a')` and `gsub!(/a+/, 'a')`
2373
- # can be replaced by `squeeze('a')` and `squeeze!('a')`.
2374
- #
2375
- # The `squeeze('a')` method is faster than `gsub(/a+/, 'a')`.
2376
- #
2377
- # @example
2378
- #
2379
- # # bad
2380
- # str.gsub(/a+/, 'a')
2381
- # str.gsub!(/a+/, 'a')
2382
- #
2383
- # # good
2384
- # str.squeeze('a')
2385
- # str.squeeze!('a')
2386
- #
2387
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/squeeze.rb:21
2388
- class RuboCop::Cop::Performance::Squeeze < ::RuboCop::Cop::Base
2389
- extend ::RuboCop::Cop::AutoCorrector
2390
-
2391
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/squeeze.rb:41
2392
- def on_send(node); end
2393
-
2394
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/squeeze.rb:32
2395
- def squeeze_candidate?(param0 = T.unsafe(nil)); end
2396
-
2397
- private
2398
-
2399
- # @return [Boolean]
2400
- #
2401
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/squeeze.rb:61
2402
- def repeating_literal?(regex_str); end
2403
- end
2404
-
2405
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/squeeze.rb:24
2406
- RuboCop::Cop::Performance::Squeeze::MSG = T.let(T.unsafe(nil), String)
2407
-
2408
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/squeeze.rb:27
2409
- RuboCop::Cop::Performance::Squeeze::PREFERRED_METHODS = T.let(T.unsafe(nil), Hash)
2410
-
2411
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/squeeze.rb:25
2412
- RuboCop::Cop::Performance::Squeeze::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2413
-
2414
- # Identifies unnecessary use of a regex where `String#start_with?` would suffice.
2415
- #
2416
- # This cop has `SafeMultiline` configuration option that `true` by default because
2417
- # `^start` is unsafe as it will behave incompatible with `start_with?`
2418
- # for receiver is multiline string.
2419
- #
2420
- # @example
2421
- # # bad
2422
- # 'abc'.match?(/\Aab/)
2423
- # /\Aab/.match?('abc')
2424
- # 'abc' =~ /\Aab/
2425
- # /\Aab/ =~ 'abc'
2426
- # 'abc'.match(/\Aab/)
2427
- # /\Aab/.match('abc')
2428
- #
2429
- # # good
2430
- # 'abc'.start_with?('ab')
2431
- # @example SafeMultiline: true (default)
2432
- #
2433
- # # good
2434
- # 'abc'.match?(/^ab/)
2435
- # /^ab/.match?('abc')
2436
- # 'abc' =~ /^ab/
2437
- # /^ab/ =~ 'abc'
2438
- # 'abc'.match(/^ab/)
2439
- # /^ab/.match('abc')
2440
- # @example SafeMultiline: false
2441
- #
2442
- # # bad
2443
- # 'abc'.match?(/^ab/)
2444
- # /^ab/.match?('abc')
2445
- # 'abc' =~ /^ab/
2446
- # /^ab/ =~ 'abc'
2447
- # 'abc'.match(/^ab/)
2448
- # /^ab/.match('abc')
2449
- #
2450
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/start_with.rb:49
2451
- class RuboCop::Cop::Performance::StartWith < ::RuboCop::Cop::Base
2452
- include ::RuboCop::Cop::RegexpMetacharacter
2453
- extend ::RuboCop::Cop::AutoCorrector
2454
-
2455
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/start_with.rb:63
2456
- def on_match_with_lvasgn(node); end
2457
-
2458
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/start_with.rb:63
2459
- def on_send(node); end
2460
-
2461
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/start_with.rb:57
2462
- def redundant_regex?(param0 = T.unsafe(nil)); end
2463
- end
2464
-
2465
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/start_with.rb:53
2466
- RuboCop::Cop::Performance::StartWith::MSG = T.let(T.unsafe(nil), String)
2467
-
2468
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/start_with.rb:55
2469
- RuboCop::Cop::Performance::StartWith::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2470
-
2471
- # Identifies places where string identifier argument can be replaced
2472
- # by symbol identifier argument.
2473
- # It prevents the redundancy of the internal string-to-symbol conversion.
2474
- #
2475
- # This cop targets methods that take identifier (e.g. method name) argument
2476
- # and the following examples are parts of it.
2477
- #
2478
- # @example
2479
- #
2480
- # # bad
2481
- # send('do_something')
2482
- # attr_accessor 'do_something'
2483
- # instance_variable_get('@ivar')
2484
- #
2485
- # # good
2486
- # send(:do_something)
2487
- # attr_accessor :do_something
2488
- # instance_variable_get(:@ivar)
2489
- #
2490
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_identifier_argument.rb:25
2491
- class RuboCop::Cop::Performance::StringIdentifierArgument < ::RuboCop::Cop::Base
2492
- extend ::RuboCop::Cop::AutoCorrector
2493
-
2494
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_identifier_argument.rb:46
2495
- def on_send(node); end
2496
- end
2497
-
2498
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_identifier_argument.rb:28
2499
- RuboCop::Cop::Performance::StringIdentifierArgument::MSG = T.let(T.unsafe(nil), String)
2500
-
2501
- # NOTE: `attr` method is not included in this list as it can cause false positives in Nokogiri API.
2502
- # And `attr` may not be used because `Style/Attr` registers an offense.
2503
- # https://github.com/rubocop/rubocop-performance/issues/278
2504
- #
2505
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_identifier_argument.rb:33
2506
- RuboCop::Cop::Performance::StringIdentifierArgument::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2507
-
2508
- # Identifies unnecessary use of a regex where `String#include?` would suffice.
2509
- #
2510
- # @example
2511
- # # bad
2512
- # 'abc'.match?(/ab/)
2513
- # /ab/.match?('abc')
2514
- # 'abc' =~ /ab/
2515
- # /ab/ =~ 'abc'
2516
- # 'abc'.match(/ab/)
2517
- # /ab/.match('abc')
2518
- #
2519
- # # good
2520
- # 'abc'.include?('ab')
2521
- #
2522
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_include.rb:22
2523
- class RuboCop::Cop::Performance::StringInclude < ::RuboCop::Cop::Base
2524
- extend ::RuboCop::Cop::AutoCorrector
2525
-
2526
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_include.rb:34
2527
- def on_match_with_lvasgn(node); end
2528
-
2529
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_include.rb:34
2530
- def on_send(node); end
2531
-
2532
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_include.rb:28
2533
- def redundant_regex?(param0 = T.unsafe(nil)); end
2534
-
2535
- private
2536
-
2537
- # @return [Boolean]
2538
- #
2539
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_include.rb:50
2540
- def literal?(regex_str); end
2541
- end
2542
-
2543
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_include.rb:25
2544
- RuboCop::Cop::Performance::StringInclude::MSG = T.let(T.unsafe(nil), String)
2545
-
2546
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_include.rb:26
2547
- RuboCop::Cop::Performance::StringInclude::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2548
-
2549
- # Identifies places where `gsub` can be replaced by `tr` or `delete`.
2550
- #
2551
- # @example
2552
- # # bad
2553
- # 'abc'.gsub('b', 'd')
2554
- # 'abc'.gsub('a', '')
2555
- # 'abc'.gsub(/a/, 'd')
2556
- # 'abc'.gsub!('a', 'd')
2557
- #
2558
- # # good
2559
- # 'abc'.gsub(/.*/, 'a')
2560
- # 'abc'.gsub(/a+/, 'd')
2561
- # 'abc'.tr('b', 'd')
2562
- # 'a b c'.delete(' ')
2563
- #
2564
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:20
2565
- class RuboCop::Cop::Performance::StringReplacement < ::RuboCop::Cop::Base
2566
- include ::RuboCop::Cop::RangeHelp
2567
- extend ::RuboCop::Cop::AutoCorrector
2568
-
2569
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:37
2570
- def on_send(node); end
2571
-
2572
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:31
2573
- def string_replacement?(param0 = T.unsafe(nil)); end
2574
-
2575
- private
2576
-
2577
- # @return [Boolean]
2578
- #
2579
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:83
2580
- def accept_first_param?(first_param); end
2581
-
2582
- # @return [Boolean]
2583
- #
2584
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:78
2585
- def accept_second_param?(second_param); end
2586
-
2587
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:59
2588
- def autocorrect(corrector, node); end
2589
-
2590
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:100
2591
- def first_source(first_param); end
2592
-
2593
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:143
2594
- def message(node, first_source, second_source); end
2595
-
2596
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:150
2597
- def method_suffix(node); end
2598
-
2599
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:48
2600
- def offense(node, first_param, second_param); end
2601
-
2602
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:129
2603
- def range(node); end
2604
-
2605
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:154
2606
- def remove_second_param(corrector, node, first_param); end
2607
-
2608
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:69
2609
- def replace_method(corrector, node, first_source, second_source, first_param); end
2610
-
2611
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:133
2612
- def replacement_method(node, first_source, second_source); end
2613
-
2614
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:118
2615
- def source_from_regex_constructor(node); end
2616
-
2617
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:111
2618
- def source_from_regex_literal(node); end
2619
- end
2620
-
2621
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:29
2622
- RuboCop::Cop::Performance::StringReplacement::BANG = T.let(T.unsafe(nil), String)
2623
-
2624
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:27
2625
- RuboCop::Cop::Performance::StringReplacement::DELETE = T.let(T.unsafe(nil), String)
2626
-
2627
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:26
2628
- RuboCop::Cop::Performance::StringReplacement::DETERMINISTIC_REGEX = T.let(T.unsafe(nil), Regexp)
2629
-
2630
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:24
2631
- RuboCop::Cop::Performance::StringReplacement::MSG = T.let(T.unsafe(nil), String)
2632
-
2633
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:25
2634
- RuboCop::Cop::Performance::StringReplacement::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2635
-
2636
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/string_replacement.rb:28
2637
- RuboCop::Cop::Performance::StringReplacement::TR = T.let(T.unsafe(nil), String)
2638
-
2639
- # Identifies places where custom code finding the sum of elements
2640
- # in some Enumerable object can be replaced by `Enumerable#sum` method.
2641
- #
2642
- # @example OnlySumOrWithInitialValue: false (default)
2643
- # # bad
2644
- # [1, 2, 3].inject(:+) # Autocorrections for cases without initial value are unsafe
2645
- # [1, 2, 3].inject(&:+) # and will only be performed when using the `-A` option.
2646
- # [1, 2, 3].reduce { |acc, elem| acc + elem } # They can be prohibited completely using `SafeAutoCorrect: true`.
2647
- # [1, 2, 3].reduce(10, :+)
2648
- # [1, 2, 3].map { |elem| elem ** 2 }.sum
2649
- # [1, 2, 3].collect(&:count).sum(10)
2650
- #
2651
- # # good
2652
- # [1, 2, 3].sum
2653
- # [1, 2, 3].sum(10)
2654
- # [1, 2, 3].sum { |elem| elem ** 2 }
2655
- # [1, 2, 3].sum(10, &:count)
2656
- # @example OnlySumOrWithInitialValue: true
2657
- # # bad
2658
- # [1, 2, 3].reduce(10, :+)
2659
- # [1, 2, 3].map { |elem| elem ** 2 }.sum
2660
- # [1, 2, 3].collect(&:count).sum(10)
2661
- #
2662
- # # good
2663
- # [1, 2, 3].sum(10)
2664
- # [1, 2, 3].sum { |elem| elem ** 2 }
2665
- # [1, 2, 3].sum(10, &:count)
2666
- #
2667
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:70
2668
- class RuboCop::Cop::Performance::Sum < ::RuboCop::Cop::Base
2669
- include ::RuboCop::Cop::RangeHelp
2670
- extend ::RuboCop::Cop::AutoCorrector
2671
-
2672
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:99
2673
- def acc_plus_elem?(param0 = T.unsafe(nil), param1, param2); end
2674
-
2675
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:99
2676
- def elem_plus_acc?(param0 = T.unsafe(nil), param1, param2); end
2677
-
2678
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:111
2679
- def on_block(node); end
2680
-
2681
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:104
2682
- def on_send(node); end
2683
-
2684
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:79
2685
- def sum_candidate?(param0 = T.unsafe(nil)); end
2686
-
2687
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:83
2688
- def sum_map_candidate?(param0 = T.unsafe(nil)); end
2689
-
2690
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:92
2691
- def sum_with_block_candidate?(param0 = T.unsafe(nil)); end
2692
-
2693
- private
2694
-
2695
- # @return [Boolean]
2696
- #
2697
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:156
2698
- def array_literal?(node); end
2699
-
2700
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:161
2701
- def autocorrect(corrector, init, range); end
2702
-
2703
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:169
2704
- def autocorrect_sum_map(corrector, sum, map, init); end
2705
-
2706
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:245
2707
- def build_block_bad_method(method, init, var_acc, var_elem, body); end
2708
-
2709
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:212
2710
- def build_block_message(send, init, var_acc, var_elem, body); end
2711
-
2712
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:218
2713
- def build_good_method(init, block_pass = T.unsafe(nil)); end
2714
-
2715
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:231
2716
- def build_method_bad_method(init, method, operation); end
2717
-
2718
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:194
2719
- def build_method_message(node, method, init, operation); end
2720
-
2721
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:205
2722
- def build_sum_map_message(method, init); end
2723
-
2724
- # @return [Boolean]
2725
- #
2726
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:151
2727
- def empty_array_literal?(node); end
2728
-
2729
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:126
2730
- def handle_sum_candidate(node); end
2731
-
2732
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:139
2733
- def handle_sum_map_candidate(node); end
2734
-
2735
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:256
2736
- def method_call_with_args_range(node); end
2737
-
2738
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:190
2739
- def sum_block_range(send, node); end
2740
-
2741
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:186
2742
- def sum_map_range(map, sum); end
2743
-
2744
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:182
2745
- def sum_method_range(node); end
2746
- end
2747
-
2748
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:74
2749
- RuboCop::Cop::Performance::Sum::MSG = T.let(T.unsafe(nil), String)
2750
-
2751
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:75
2752
- RuboCop::Cop::Performance::Sum::MSG_IF_NO_INIT_VALUE = T.let(T.unsafe(nil), String)
2753
-
2754
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/sum.rb:77
2755
- RuboCop::Cop::Performance::Sum::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2756
-
2757
- # Checks for .times.map calls.
2758
- # In most cases such calls can be replaced
2759
- # with an explicit array creation.
2760
- #
2761
- # @example
2762
- # # bad
2763
- # 9.times.map do |i|
2764
- # i.to_s
2765
- # end
2766
- #
2767
- # # good
2768
- # Array.new(9) do |i|
2769
- # i.to_s
2770
- # end
2771
- #
2772
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/times_map.rb:32
2773
- class RuboCop::Cop::Performance::TimesMap < ::RuboCop::Cop::Base
2774
- extend ::RuboCop::Cop::AutoCorrector
2775
-
2776
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/times_map.rb:44
2777
- def on_block(node); end
2778
-
2779
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/times_map.rb:40
2780
- def on_send(node); end
2781
-
2782
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/times_map.rb:70
2783
- def times_map_call(param0 = T.unsafe(nil)); end
2784
-
2785
- private
2786
-
2787
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/times_map.rb:50
2788
- def check(node); end
2789
-
2790
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/times_map.rb:61
2791
- def message(map_or_collect, count); end
2792
- end
2793
-
2794
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/times_map.rb:35
2795
- RuboCop::Cop::Performance::TimesMap::MESSAGE = T.let(T.unsafe(nil), String)
2796
-
2797
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/times_map.rb:37
2798
- RuboCop::Cop::Performance::TimesMap::MESSAGE_ONLY_IF = T.let(T.unsafe(nil), String)
2799
-
2800
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/times_map.rb:38
2801
- RuboCop::Cop::Performance::TimesMap::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2802
-
2803
- # In Ruby 2.3 or later, use unary plus operator to unfreeze a string
2804
- # literal instead of `String#dup` and `String.new`.
2805
- # Unary plus operator is faster than `String#dup`.
2806
- #
2807
- # @example
2808
- # # bad
2809
- # ''.dup
2810
- # "something".dup
2811
- # String.new
2812
- # String.new('')
2813
- # String.new('something')
2814
- #
2815
- # # good
2816
- # +'something'
2817
- # +''
2818
- #
2819
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/unfreeze_string.rb:27
2820
- class RuboCop::Cop::Performance::UnfreezeString < ::RuboCop::Cop::Base
2821
- extend ::RuboCop::Cop::AutoCorrector
2822
-
2823
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/unfreeze_string.rb:33
2824
- def dup_string?(param0 = T.unsafe(nil)); end
2825
-
2826
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/unfreeze_string.rb:44
2827
- def on_send(node); end
2828
-
2829
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/unfreeze_string.rb:37
2830
- def string_new?(param0 = T.unsafe(nil)); end
2831
-
2832
- private
2833
-
2834
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/unfreeze_string.rb:57
2835
- def string_value(node); end
2836
- end
2837
-
2838
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/unfreeze_string.rb:30
2839
- RuboCop::Cop::Performance::UnfreezeString::MSG = T.let(T.unsafe(nil), String)
2840
-
2841
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/unfreeze_string.rb:31
2842
- RuboCop::Cop::Performance::UnfreezeString::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2843
-
2844
- # Identifies places where `URI::Parser.new` can be replaced by `URI::DEFAULT_PARSER`.
2845
- #
2846
- # @example
2847
- # # bad
2848
- # URI::Parser.new
2849
- #
2850
- # # good
2851
- # URI::DEFAULT_PARSER
2852
- #
2853
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/uri_default_parser.rb:15
2854
- class RuboCop::Cop::Performance::UriDefaultParser < ::RuboCop::Cop::Base
2855
- extend ::RuboCop::Cop::AutoCorrector
2856
-
2857
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/uri_default_parser.rb:28
2858
- def on_send(node); end
2859
-
2860
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/uri_default_parser.rb:22
2861
- def uri_parser_new?(param0 = T.unsafe(nil)); end
2862
- end
2863
-
2864
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/uri_default_parser.rb:18
2865
- RuboCop::Cop::Performance::UriDefaultParser::MSG = T.let(T.unsafe(nil), String)
2866
-
2867
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/performance/uri_default_parser.rb:20
2868
- RuboCop::Cop::Performance::UriDefaultParser::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
2869
-
2870
- # Common functionality for handling regexp metacharacters.
2871
- #
2872
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/mixin/regexp_metacharacter.rb:6
2873
- module RuboCop::Cop::RegexpMetacharacter
2874
- private
2875
-
2876
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/mixin/regexp_metacharacter.rb:63
2877
- def drop_end_metacharacter(regexp_string); end
2878
-
2879
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/mixin/regexp_metacharacter.rb:55
2880
- def drop_start_metacharacter(regexp_string); end
2881
-
2882
- # @return [Boolean]
2883
- #
2884
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/mixin/regexp_metacharacter.rb:15
2885
- def literal_at_end?(regexp); end
2886
-
2887
- # @return [Boolean]
2888
- #
2889
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/mixin/regexp_metacharacter.rb:41
2890
- def literal_at_end_with_backslash_z?(regex_str); end
2891
-
2892
- # @return [Boolean]
2893
- #
2894
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/mixin/regexp_metacharacter.rb:48
2895
- def literal_at_end_with_dollar?(regex_str); end
2896
-
2897
- # @return [Boolean]
2898
- #
2899
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/mixin/regexp_metacharacter.rb:9
2900
- def literal_at_start?(regexp); end
2901
-
2902
- # @return [Boolean]
2903
- #
2904
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/mixin/regexp_metacharacter.rb:21
2905
- def literal_at_start_with_backslash_a?(regex_str); end
2906
-
2907
- # @return [Boolean]
2908
- #
2909
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/mixin/regexp_metacharacter.rb:31
2910
- def literal_at_start_with_caret?(regex_str); end
2911
-
2912
- # @return [Boolean]
2913
- #
2914
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/mixin/regexp_metacharacter.rb:71
2915
- def safe_multiline?; end
2916
- end
2917
-
2918
- # Common functionality for cops checking `Enumerable#sort` blocks.
2919
- #
2920
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/mixin/sort_block.rb:6
2921
- module RuboCop::Cop::SortBlock
2922
- include ::RuboCop::Cop::RangeHelp
2923
- extend ::RuboCop::AST::NodePattern::Macros
2924
-
2925
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/mixin/sort_block.rb:17
2926
- def replaceable_body?(param0 = T.unsafe(nil), param1, param2); end
2927
-
2928
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/mixin/sort_block.rb:10
2929
- def sort_with_block?(param0 = T.unsafe(nil)); end
2930
-
2931
- private
2932
-
2933
- # source://rubocop-performance-1.14.3/lib/rubocop/cop/mixin/sort_block.rb:23
2934
- def sort_range(send, node); end
2935
- end
2936
-
2937
- # source://rubocop-1.35.1/lib/rubocop/ast_aliases.rb:5
2938
- RuboCop::NodePattern = RuboCop::AST::NodePattern
2939
-
2940
- # RuboCop Performance project namespace
2941
- #
2942
- # source://rubocop-performance-1.14.3/lib/rubocop/performance.rb:5
2943
- module RuboCop::Performance; end
2944
-
2945
- # source://rubocop-performance-1.14.3/lib/rubocop/performance.rb:8
2946
- RuboCop::Performance::CONFIG = T.let(T.unsafe(nil), Hash)
2947
-
2948
- # source://rubocop-performance-1.14.3/lib/rubocop/performance.rb:7
2949
- RuboCop::Performance::CONFIG_DEFAULT = T.let(T.unsafe(nil), Pathname)
2950
-
2951
- # Because RuboCop doesn't yet support plugins, we have to monkey patch in a
2952
- # bit of our configuration.
2953
- #
2954
- # source://rubocop-performance-1.14.3/lib/rubocop/performance/inject.rb:7
2955
- module RuboCop::Performance::Inject
2956
- class << self
2957
- # source://rubocop-performance-1.14.3/lib/rubocop/performance/inject.rb:8
2958
- def defaults!; end
2959
- end
2960
- end
2961
-
2962
- # source://rubocop-performance-1.14.3/lib/rubocop/performance.rb:6
2963
- RuboCop::Performance::PROJECT_ROOT = T.let(T.unsafe(nil), Pathname)
2964
-
2965
- # This module holds the RuboCop Performance version information.
2966
- #
2967
- # source://rubocop-performance-1.14.3/lib/rubocop/performance/version.rb:6
2968
- module RuboCop::Performance::Version
2969
- class << self
2970
- # source://rubocop-performance-1.14.3/lib/rubocop/performance/version.rb:9
2971
- def document_version; end
2972
- end
2973
- end
2974
-
2975
- # source://rubocop-performance-1.14.3/lib/rubocop/performance/version.rb:7
2976
- RuboCop::Performance::Version::STRING = T.let(T.unsafe(nil), String)
2977
-
2978
- # source://rubocop-1.35.1/lib/rubocop/ast_aliases.rb:6
2979
- RuboCop::ProcessedSource = RuboCop::AST::ProcessedSource
2980
-
2981
- # source://rubocop-1.35.1/lib/rubocop/ast_aliases.rb:7
2982
- RuboCop::Token = RuboCop::AST::Token