rubocop 1.54.1 → 1.64.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (297) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +5 -4
  4. data/assets/output.css.erb +159 -0
  5. data/assets/output.html.erb +1 -160
  6. data/config/default.yml +155 -26
  7. data/config/obsoletion.yml +5 -0
  8. data/lib/rubocop/cached_data.rb +11 -3
  9. data/lib/rubocop/cli/command/auto_generate_config.rb +22 -8
  10. data/lib/rubocop/cli/command/lsp.rb +2 -2
  11. data/lib/rubocop/cli/command/show_docs_url.rb +2 -2
  12. data/lib/rubocop/cli.rb +11 -2
  13. data/lib/rubocop/config.rb +36 -12
  14. data/lib/rubocop/config_finder.rb +14 -4
  15. data/lib/rubocop/config_loader.rb +0 -1
  16. data/lib/rubocop/config_obsoletion/parameter_rule.rb +9 -1
  17. data/lib/rubocop/config_obsoletion.rb +11 -8
  18. data/lib/rubocop/config_validator.rb +14 -7
  19. data/lib/rubocop/cop/autocorrect_logic.rb +9 -2
  20. data/lib/rubocop/cop/base.rb +64 -17
  21. data/lib/rubocop/cop/bundler/duplicated_gem.rb +1 -0
  22. data/lib/rubocop/cop/bundler/duplicated_group.rb +127 -0
  23. data/lib/rubocop/cop/bundler/gem_comment.rb +2 -2
  24. data/lib/rubocop/cop/bundler/gem_version.rb +3 -5
  25. data/lib/rubocop/cop/bundler/ordered_gems.rb +9 -1
  26. data/lib/rubocop/cop/correctors/each_to_for_corrector.rb +4 -8
  27. data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +5 -13
  28. data/lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb +7 -4
  29. data/lib/rubocop/cop/documentation.rb +16 -6
  30. data/lib/rubocop/cop/exclude_limit.rb +1 -1
  31. data/lib/rubocop/cop/force.rb +12 -0
  32. data/lib/rubocop/cop/gemspec/dependency_version.rb +3 -5
  33. data/lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb +2 -2
  34. data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +9 -1
  35. data/lib/rubocop/cop/gemspec/required_ruby_version.rb +5 -1
  36. data/lib/rubocop/cop/generator/require_file_injector.rb +1 -1
  37. data/lib/rubocop/cop/internal_affairs/example_description.rb +46 -24
  38. data/lib/rubocop/cop/internal_affairs/method_name_end_with.rb +8 -6
  39. data/lib/rubocop/cop/internal_affairs/method_name_equal.rb +19 -20
  40. data/lib/rubocop/cop/internal_affairs/node_first_or_last_argument.rb +53 -0
  41. data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +123 -29
  42. data/lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb +34 -0
  43. data/lib/rubocop/cop/internal_affairs/redundant_method_dispatch_node.rb +11 -2
  44. data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +2 -0
  45. data/lib/rubocop/cop/internal_affairs.rb +2 -0
  46. data/lib/rubocop/cop/layout/argument_alignment.rb +1 -1
  47. data/lib/rubocop/cop/layout/comment_indentation.rb +1 -1
  48. data/lib/rubocop/cop/layout/dot_position.rb +1 -5
  49. data/lib/rubocop/cop/layout/empty_comment.rb +3 -1
  50. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +42 -9
  51. data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +14 -7
  52. data/lib/rubocop/cop/layout/end_alignment.rb +15 -3
  53. data/lib/rubocop/cop/layout/extra_spacing.rb +4 -10
  54. data/lib/rubocop/cop/layout/first_array_element_indentation.rb +24 -7
  55. data/lib/rubocop/cop/layout/first_parameter_indentation.rb +1 -1
  56. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +2 -2
  57. data/lib/rubocop/cop/layout/heredoc_indentation.rb +4 -1
  58. data/lib/rubocop/cop/layout/indentation_width.rb +1 -1
  59. data/lib/rubocop/cop/layout/leading_comment_space.rb +1 -1
  60. data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +17 -9
  61. data/lib/rubocop/cop/layout/line_continuation_spacing.rb +1 -1
  62. data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +18 -3
  63. data/lib/rubocop/cop/layout/redundant_line_break.rb +29 -6
  64. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +4 -4
  65. data/lib/rubocop/cop/layout/single_line_block_chain.rb +5 -0
  66. data/lib/rubocop/cop/layout/space_after_not.rb +1 -1
  67. data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +2 -2
  68. data/lib/rubocop/cop/layout/space_around_operators.rb +50 -20
  69. data/lib/rubocop/cop/layout/space_before_block_braces.rb +19 -10
  70. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +1 -1
  71. data/lib/rubocop/cop/layout/space_inside_parens.rb +1 -1
  72. data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +3 -4
  73. data/lib/rubocop/cop/layout/trailing_empty_lines.rb +5 -0
  74. data/lib/rubocop/cop/lint/assignment_in_condition.rb +6 -6
  75. data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +2 -2
  76. data/lib/rubocop/cop/lint/constant_overwritten_in_rescue.rb +1 -1
  77. data/lib/rubocop/cop/lint/debugger.rb +38 -3
  78. data/lib/rubocop/cop/lint/deprecated_class_methods.rb +1 -1
  79. data/lib/rubocop/cop/lint/duplicate_methods.rb +1 -1
  80. data/lib/rubocop/cop/lint/empty_block.rb +1 -1
  81. data/lib/rubocop/cop/lint/empty_conditional_body.rb +2 -2
  82. data/lib/rubocop/cop/lint/erb_new_arguments.rb +24 -17
  83. data/lib/rubocop/cop/lint/float_comparison.rb +10 -0
  84. data/lib/rubocop/cop/lint/hash_compare_by_identity.rb +2 -1
  85. data/lib/rubocop/cop/lint/it_without_arguments_in_block.rb +56 -0
  86. data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +85 -0
  87. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +1 -1
  88. data/lib/rubocop/cop/lint/mixed_case_range.rb +10 -5
  89. data/lib/rubocop/cop/lint/next_without_accumulator.rb +6 -21
  90. data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +10 -7
  91. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +3 -5
  92. data/lib/rubocop/cop/lint/number_conversion.rb +9 -4
  93. data/lib/rubocop/cop/lint/redundant_require_statement.rb +4 -0
  94. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +72 -8
  95. data/lib/rubocop/cop/lint/redundant_with_index.rb +6 -2
  96. data/lib/rubocop/cop/lint/redundant_with_object.rb +2 -2
  97. data/lib/rubocop/cop/lint/rescue_type.rb +1 -3
  98. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +14 -8
  99. data/lib/rubocop/cop/lint/script_permission.rb +3 -3
  100. data/lib/rubocop/cop/lint/self_assignment.rb +38 -0
  101. data/lib/rubocop/cop/lint/shadowed_argument.rb +1 -0
  102. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +7 -1
  103. data/lib/rubocop/cop/lint/struct_new_override.rb +12 -12
  104. data/lib/rubocop/cop/lint/suppressed_exception.rb +1 -1
  105. data/lib/rubocop/cop/lint/symbol_conversion.rb +7 -2
  106. data/lib/rubocop/cop/lint/syntax.rb +6 -3
  107. data/lib/rubocop/cop/lint/to_enum_arguments.rb +12 -5
  108. data/lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb +1 -1
  109. data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +2 -2
  110. data/lib/rubocop/cop/lint/unreachable_code.rb +4 -2
  111. data/lib/rubocop/cop/lint/unreachable_loop.rb +8 -2
  112. data/lib/rubocop/cop/lint/useless_access_modifier.rb +2 -2
  113. data/lib/rubocop/cop/lint/useless_assignment.rb +38 -12
  114. data/lib/rubocop/cop/lint/useless_times.rb +2 -2
  115. data/lib/rubocop/cop/lint/void.rb +48 -12
  116. data/lib/rubocop/cop/metrics/abc_size.rb +3 -3
  117. data/lib/rubocop/cop/metrics/block_length.rb +1 -1
  118. data/lib/rubocop/cop/metrics/class_length.rb +8 -3
  119. data/lib/rubocop/cop/metrics/method_length.rb +1 -1
  120. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +7 -7
  121. data/lib/rubocop/cop/mixin/check_line_breakable.rb +1 -1
  122. data/lib/rubocop/cop/mixin/code_length.rb +12 -1
  123. data/lib/rubocop/cop/mixin/comments_help.rb +16 -12
  124. data/lib/rubocop/cop/mixin/configurable_formatting.rb +1 -0
  125. data/lib/rubocop/cop/mixin/def_node.rb +1 -1
  126. data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +23 -13
  127. data/lib/rubocop/cop/mixin/method_complexity.rb +15 -6
  128. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +4 -3
  129. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +6 -8
  130. data/lib/rubocop/cop/mixin/safe_assignment.rb +1 -1
  131. data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
  132. data/lib/rubocop/cop/mixin/string_help.rb +4 -2
  133. data/lib/rubocop/cop/mixin/trailing_comma.rb +1 -1
  134. data/lib/rubocop/cop/naming/block_forwarding.rb +34 -7
  135. data/lib/rubocop/cop/naming/constant_name.rb +1 -2
  136. data/lib/rubocop/cop/naming/file_name.rb +3 -3
  137. data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +3 -1
  138. data/lib/rubocop/cop/naming/inclusive_language.rb +1 -2
  139. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +1 -1
  140. data/lib/rubocop/cop/naming/predicate_name.rb +2 -2
  141. data/lib/rubocop/cop/registry.rb +1 -1
  142. data/lib/rubocop/cop/security/compound_hash.rb +2 -2
  143. data/lib/rubocop/cop/security/open.rb +2 -2
  144. data/lib/rubocop/cop/style/access_modifier_declarations.rb +52 -2
  145. data/lib/rubocop/cop/style/accessor_grouping.rb +1 -1
  146. data/lib/rubocop/cop/style/alias.rb +10 -8
  147. data/lib/rubocop/cop/style/arguments_forwarding.rb +414 -63
  148. data/lib/rubocop/cop/style/array_first_last.rb +64 -0
  149. data/lib/rubocop/cop/style/array_intersect.rb +13 -5
  150. data/lib/rubocop/cop/style/auto_resource_cleanup.rb +21 -14
  151. data/lib/rubocop/cop/style/bisected_attr_accessor.rb +2 -2
  152. data/lib/rubocop/cop/style/block_delimiters.rb +2 -1
  153. data/lib/rubocop/cop/style/case_like_if.rb +5 -5
  154. data/lib/rubocop/cop/style/class_check.rb +1 -0
  155. data/lib/rubocop/cop/style/class_equality_comparison.rb +7 -0
  156. data/lib/rubocop/cop/style/class_vars.rb +3 -3
  157. data/lib/rubocop/cop/style/collection_compact.rb +21 -11
  158. data/lib/rubocop/cop/style/collection_methods.rb +2 -0
  159. data/lib/rubocop/cop/style/combinable_loops.rb +17 -9
  160. data/lib/rubocop/cop/style/commented_keyword.rb +5 -2
  161. data/lib/rubocop/cop/style/concat_array_literals.rb +2 -1
  162. data/lib/rubocop/cop/style/conditional_assignment.rb +7 -8
  163. data/lib/rubocop/cop/style/copyright.rb +31 -21
  164. data/lib/rubocop/cop/style/date_time.rb +5 -4
  165. data/lib/rubocop/cop/style/documentation.rb +24 -24
  166. data/lib/rubocop/cop/style/documentation_method.rb +20 -0
  167. data/lib/rubocop/cop/style/each_for_simple_loop.rb +7 -7
  168. data/lib/rubocop/cop/style/each_with_object.rb +2 -2
  169. data/lib/rubocop/cop/style/empty_case_condition.rb +6 -1
  170. data/lib/rubocop/cop/style/empty_literal.rb +1 -1
  171. data/lib/rubocop/cop/style/eval_with_location.rb +6 -15
  172. data/lib/rubocop/cop/style/exact_regexp_match.rb +4 -2
  173. data/lib/rubocop/cop/style/explicit_block_argument.rb +2 -2
  174. data/lib/rubocop/cop/style/for.rb +3 -1
  175. data/lib/rubocop/cop/style/format_string.rb +33 -12
  176. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +3 -1
  177. data/lib/rubocop/cop/style/guard_clause.rb +26 -0
  178. data/lib/rubocop/cop/style/hash_conversion.rb +10 -0
  179. data/lib/rubocop/cop/style/hash_each_methods.rb +105 -11
  180. data/lib/rubocop/cop/style/hash_except.rb +2 -1
  181. data/lib/rubocop/cop/style/hash_syntax.rb +24 -2
  182. data/lib/rubocop/cop/style/identical_conditional_branches.rb +28 -3
  183. data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +5 -3
  184. data/lib/rubocop/cop/style/inverse_methods.rb +14 -13
  185. data/lib/rubocop/cop/style/invertible_unless_condition.rb +44 -2
  186. data/lib/rubocop/cop/style/lambda_call.rb +5 -0
  187. data/lib/rubocop/cop/style/map_compact_with_conditional_block.rb +8 -10
  188. data/lib/rubocop/cop/style/map_into_array.rb +175 -0
  189. data/lib/rubocop/cop/style/map_to_hash.rb +18 -8
  190. data/lib/rubocop/cop/style/map_to_set.rb +1 -1
  191. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +22 -6
  192. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +2 -4
  193. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +20 -0
  194. data/lib/rubocop/cop/style/method_def_parentheses.rb +1 -1
  195. data/lib/rubocop/cop/style/missing_respond_to_missing.rb +2 -2
  196. data/lib/rubocop/cop/style/mixin_grouping.rb +1 -1
  197. data/lib/rubocop/cop/style/multiline_block_chain.rb +1 -1
  198. data/lib/rubocop/cop/style/multiline_method_signature.rb +10 -1
  199. data/lib/rubocop/cop/style/multiline_ternary_operator.rb +6 -4
  200. data/lib/rubocop/cop/style/nested_ternary_operator.rb +3 -11
  201. data/lib/rubocop/cop/style/next.rb +1 -1
  202. data/lib/rubocop/cop/style/nil_comparison.rb +2 -0
  203. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +1 -1
  204. data/lib/rubocop/cop/style/numeric_predicate.rb +10 -2
  205. data/lib/rubocop/cop/style/object_then.rb +5 -3
  206. data/lib/rubocop/cop/style/one_line_conditional.rb +1 -1
  207. data/lib/rubocop/cop/style/open_struct_use.rb +1 -1
  208. data/lib/rubocop/cop/style/operator_method_call.rb +8 -2
  209. data/lib/rubocop/cop/style/parallel_assignment.rb +3 -5
  210. data/lib/rubocop/cop/style/parentheses_around_condition.rb +8 -0
  211. data/lib/rubocop/cop/style/raise_args.rb +4 -1
  212. data/lib/rubocop/cop/style/redundant_argument.rb +33 -4
  213. data/lib/rubocop/cop/style/redundant_assignment.rb +10 -2
  214. data/lib/rubocop/cop/style/redundant_begin.rb +9 -1
  215. data/lib/rubocop/cop/style/redundant_conditional.rb +1 -9
  216. data/lib/rubocop/cop/style/redundant_current_directory_in_path.rb +5 -4
  217. data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +93 -5
  218. data/lib/rubocop/cop/style/redundant_each.rb +7 -4
  219. data/lib/rubocop/cop/style/redundant_exception.rb +32 -12
  220. data/lib/rubocop/cop/style/redundant_fetch_block.rb +3 -3
  221. data/lib/rubocop/cop/style/redundant_filter_chain.rb +23 -6
  222. data/lib/rubocop/cop/style/redundant_line_continuation.rb +19 -2
  223. data/lib/rubocop/cop/style/redundant_parentheses.rb +71 -22
  224. data/lib/rubocop/cop/style/redundant_percent_q.rb +1 -1
  225. data/lib/rubocop/cop/style/redundant_return.rb +14 -3
  226. data/lib/rubocop/cop/style/redundant_self.rb +17 -2
  227. data/lib/rubocop/cop/style/redundant_self_assignment_branch.rb +5 -0
  228. data/lib/rubocop/cop/style/redundant_sort.rb +9 -8
  229. data/lib/rubocop/cop/style/redundant_sort_by.rb +2 -2
  230. data/lib/rubocop/cop/style/redundant_string_escape.rb +1 -1
  231. data/lib/rubocop/cop/style/require_order.rb +1 -1
  232. data/lib/rubocop/cop/style/return_nil.rb +6 -2
  233. data/lib/rubocop/cop/style/return_nil_in_predicate_method_definition.rb +23 -9
  234. data/lib/rubocop/cop/style/sample.rb +3 -4
  235. data/lib/rubocop/cop/style/select_by_regexp.rb +7 -6
  236. data/lib/rubocop/cop/style/self_assignment.rb +1 -1
  237. data/lib/rubocop/cop/style/semicolon.rb +8 -3
  238. data/lib/rubocop/cop/style/send.rb +4 -4
  239. data/lib/rubocop/cop/style/send_with_literal_method_name.rb +90 -0
  240. data/lib/rubocop/cop/style/single_argument_dig.rb +7 -3
  241. data/lib/rubocop/cop/style/single_line_do_end_block.rb +67 -0
  242. data/lib/rubocop/cop/style/slicing_with_range.rb +76 -10
  243. data/lib/rubocop/cop/style/sole_nested_conditional.rb +3 -1
  244. data/lib/rubocop/cop/style/special_global_vars.rb +1 -2
  245. data/lib/rubocop/cop/style/string_chars.rb +1 -0
  246. data/lib/rubocop/cop/style/string_literals_in_interpolation.rb +30 -5
  247. data/lib/rubocop/cop/style/strip.rb +7 -4
  248. data/lib/rubocop/cop/style/super_arguments.rb +156 -0
  249. data/lib/rubocop/cop/style/super_with_args_parentheses.rb +35 -0
  250. data/lib/rubocop/cop/style/symbol_array.rb +35 -15
  251. data/lib/rubocop/cop/style/symbol_proc.rb +68 -5
  252. data/lib/rubocop/cop/style/top_level_method_definition.rb +1 -1
  253. data/lib/rubocop/cop/style/unpack_first.rb +11 -14
  254. data/lib/rubocop/cop/style/yoda_expression.rb +8 -7
  255. data/lib/rubocop/cop/team.rb +5 -0
  256. data/lib/rubocop/cop/utils/regexp_ranges.rb +27 -14
  257. data/lib/rubocop/cop/variable_force/assignment.rb +1 -3
  258. data/lib/rubocop/cops_documentation_generator.rb +15 -3
  259. data/lib/rubocop/directive_comment.rb +10 -8
  260. data/lib/rubocop/ext/regexp_node.rb +9 -4
  261. data/lib/rubocop/file_finder.rb +4 -7
  262. data/lib/rubocop/formatter/clang_style_formatter.rb +3 -7
  263. data/lib/rubocop/formatter/disabled_config_formatter.rb +23 -8
  264. data/lib/rubocop/formatter/formatter_set.rb +7 -1
  265. data/lib/rubocop/formatter/html_formatter.rb +35 -14
  266. data/lib/rubocop/formatter/json_formatter.rb +0 -1
  267. data/lib/rubocop/formatter/junit_formatter.rb +1 -1
  268. data/lib/rubocop/formatter/offense_count_formatter.rb +12 -2
  269. data/lib/rubocop/formatter/tap_formatter.rb +3 -7
  270. data/lib/rubocop/formatter.rb +1 -1
  271. data/lib/rubocop/lockfile.rb +56 -7
  272. data/lib/rubocop/lsp/logger.rb +1 -1
  273. data/lib/rubocop/lsp/routes.rb +43 -31
  274. data/lib/rubocop/lsp/runtime.rb +21 -4
  275. data/lib/rubocop/lsp/server.rb +13 -6
  276. data/lib/rubocop/lsp/severity.rb +1 -1
  277. data/lib/rubocop/lsp.rb +36 -0
  278. data/lib/rubocop/magic_comment.rb +13 -11
  279. data/lib/rubocop/options.rb +14 -11
  280. data/lib/rubocop/path_util.rb +6 -2
  281. data/lib/rubocop/rake_task.rb +1 -1
  282. data/lib/rubocop/result_cache.rb +4 -1
  283. data/lib/rubocop/rspec/cop_helper.rb +8 -2
  284. data/lib/rubocop/rspec/expect_offense.rb +16 -8
  285. data/lib/rubocop/rspec/shared_contexts.rb +55 -19
  286. data/lib/rubocop/rspec/support.rb +2 -0
  287. data/lib/rubocop/runner.rb +19 -6
  288. data/lib/rubocop/server/cache.rb +1 -1
  289. data/lib/rubocop/server/client_command/exec.rb +1 -2
  290. data/lib/rubocop/server/server_command/exec.rb +0 -1
  291. data/lib/rubocop/string_interpreter.rb +3 -3
  292. data/lib/rubocop/target_finder.rb +91 -81
  293. data/lib/rubocop/target_ruby.rb +82 -76
  294. data/lib/rubocop/version.rb +19 -4
  295. data/lib/rubocop.rb +9 -0
  296. metadata +29 -16
  297. /data/lib/rubocop/formatter/{git_hub_actions_formatter.rb → github_actions_formatter.rb} +0 -0
data/config/default.yml CHANGED
@@ -144,6 +144,12 @@ AllCops:
144
144
  # Ruby version is still unresolved, RuboCop will use the oldest officially
145
145
  # supported Ruby version (currently Ruby 2.7).
146
146
  TargetRubyVersion: ~
147
+ # You can specify the parser engine. There are two options available:
148
+ # - `parser_whitequark` ... https://github.com/whitequark/parser
149
+ # - `parser_prism` ... https://github.com/ruby/prism (`Prism::Translation::Parser`)
150
+ # By default, `parser` is used. For the `TargetRubyVersion` value, `parser` can be specified for versions `2.0` and above.
151
+ # `parser_prism` can be specified for versions `3.3` and above. `parser_prism` is faster but still considered experimental.
152
+ ParserEngine: parser_whitequark
147
153
  # Determines if a notification for extension libraries should be shown when
148
154
  # rubocop is run. Keys are the name of the extension, and values are an array
149
155
  # of gems in the Gemfile that the extension is suggested for, if not already
@@ -157,6 +163,7 @@ AllCops:
157
163
  rubocop-graphql: [graphql]
158
164
  rubocop-capybara: [capybara]
159
165
  rubocop-factory_bot: [factory_bot, factory_bot_rails]
166
+ rubocop-rspec_rails: [rspec-rails]
160
167
  # Enable/Disable checking the methods extended by Active Support.
161
168
  ActiveSupportExtensionsEnabled: false
162
169
 
@@ -173,6 +180,16 @@ Bundler/DuplicatedGem:
173
180
  - '**/Gemfile'
174
181
  - '**/gems.rb'
175
182
 
183
+ Bundler/DuplicatedGroup:
184
+ Description: 'Checks for duplicate group entries in Gemfile.'
185
+ Enabled: true
186
+ Severity: warning
187
+ VersionAdded: '1.56'
188
+ Include:
189
+ - '**/*.gemfile'
190
+ - '**/Gemfile'
191
+ - '**/gems.rb'
192
+
176
193
  Bundler/GemComment:
177
194
  Description: 'Add a comment describing each gem.'
178
195
  Enabled: false
@@ -546,7 +563,9 @@ Layout/ElseAlignment:
546
563
  Layout/EmptyComment:
547
564
  Description: 'Checks empty comment.'
548
565
  Enabled: true
566
+ AutoCorrect: contextual
549
567
  VersionAdded: '0.53'
568
+ VersionChanged: '1.61'
550
569
  AllowBorderComment: true
551
570
  AllowMarginComment: true
552
571
 
@@ -1341,6 +1360,10 @@ Layout/SpaceAroundOperators:
1341
1360
  SupportedStylesForExponentOperator:
1342
1361
  - space
1343
1362
  - no_space
1363
+ EnforcedStyleForRationalLiterals: no_space
1364
+ SupportedStylesForRationalLiterals:
1365
+ - space
1366
+ - no_space
1344
1367
 
1345
1368
  Layout/SpaceBeforeBlockBraces:
1346
1369
  Description: >-
@@ -1635,7 +1658,7 @@ Lint/Debugger:
1635
1658
  Description: 'Check for debugger calls.'
1636
1659
  Enabled: true
1637
1660
  VersionAdded: '0.14'
1638
- VersionChanged: '1.46'
1661
+ VersionChanged: '1.63'
1639
1662
  DebuggerMethods:
1640
1663
  # Groups are available so that a specific group can be disabled in
1641
1664
  # a user's configuration, but are otherwise not significant.
@@ -1648,8 +1671,14 @@ Lint/Debugger:
1648
1671
  - Kernel.byebug
1649
1672
  - Kernel.remote_byebug
1650
1673
  Capybara:
1674
+ - page.save_and_open_page
1675
+ - page.save_and_open_screenshot
1676
+ - page.save_page
1677
+ - page.save_screenshot
1651
1678
  - save_and_open_page
1652
1679
  - save_and_open_screenshot
1680
+ - save_page
1681
+ - save_screenshot
1653
1682
  debug.rb:
1654
1683
  - binding.b
1655
1684
  - binding.break
@@ -1671,6 +1700,10 @@ Lint/Debugger:
1671
1700
  - jard
1672
1701
  WebConsole:
1673
1702
  - binding.console
1703
+ DebuggerRequires:
1704
+ debug.rb:
1705
+ - debug/open
1706
+ - debug/start
1674
1707
 
1675
1708
  Lint/DeprecatedClassMethods:
1676
1709
  Description: 'Check for deprecated class method calls.'
@@ -1811,16 +1844,18 @@ Lint/EmptyClass:
1811
1844
  Lint/EmptyConditionalBody:
1812
1845
  Description: 'Checks for the presence of `if`, `elsif` and `unless` branches without a body.'
1813
1846
  Enabled: true
1847
+ AutoCorrect: contextual
1814
1848
  SafeAutoCorrect: false
1815
1849
  AllowComments: true
1816
1850
  VersionAdded: '0.89'
1817
- VersionChanged: '1.34'
1851
+ VersionChanged: '1.61'
1818
1852
 
1819
1853
  Lint/EmptyEnsure:
1820
1854
  Description: 'Checks for empty ensure block.'
1821
1855
  Enabled: true
1856
+ AutoCorrect: contextual
1822
1857
  VersionAdded: '0.10'
1823
- VersionChanged: '0.48'
1858
+ VersionChanged: '1.61'
1824
1859
 
1825
1860
  Lint/EmptyExpression:
1826
1861
  Description: 'Checks for empty expressions.'
@@ -1842,8 +1877,9 @@ Lint/EmptyInPattern:
1842
1877
  Lint/EmptyInterpolation:
1843
1878
  Description: 'Checks for empty string interpolation.'
1844
1879
  Enabled: true
1880
+ AutoCorrect: contextual
1845
1881
  VersionAdded: '0.20'
1846
- VersionChanged: '0.45'
1882
+ VersionChanged: '1.61'
1847
1883
 
1848
1884
  Lint/EmptyWhen:
1849
1885
  Description: 'Checks for `when` branches with empty bodies.'
@@ -1949,6 +1985,12 @@ Lint/InterpolationCheck:
1949
1985
  VersionAdded: '0.50'
1950
1986
  VersionChanged: '1.40'
1951
1987
 
1988
+ Lint/ItWithoutArgumentsInBlock:
1989
+ Description: 'Checks uses of `it` calls without arguments in block.'
1990
+ Reference: 'https://bugs.ruby-lang.org/issues/18980'
1991
+ Enabled: pending
1992
+ VersionAdded: '1.59'
1993
+
1952
1994
  Lint/LambdaWithoutLiteralBlock:
1953
1995
  Description: 'Checks uses of lambda without a literal block.'
1954
1996
  Enabled: pending
@@ -1959,6 +2001,11 @@ Lint/LiteralAsCondition:
1959
2001
  Enabled: true
1960
2002
  VersionAdded: '0.51'
1961
2003
 
2004
+ Lint/LiteralAssignmentInCondition:
2005
+ Description: 'Checks for literal assignments in the conditions.'
2006
+ Enabled: pending
2007
+ VersionAdded: '1.58'
2008
+
1962
2009
  Lint/LiteralInInterpolation:
1963
2010
  Description: 'Checks for literals used in interpolation.'
1964
2011
  Enabled: true
@@ -2160,7 +2207,9 @@ Lint/RedundantRegexpQuantifiers:
2160
2207
  Lint/RedundantRequireStatement:
2161
2208
  Description: 'Checks for unnecessary `require` statement.'
2162
2209
  Enabled: true
2210
+ SafeAutoCorrect: false
2163
2211
  VersionAdded: '0.76'
2212
+ VersionChanged: '1.57'
2164
2213
 
2165
2214
  Lint/RedundantSafeNavigation:
2166
2215
  Description: 'Checks for redundant safe navigation calls.'
@@ -2368,7 +2417,9 @@ Lint/TopLevelReturnWithArgument:
2368
2417
  Lint/TrailingCommaInAttributeDeclaration:
2369
2418
  Description: 'Checks for trailing commas in attribute declarations.'
2370
2419
  Enabled: true
2420
+ AutoCorrect: contextual
2371
2421
  VersionAdded: '0.90'
2422
+ VersionChanged: '1.61'
2372
2423
 
2373
2424
  Lint/TripleQuotes:
2374
2425
  Description: 'Checks for useless triple quote constructs.'
@@ -2428,8 +2479,9 @@ Lint/UnusedBlockArgument:
2428
2479
  Description: 'Checks for unused block arguments.'
2429
2480
  StyleGuide: '#underscore-unused-vars'
2430
2481
  Enabled: true
2482
+ AutoCorrect: contextual
2431
2483
  VersionAdded: '0.21'
2432
- VersionChanged: '0.22'
2484
+ VersionChanged: '1.61'
2433
2485
  IgnoreEmptyBlocks: true
2434
2486
  AllowUnusedKeywordArguments: false
2435
2487
 
@@ -2437,8 +2489,9 @@ Lint/UnusedMethodArgument:
2437
2489
  Description: 'Checks for unused method arguments.'
2438
2490
  StyleGuide: '#underscore-unused-vars'
2439
2491
  Enabled: true
2492
+ AutoCorrect: contextual
2440
2493
  VersionAdded: '0.21'
2441
- VersionChanged: '0.81'
2494
+ VersionChanged: '1.61'
2442
2495
  AllowUnusedKeywordArguments: false
2443
2496
  IgnoreEmptyMethods: true
2444
2497
  IgnoreNotImplementedMethods: true
@@ -2462,8 +2515,9 @@ Lint/UriRegexp:
2462
2515
  Lint/UselessAccessModifier:
2463
2516
  Description: 'Checks for useless access modifiers.'
2464
2517
  Enabled: true
2518
+ AutoCorrect: contextual
2465
2519
  VersionAdded: '0.20'
2466
- VersionChanged: '0.83'
2520
+ VersionChanged: '1.61'
2467
2521
  ContextCreatingMethods: []
2468
2522
  MethodCreatingMethods: []
2469
2523
 
@@ -2471,8 +2525,9 @@ Lint/UselessAssignment:
2471
2525
  Description: 'Checks for useless assignment to a local variable.'
2472
2526
  StyleGuide: '#underscore-unused-vars'
2473
2527
  Enabled: true
2528
+ AutoCorrect: contextual
2474
2529
  VersionAdded: '0.11'
2475
- VersionChanged: '1.51'
2530
+ VersionChanged: '1.61'
2476
2531
  SafeAutoCorrect: false
2477
2532
 
2478
2533
  Lint/UselessElseWithoutRescue:
@@ -2484,8 +2539,9 @@ Lint/UselessElseWithoutRescue:
2484
2539
  Lint/UselessMethodDefinition:
2485
2540
  Description: 'Checks for useless method definitions.'
2486
2541
  Enabled: true
2542
+ AutoCorrect: contextual
2487
2543
  VersionAdded: '0.90'
2488
- VersionChanged: '0.91'
2544
+ VersionChanged: '1.61'
2489
2545
  Safe: false
2490
2546
 
2491
2547
  Lint/UselessRescue:
@@ -2508,13 +2564,17 @@ Lint/UselessSetterCall:
2508
2564
  Lint/UselessTimes:
2509
2565
  Description: 'Checks for useless `Integer#times` calls.'
2510
2566
  Enabled: true
2511
- VersionAdded: '0.91'
2512
2567
  Safe: false
2568
+ AutoCorrect: contextual
2569
+ VersionAdded: '0.91'
2570
+ VersionChanged: '1.61'
2513
2571
 
2514
2572
  Lint/Void:
2515
2573
  Description: 'Possible use of operator/literal/variable in void context.'
2516
2574
  Enabled: true
2575
+ AutoCorrect: contextual
2517
2576
  VersionAdded: '0.9'
2577
+ VersionChanged: '1.61'
2518
2578
  CheckForMethodsWithNoSideEffects: false
2519
2579
 
2520
2580
  #################### Metrics ###############################
@@ -2713,7 +2773,8 @@ Naming/FileName:
2713
2773
  VersionChanged: '1.23'
2714
2774
  # Camel case file names listed in `AllCops:Include` and all file names listed
2715
2775
  # in `AllCops:Exclude` are excluded by default. Add extra excludes here.
2716
- Exclude: []
2776
+ Exclude:
2777
+ - Rakefile.rb
2717
2778
  # When `true`, requires that each source file should define a class or module
2718
2779
  # with a name which matches the file name (converted to ... case).
2719
2780
  # It further expects it to be nested inside modules which match the names
@@ -3029,6 +3090,7 @@ Style/AccessModifierDeclarations:
3029
3090
  - inline
3030
3091
  - group
3031
3092
  AllowModifiersOnSymbols: true
3093
+ AllowModifiersOnAttrs: true
3032
3094
  SafeAutoCorrect: false
3033
3095
 
3034
3096
  Style/AccessorGrouping:
@@ -3072,7 +3134,20 @@ Style/ArgumentsForwarding:
3072
3134
  StyleGuide: '#arguments-forwarding'
3073
3135
  Enabled: pending
3074
3136
  AllowOnlyRestArgument: true
3137
+ UseAnonymousForwarding: true
3138
+ RedundantRestArgumentNames:
3139
+ - args
3140
+ - arguments
3141
+ RedundantKeywordRestArgumentNames:
3142
+ - kwargs
3143
+ - options
3144
+ - opts
3145
+ RedundantBlockArgumentNames:
3146
+ - blk
3147
+ - block
3148
+ - proc
3075
3149
  VersionAdded: '1.1'
3150
+ VersionChanged: '1.58'
3076
3151
 
3077
3152
  Style/ArrayCoercion:
3078
3153
  Description: >-
@@ -3083,6 +3158,13 @@ Style/ArrayCoercion:
3083
3158
  Enabled: false
3084
3159
  VersionAdded: '0.88'
3085
3160
 
3161
+ Style/ArrayFirstLast:
3162
+ Description: 'Use `arr.first` and `arr.last` instead of `arr[0]` and `arr[-1]`.'
3163
+ Reference: '#first-and-last'
3164
+ Enabled: false
3165
+ VersionAdded: '1.58'
3166
+ Safe: false
3167
+
3086
3168
  Style/ArrayIntersect:
3087
3169
  Description: 'Use `array1.intersect?(array2)` instead of `(array1 & array2).any?`.'
3088
3170
  Enabled: 'pending'
@@ -3343,7 +3425,9 @@ Style/ClassEqualityComparison:
3343
3425
  Description: 'Enforces the use of `Object#instance_of?` instead of class comparison for equality.'
3344
3426
  StyleGuide: '#instance-of-vs-class-comparison'
3345
3427
  Enabled: true
3428
+ SafeAutoCorrect: false
3346
3429
  VersionAdded: '0.93'
3430
+ VersionChanged: '1.57'
3347
3431
  AllowedMethods:
3348
3432
  - ==
3349
3433
  - equal?
@@ -3398,6 +3482,7 @@ Style/CollectionMethods:
3398
3482
  PreferredMethods:
3399
3483
  collect: 'map'
3400
3484
  collect!: 'map!'
3485
+ collect_concat: 'flat_map'
3401
3486
  inject: 'reduce'
3402
3487
  detect: 'find'
3403
3488
  find_all: 'select'
@@ -3603,6 +3688,7 @@ Style/DocumentationMethod:
3603
3688
  Description: 'Checks for missing documentation comment for public methods.'
3604
3689
  Enabled: false
3605
3690
  VersionAdded: '0.43'
3691
+ AllowedMethods: []
3606
3692
  Exclude:
3607
3693
  - 'spec/**/*'
3608
3694
  - 'test/**/*'
@@ -3651,8 +3737,9 @@ Style/EmptyCaseCondition:
3651
3737
  Style/EmptyElse:
3652
3738
  Description: 'Avoid empty else-clauses.'
3653
3739
  Enabled: true
3740
+ AutoCorrect: contextual
3654
3741
  VersionAdded: '0.28'
3655
- VersionChanged: '0.32'
3742
+ VersionChanged: '1.61'
3656
3743
  EnforcedStyle: both
3657
3744
  # empty - warn only on empty `else`
3658
3745
  # nil - warn on `else` with nil in it
@@ -3666,7 +3753,9 @@ Style/EmptyElse:
3666
3753
  Style/EmptyHeredoc:
3667
3754
  Description: 'Checks for using empty heredoc to reduce redundancy.'
3668
3755
  Enabled: pending
3756
+ AutoCorrect: contextual
3669
3757
  VersionAdded: '1.32'
3758
+ VersionChanged: '1.61'
3670
3759
 
3671
3760
  Style/EmptyLambdaParameter:
3672
3761
  Description: 'Omit parens for empty lambda parameters.'
@@ -3684,7 +3773,9 @@ Style/EmptyMethod:
3684
3773
  Description: 'Checks the formatting of empty method definitions.'
3685
3774
  StyleGuide: '#no-single-line-methods'
3686
3775
  Enabled: true
3776
+ AutoCorrect: contextual
3687
3777
  VersionAdded: '0.46'
3778
+ VersionChanged: '1.61'
3688
3779
  EnforcedStyle: compact
3689
3780
  SupportedStyles:
3690
3781
  - compact
@@ -3916,8 +4007,9 @@ Style/HashConversion:
3916
4007
  Description: 'Avoid Hash[] in favor of ary.to_h or literal hashes.'
3917
4008
  StyleGuide: '#avoid-hash-constructor'
3918
4009
  Enabled: pending
4010
+ SafeAutoCorrect: false
3919
4011
  VersionAdded: '1.10'
3920
- VersionChanged: '1.11'
4012
+ VersionChanged: '1.55'
3921
4013
  AllowSplatArgument: true
3922
4014
 
3923
4015
  Style/HashEachMethods:
@@ -3978,6 +4070,8 @@ Style/HashSyntax:
3978
4070
  - either
3979
4071
  # forces use of the 3.1 syntax only if all values can be omitted in the hash.
3980
4072
  - consistent
4073
+ # allow either (implicit or explicit) syntax but enforce consistency within a single hash
4074
+ - either_consistent
3981
4075
  # Force hashes that have a symbol value to use hash rockets
3982
4076
  UseHashRocketsWithSymbolValues: false
3983
4077
  # Do not suggest { a?: 1 } over { :a? => 1 } in ruby19 style
@@ -4118,12 +4212,6 @@ Style/InvertibleUnlessCondition:
4118
4212
  :none?: :any?
4119
4213
  :even?: :odd?
4120
4214
  :odd?: :even?
4121
- # `ActiveSupport` defines some common inverse methods. They are listed below,
4122
- # and not enabled by default.
4123
- # :present?: :blank?
4124
- # :blank?: :present?
4125
- # :include?: :exclude?
4126
- # :exclude?: :include?
4127
4215
 
4128
4216
  Style/IpAddresses:
4129
4217
  Description: "Don't include literal IP addresses in code."
@@ -4204,6 +4292,13 @@ Style/MapCompactWithConditionalBlock:
4204
4292
  Enabled: pending
4205
4293
  VersionAdded: '1.30'
4206
4294
 
4295
+ Style/MapIntoArray:
4296
+ Description: 'Checks for usages of `each` with `<<`, `push`, or `append` which can be replaced by `map`.'
4297
+ StyleGuide: '#functional-code'
4298
+ Enabled: pending
4299
+ VersionAdded: '1.63'
4300
+ Safe: false
4301
+
4207
4302
  Style/MapToHash:
4208
4303
  Description: 'Prefer `to_h` with a block over `map.to_h`.'
4209
4304
  Enabled: pending
@@ -4667,6 +4762,7 @@ Style/OperatorMethodCall:
4667
4762
 
4668
4763
  Style/OptionHash:
4669
4764
  Description: "Don't use option hashes when you can use keyword arguments."
4765
+ StyleGuide: '#keyword-arguments-vs-option-hashes'
4670
4766
  Enabled: false
4671
4767
  VersionAdded: '0.33'
4672
4768
  VersionChanged: '0.34'
@@ -4789,8 +4885,9 @@ Style/RaiseArgs:
4789
4885
  Description: 'Checks the arguments passed to raise/fail.'
4790
4886
  StyleGuide: '#exception-class-messages'
4791
4887
  Enabled: true
4888
+ Safe: false
4792
4889
  VersionAdded: '0.14'
4793
- VersionChanged: '1.2'
4890
+ VersionChanged: '1.61'
4794
4891
  EnforcedStyle: exploded
4795
4892
  SupportedStyles:
4796
4893
  - compact # raise Exception.new(msg)
@@ -4810,12 +4907,16 @@ Style/RedundantArgument:
4810
4907
  Enabled: pending
4811
4908
  Safe: false
4812
4909
  VersionAdded: '1.4'
4813
- VersionChanged: '1.40'
4910
+ VersionChanged: '1.55'
4814
4911
  Methods:
4815
4912
  # Array#join
4816
4913
  join: ''
4817
4914
  # Array#sum
4818
4915
  sum: 0
4916
+ # Kernel.#exit
4917
+ exit: true
4918
+ # Kernel.#exit!
4919
+ exit!: false
4819
4920
  # String#split
4820
4921
  split: ' '
4821
4922
  # String#chomp
@@ -4887,7 +4988,7 @@ Style/RedundantFetchBlock:
4887
4988
  Description: >-
4888
4989
  Use `fetch(key, value)` instead of `fetch(key) { value }`
4889
4990
  when value has Numeric, Rational, Complex, Symbol or String type, `false`, `true`, `nil` or is a constant.
4890
- Reference: 'https://github.com/JuanitoFatas/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code'
4991
+ Reference: 'https://github.com/fastruby/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code'
4891
4992
  Enabled: true
4892
4993
  Safe: false
4893
4994
  # If enabled, this cop will autocorrect usages of
@@ -4909,7 +5010,9 @@ Style/RedundantFilterChain:
4909
5010
  Identifies usages of `any?`, `empty?`, `none?` or `one?` predicate methods chained to
4910
5011
  `select`/`filter`/`find_all` and change them to use predicate method instead.
4911
5012
  Enabled: pending
5013
+ SafeAutoCorrect: false
4912
5014
  VersionAdded: '1.52'
5015
+ VersionChanged: '1.57'
4913
5016
 
4914
5017
  Style/RedundantFreeze:
4915
5018
  Description: "Checks usages of Object#freeze on immutable objects."
@@ -4925,10 +5028,11 @@ Style/RedundantHeredocDelimiterQuotes:
4925
5028
  Style/RedundantInitialize:
4926
5029
  Description: 'Checks for redundant `initialize` methods.'
4927
5030
  Enabled: pending
5031
+ AutoCorrect: contextual
4928
5032
  Safe: false
4929
5033
  AllowComments: true
4930
5034
  VersionAdded: '1.27'
4931
- VersionChanged: '1.28'
5035
+ VersionChanged: '1.61'
4932
5036
 
4933
5037
  Style/RedundantInterpolation:
4934
5038
  Description: 'Checks for strings that are just an interpolated expression.'
@@ -5106,7 +5210,7 @@ Style/Sample:
5106
5210
  Description: >-
5107
5211
  Use `sample` instead of `shuffle.first`,
5108
5212
  `shuffle.last`, and `shuffle[Integer]`.
5109
- Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
5213
+ Reference: 'https://github.com/fastruby/fast-ruby#arrayshufflefirst-vs-arraysample-code'
5110
5214
  Enabled: true
5111
5215
  VersionAdded: '0.30'
5112
5216
 
@@ -5140,6 +5244,13 @@ Style/Send:
5140
5244
  Enabled: false
5141
5245
  VersionAdded: '0.33'
5142
5246
 
5247
+ Style/SendWithLiteralMethodName:
5248
+ Description: 'Detects the use of the `public_send` method with a static method name argument.'
5249
+ Enabled: pending
5250
+ Safe: false
5251
+ AllowSend: true
5252
+ VersionAdded: '1.64'
5253
+
5143
5254
  Style/SignalException:
5144
5255
  Description: 'Checks for proper usage of fail and raise.'
5145
5256
  StyleGuide: '#prefer-raise-over-fail'
@@ -5171,6 +5282,12 @@ Style/SingleLineBlockParams:
5171
5282
  - acc
5172
5283
  - elem
5173
5284
 
5285
+ Style/SingleLineDoEndBlock:
5286
+ Description: 'Checks for single-line `do`...`end` blocks.'
5287
+ StyleGuide: '#single-line-do-end-block'
5288
+ Enabled: pending
5289
+ VersionAdded: '1.57'
5290
+
5174
5291
  Style/SingleLineMethods:
5175
5292
  Description: 'Avoid single-line methods.'
5176
5293
  StyleGuide: '#no-single-line-methods'
@@ -5180,7 +5297,8 @@ Style/SingleLineMethods:
5180
5297
  AllowIfMethodIsEmpty: true
5181
5298
 
5182
5299
  Style/SlicingWithRange:
5183
- Description: 'Checks array slicing is done with endless ranges when suitable.'
5300
+ Description: 'Checks array slicing is done with redundant, endless, and beginless ranges when suitable.'
5301
+ StyleGuide: '#slicing-with-ranges'
5184
5302
  Enabled: true
5185
5303
  VersionAdded: '0.83'
5186
5304
  Safe: false
@@ -5307,6 +5425,17 @@ Style/StructInheritance:
5307
5425
  VersionAdded: '0.29'
5308
5426
  VersionChanged: '1.20'
5309
5427
 
5428
+ Style/SuperArguments:
5429
+ Description: 'Call `super` without arguments and parentheses when the signature is identical.'
5430
+ Enabled: pending
5431
+ VersionAdded: '1.64'
5432
+
5433
+ Style/SuperWithArgsParentheses:
5434
+ Description: 'Use parentheses for `super` with arguments.'
5435
+ StyleGuide: '#super-with-args'
5436
+ Enabled: pending
5437
+ VersionAdded: '1.58'
5438
+
5310
5439
  Style/SwapValues:
5311
5440
  Description: 'Enforces the use of shorthand-style swapping of 2 variables.'
5312
5441
  StyleGuide: '#values-swapping'
@@ -5336,7 +5465,7 @@ Style/SymbolProc:
5336
5465
  Enabled: true
5337
5466
  Safe: false
5338
5467
  VersionAdded: '0.26'
5339
- VersionChanged: '1.40'
5468
+ VersionChanged: '1.64'
5340
5469
  AllowMethodsWithArguments: false
5341
5470
  # A list of method names to be always allowed by the check.
5342
5471
  # The names should be fairly unique, otherwise you'll end up ignoring lots of code.
@@ -224,6 +224,11 @@ changed_parameters:
224
224
  - AllowedMethods
225
225
  - AllowedPatterns
226
226
  severity: warning
227
+ - cops: Style/ArgumentsForwarding
228
+ parameters: AllowOnlyRestArgument
229
+ reason: "`AllowOnlyRestArgument` has no effect with TargetRubyVersion >= 3.2."
230
+ severity: warning
231
+ minimum_ruby_version: 3.2
227
232
 
228
233
  # Enforced styles that have been removed or replaced
229
234
  changed_enforced_styles:
@@ -48,11 +48,19 @@ module RuboCop
48
48
  source_buffer = Parser::Source::Buffer.new(@filename)
49
49
  source_buffer.source = File.read(@filename, encoding: Encoding::UTF_8)
50
50
  offenses.map! do |o|
51
- location = Parser::Source::Range.new(source_buffer,
52
- o['location']['begin_pos'],
53
- o['location']['end_pos'])
51
+ location = location_from_source_buffer(o, source_buffer)
54
52
  Cop::Offense.new(o['severity'], location, o['message'], o['cop_name'], o['status'].to_sym)
55
53
  end
56
54
  end
55
+
56
+ def location_from_source_buffer(offense, source_buffer)
57
+ begin_pos = offense['location']['begin_pos']
58
+ end_pos = offense['location']['end_pos']
59
+ if begin_pos.zero? && end_pos.zero?
60
+ Cop::Offense::NO_LOCATION
61
+ else
62
+ Parser::Source::Range.new(source_buffer, begin_pos, end_pos)
63
+ end
64
+ end
57
65
  end
58
66
  end
@@ -10,13 +10,17 @@ module RuboCop
10
10
 
11
11
  AUTO_GENERATED_FILE = '.rubocop_todo.yml'
12
12
  YAML_OPTIONAL_DOC_START = /\A---(\s+#|\s*\z)/.freeze
13
+ PLACEHOLDER = '###rubocop:inherit_here'
13
14
 
14
15
  PHASE_1 = 'Phase 1 of 2: run Layout/LineLength cop'
15
16
  PHASE_2 = 'Phase 2 of 2: run all cops'
16
17
 
17
18
  PHASE_1_OVERRIDDEN = '(skipped because the default Layout/LineLength:Max is overridden)'
18
19
  PHASE_1_DISABLED = '(skipped because Layout/LineLength is disabled)'
19
- PHASE_1_SKIPPED = '(skipped because a list of cops is passed to the `--only` flag)'
20
+ PHASE_1_SKIPPED_ONLY_COPS =
21
+ '(skipped because a list of cops is passed to the `--only` flag)'
22
+ PHASE_1_SKIPPED_ONLY_EXCLUDE =
23
+ '(skipped because only excludes will be generated due to `--auto-gen-only-exclude` flag)'
20
24
 
21
25
  def run
22
26
  add_formatter
@@ -28,12 +32,14 @@ module RuboCop
28
32
  private
29
33
 
30
34
  def maybe_run_line_length_cop
31
- if !line_length_enabled?(@config_store.for_pwd)
35
+ if only_exclude?
36
+ skip_line_length_cop(PHASE_1_SKIPPED_ONLY_EXCLUDE)
37
+ elsif !line_length_enabled?(@config_store.for_pwd)
32
38
  skip_line_length_cop(PHASE_1_DISABLED)
33
39
  elsif !same_max_line_length?(@config_store.for_pwd, ConfigLoader.default_configuration)
34
40
  skip_line_length_cop(PHASE_1_OVERRIDDEN)
35
41
  elsif options_has_only_flag?
36
- skip_line_length_cop(PHASE_1_SKIPPED)
42
+ skip_line_length_cop(PHASE_1_SKIPPED_ONLY_COPS)
37
43
  else
38
44
  run_line_length_cop
39
45
  end
@@ -64,6 +70,10 @@ module RuboCop
64
70
  @options[:only]
65
71
  end
66
72
 
73
+ def only_exclude?
74
+ @options[:auto_gen_only_exclude]
75
+ end
76
+
67
77
  # Do an initial run with only Layout/LineLength so that cops that
68
78
  # depend on Layout/LineLength:Max get the correct value for that
69
79
  # parameter.
@@ -125,15 +135,19 @@ module RuboCop
125
135
 
126
136
  def existing_configuration(config_file)
127
137
  File.read(config_file, encoding: Encoding::UTF_8)
128
- .sub(/^inherit_from: *[^\n]+/, '')
129
- .sub(/^inherit_from: *(\n *- *[^\n]+)+/, '')
138
+ .sub(/^inherit_from: *[^\n]+/, PLACEHOLDER)
139
+ .sub(/^inherit_from: *(\n *- *[^\n]+)+/, PLACEHOLDER)
130
140
  end
131
141
 
132
142
  def write_config_file(file_name, file_string, rubocop_yml_contents)
133
143
  lines = /\S/.match?(rubocop_yml_contents) ? rubocop_yml_contents.split("\n", -1) : []
134
- doc_start_index = lines.index { |line| YAML_OPTIONAL_DOC_START.match?(line) } || -1
135
- lines.insert(doc_start_index + 1, "inherit_from:#{file_string}\n")
136
- File.write(file_name, lines.join("\n"))
144
+ unless rubocop_yml_contents&.include?(PLACEHOLDER)
145
+ doc_start_index = lines.index { |line| YAML_OPTIONAL_DOC_START.match?(line) } || -1
146
+ lines.insert(doc_start_index + 1, PLACEHOLDER)
147
+ end
148
+ File.write(file_name, lines.join("\n")
149
+ .sub(/#{PLACEHOLDER}\n*/o, "inherit_from:#{file_string}\n\n")
150
+ .sub(/\n\n+\Z/, "\n"))
137
151
  end
138
152
 
139
153
  def relative_path_to_todo_from_options_config
@@ -7,11 +7,11 @@ module RuboCop
7
7
  module Command
8
8
  # Start Language Server Protocol of RuboCop.
9
9
  # @api private
10
- class Lsp < Base
10
+ class LSP < Base
11
11
  self.command_name = :lsp
12
12
 
13
13
  def run
14
- RuboCop::Lsp::Server.new(@config_store).start
14
+ RuboCop::LSP::Server.new(@config_store).start
15
15
  end
16
16
  end
17
17
  end
@@ -26,10 +26,10 @@ module RuboCop
26
26
 
27
27
  cops_array.each do |cop_name|
28
28
  cop = registry_hash[cop_name]
29
-
30
29
  next if cop.empty?
31
30
 
32
- puts Cop::Documentation.url_for(cop.first, @config)
31
+ url = Cop::Documentation.url_for(cop.first, @config)
32
+ puts url if url
33
33
  end
34
34
 
35
35
  puts