checkoff 0.222.0 → 0.225.0

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