rubocop 1.90.0 → 1.92.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/config/default.yml +241 -11
  4. data/config/obsoletion.yml +9 -0
  5. data/lib/rubocop/cached_data.rb +47 -7
  6. data/lib/rubocop/changed_files.rb +134 -0
  7. data/lib/rubocop/cli/command/cop_names.rb +57 -0
  8. data/lib/rubocop/cli/command/execute_runner.rb +23 -3
  9. data/lib/rubocop/cli/command/explain.rb +34 -0
  10. data/lib/rubocop/cli/command/show_cops.rb +6 -0
  11. data/lib/rubocop/cli/command/show_docs_url.rb +6 -4
  12. data/lib/rubocop/cli.rb +11 -4
  13. data/lib/rubocop/comment_config/directive_range.rb +3 -1
  14. data/lib/rubocop/comment_config/disable_next.rb +49 -3
  15. data/lib/rubocop/comment_config/push_pop.rb +55 -0
  16. data/lib/rubocop/comment_config.rb +32 -53
  17. data/lib/rubocop/config.rb +10 -0
  18. data/lib/rubocop/config_loader.rb +18 -7
  19. data/lib/rubocop/config_loader_resolver.rb +79 -12
  20. data/lib/rubocop/config_obsoletion/cop_rule.rb +2 -1
  21. data/lib/rubocop/config_obsoletion/removed_cop.rb +9 -1
  22. data/lib/rubocop/config_obsoletion.rb +1 -1
  23. data/lib/rubocop/config_validator.rb +29 -3
  24. data/lib/rubocop/cop/autocorrect_logic.rb +10 -5
  25. data/lib/rubocop/cop/badge.rb +1 -1
  26. data/lib/rubocop/cop/base.rb +57 -24
  27. data/lib/rubocop/cop/bundler/gem_comment.rb +0 -1
  28. data/lib/rubocop/cop/bundler/ordered_gems.rb +0 -8
  29. data/lib/rubocop/cop/cop_documentation.rb +81 -0
  30. data/lib/rubocop/cop/cop_explanation.rb +140 -0
  31. data/lib/rubocop/cop/correctors/alignment_corrector.rb +13 -1
  32. data/lib/rubocop/cop/correctors/each_to_for_corrector.rb +22 -7
  33. data/lib/rubocop/cop/correctors/empty_line_corrector.rb +1 -1
  34. data/lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb +23 -2
  35. data/lib/rubocop/cop/correctors/parentheses_corrector.rb +45 -8
  36. data/lib/rubocop/cop/correctors.rb +2 -2
  37. data/lib/rubocop/cop/documentation.rb +1 -1
  38. data/lib/rubocop/cop/gemspec/dependency_version.rb +0 -6
  39. data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +0 -6
  40. data/lib/rubocop/cop/gemspec/require_mfa.rb +1 -1
  41. data/lib/rubocop/cop/generator.rb +1 -1
  42. data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +2 -5
  43. data/lib/rubocop/cop/internal_affairs/node_type_group.rb +0 -7
  44. data/lib/rubocop/cop/internal_affairs/on_send_without_on_csend.rb +1 -1
  45. data/lib/rubocop/cop/internal_affairs/redundant_context_config_parameter.rb +1 -7
  46. data/lib/rubocop/cop/internal_affairs/style_detected_api_use.rb +1 -7
  47. data/lib/rubocop/cop/layout/argument_alignment.rb +2 -0
  48. data/lib/rubocop/cop/layout/block_alignment.rb +27 -0
  49. data/lib/rubocop/cop/layout/case_indentation.rb +25 -9
  50. data/lib/rubocop/cop/layout/class_structure.rb +9 -1
  51. data/lib/rubocop/cop/layout/comment_indentation.rb +8 -5
  52. data/lib/rubocop/cop/layout/def_end_alignment.rb +4 -0
  53. data/lib/rubocop/cop/layout/else_alignment.rb +1 -0
  54. data/lib/rubocop/cop/layout/empty_line_after_multiline_condition.rb +14 -5
  55. data/lib/rubocop/cop/layout/empty_lines.rb +5 -2
  56. data/lib/rubocop/cop/layout/empty_lines_after_module_inclusion.rb +1 -1
  57. data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +1 -0
  58. data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +1 -1
  59. data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +23 -1
  60. data/lib/rubocop/cop/layout/end_alignment.rb +16 -10
  61. data/lib/rubocop/cop/layout/extra_spacing.rb +4 -0
  62. data/lib/rubocop/cop/layout/first_argument_indentation.rb +1 -0
  63. data/lib/rubocop/cop/layout/first_array_element_indentation.rb +17 -4
  64. data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +5 -3
  65. data/lib/rubocop/cop/layout/first_method_argument_line_break.rb +6 -0
  66. data/lib/rubocop/cop/layout/first_method_parameter_line_break.rb +4 -0
  67. data/lib/rubocop/cop/layout/first_parameter_indentation.rb +11 -0
  68. data/lib/rubocop/cop/layout/hash_alignment.rb +15 -10
  69. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +2 -0
  70. data/lib/rubocop/cop/layout/heredoc_indentation.rb +15 -0
  71. data/lib/rubocop/cop/layout/indentation_style.rb +4 -1
  72. data/lib/rubocop/cop/layout/indentation_width.rb +4 -4
  73. data/lib/rubocop/cop/layout/line_continuation_spacing.rb +8 -1
  74. data/lib/rubocop/cop/layout/line_end_string_concatenation_indentation.rb +25 -9
  75. data/lib/rubocop/cop/layout/line_length.rb +71 -19
  76. data/lib/rubocop/cop/layout/multiline_array_brace_layout.rb +12 -0
  77. data/lib/rubocop/cop/layout/multiline_block_layout.rb +8 -1
  78. data/lib/rubocop/cop/layout/multiline_hash_brace_layout.rb +7 -0
  79. data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +6 -0
  80. data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +14 -0
  81. data/lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb +4 -0
  82. data/lib/rubocop/cop/layout/redundant_line_break.rb +22 -1
  83. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +15 -2
  84. data/lib/rubocop/cop/layout/single_line_block_chain.rb +10 -2
  85. data/lib/rubocop/cop/layout/space_after_not.rb +5 -0
  86. data/lib/rubocop/cop/layout/space_around_block_parameters.rb +10 -4
  87. data/lib/rubocop/cop/layout/space_around_keyword.rb +10 -0
  88. data/lib/rubocop/cop/layout/space_around_operators.rb +5 -1
  89. data/lib/rubocop/cop/layout/space_before_block_braces.rb +4 -1
  90. data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +15 -2
  91. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +31 -8
  92. data/lib/rubocop/cop/lint/ambiguous_operator.rb +1 -1
  93. data/lib/rubocop/cop/lint/ambiguous_operator_precedence.rb +2 -1
  94. data/lib/rubocop/cop/lint/argument_mismatch.rb +14 -4
  95. data/lib/rubocop/cop/lint/assignment_in_condition.rb +2 -0
  96. data/lib/rubocop/cop/lint/cop_directive_syntax.rb +88 -14
  97. data/lib/rubocop/cop/lint/duplicate_methods.rb +1 -1
  98. data/lib/rubocop/cop/lint/empty_block.rb +1 -1
  99. data/lib/rubocop/cop/lint/empty_conditional_body.rb +3 -1
  100. data/lib/rubocop/cop/lint/literal_as_condition.rb +23 -2
  101. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +63 -19
  102. data/lib/rubocop/cop/lint/loop.rb +24 -2
  103. data/lib/rubocop/cop/lint/misplaced_magic_comment.rb +245 -0
  104. data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +19 -4
  105. data/lib/rubocop/cop/lint/nested_method_definition.rb +1 -1
  106. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +1 -1
  107. data/lib/rubocop/cop/lint/number_conversion.rb +1 -1
  108. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +17 -1
  109. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +42 -17
  110. data/lib/rubocop/cop/lint/redundant_dir_glob_sort.rb +13 -2
  111. data/lib/rubocop/cop/lint/unescaped_bracket_in_regexp.rb +18 -1
  112. data/lib/rubocop/cop/lint/useless_assignment.rb +14 -7
  113. data/lib/rubocop/cop/lint/void.rb +8 -1
  114. data/lib/rubocop/cop/lint.rb +1 -0
  115. data/lib/rubocop/cop/metrics/class_length.rb +4 -2
  116. data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +0 -4
  117. data/lib/rubocop/cop/metrics/module_length.rb +4 -2
  118. data/lib/rubocop/cop/migration/department_name.rb +1 -1
  119. data/lib/rubocop/cop/mixin/alignment.rb +5 -1
  120. data/lib/rubocop/cop/mixin/annotation_comment.rb +1 -1
  121. data/lib/rubocop/cop/mixin/check_line_breakable.rb +17 -14
  122. data/lib/rubocop/cop/mixin/check_single_line_suitability.rb +5 -1
  123. data/lib/rubocop/cop/mixin/code_length.rb +10 -2
  124. data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +12 -1
  125. data/lib/rubocop/cop/mixin/endless_method_body_help.rb +69 -0
  126. data/lib/rubocop/cop/mixin/forbidden_identifiers.rb +2 -2
  127. data/lib/rubocop/cop/mixin/hash_alignment_styles.rb +26 -2
  128. data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +31 -3
  129. data/lib/rubocop/cop/mixin/hash_transform_method.rb +1 -1
  130. data/lib/rubocop/cop/mixin/min_branches_count.rb +3 -1
  131. data/lib/rubocop/cop/mixin/multiline_element_line_breaks.rb +11 -1
  132. data/lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb +9 -0
  133. data/lib/rubocop/cop/mixin/ordered_gem_node.rb +1 -1
  134. data/lib/rubocop/cop/mixin/pattern_matching_help.rb +35 -0
  135. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +29 -3
  136. data/lib/rubocop/cop/mixin/project_index_help.rb +15 -0
  137. data/lib/rubocop/cop/mixin/reparsed_equivalence.rb +13 -3
  138. data/lib/rubocop/cop/mixin/statement_modifier.rb +22 -2
  139. data/lib/rubocop/cop/mixin.rb +4 -2
  140. data/lib/rubocop/cop/naming/accessor_method_name.rb +0 -16
  141. data/lib/rubocop/cop/naming/block_forwarding.rb +4 -1
  142. data/lib/rubocop/cop/naming/block_parameter_name.rb +1 -1
  143. data/lib/rubocop/cop/naming/heredoc_delimiter_case.rb +9 -2
  144. data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +5 -3
  145. data/lib/rubocop/cop/naming/predicate_prefix.rb +7 -22
  146. data/lib/rubocop/cop/offense.rb +59 -3
  147. data/lib/rubocop/cop/registry.rb +10 -2
  148. data/lib/rubocop/cop/security/json_load.rb +16 -4
  149. data/lib/rubocop/cop/severity.rb +12 -0
  150. data/lib/rubocop/cop/style/access_modifier_declarations.rb +10 -2
  151. data/lib/rubocop/cop/style/alias.rb +18 -5
  152. data/lib/rubocop/cop/style/ambiguous_endless_method_definition.rb +4 -3
  153. data/lib/rubocop/cop/style/and_or.rb +4 -0
  154. data/lib/rubocop/cop/style/arguments_forwarding.rb +6 -3
  155. data/lib/rubocop/cop/style/attr.rb +3 -4
  156. data/lib/rubocop/cop/style/bitwise_predicate.rb +6 -4
  157. data/lib/rubocop/cop/style/block_delimiters.rb +29 -3
  158. data/lib/rubocop/cop/style/case_like_if.rb +9 -6
  159. data/lib/rubocop/cop/style/class_and_module_children.rb +54 -16
  160. data/lib/rubocop/cop/style/class_methods_definitions.rb +8 -0
  161. data/lib/rubocop/cop/style/combinable_loops.rb +85 -11
  162. data/lib/rubocop/cop/style/concat_array_literals.rb +46 -7
  163. data/lib/rubocop/cop/style/conditional_assignment.rb +4 -0
  164. data/lib/rubocop/cop/style/constant_visibility.rb +6 -2
  165. data/lib/rubocop/cop/style/data_inheritance.rb +14 -0
  166. data/lib/rubocop/cop/style/directive_scope.rb +154 -21
  167. data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +118 -18
  168. data/lib/rubocop/cop/style/documentation_method.rb +1 -9
  169. data/lib/rubocop/cop/style/double_negation.rb +11 -0
  170. data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
  171. data/lib/rubocop/cop/style/empty_block_parameter.rb +1 -1
  172. data/lib/rubocop/cop/style/empty_lambda_parameter.rb +1 -1
  173. data/lib/rubocop/cop/style/empty_literal.rb +1 -1
  174. data/lib/rubocop/cop/style/empty_method.rb +15 -3
  175. data/lib/rubocop/cop/style/endless_method.rb +91 -11
  176. data/lib/rubocop/cop/style/exact_regexp_match.rb +45 -8
  177. data/lib/rubocop/cop/style/explicit_block_argument.rb +50 -10
  178. data/lib/rubocop/cop/style/file_null.rb +2 -2
  179. data/lib/rubocop/cop/style/float_division.rb +28 -14
  180. data/lib/rubocop/cop/style/for.rb +44 -1
  181. data/lib/rubocop/cop/style/format_string.rb +28 -6
  182. data/lib/rubocop/cop/style/format_string_token.rb +1 -1
  183. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +2 -1
  184. data/lib/rubocop/cop/style/guard_clause.rb +13 -1
  185. data/lib/rubocop/cop/style/hash_conversion.rb +28 -8
  186. data/lib/rubocop/cop/style/hash_lookup_method.rb +35 -9
  187. data/lib/rubocop/cop/style/hash_syntax.rb +16 -3
  188. data/lib/rubocop/cop/style/identical_conditional_branches.rb +22 -3
  189. data/lib/rubocop/cop/style/if_inside_else.rb +21 -1
  190. data/lib/rubocop/cop/style/if_unless_modifier.rb +19 -20
  191. data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +4 -0
  192. data/lib/rubocop/cop/style/if_with_semicolon.rb +47 -4
  193. data/lib/rubocop/cop/style/inverse_methods.rb +24 -2
  194. data/lib/rubocop/cop/style/it_block_parameter.rb +32 -3
  195. data/lib/rubocop/cop/style/keyword_parameters_order.rb +3 -1
  196. data/lib/rubocop/cop/style/lambda.rb +18 -0
  197. data/lib/rubocop/cop/style/lambda_call.rb +7 -2
  198. data/lib/rubocop/cop/style/magic_comment_format.rb +1 -1
  199. data/lib/rubocop/cop/style/map_into_array.rb +1 -2
  200. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +45 -10
  201. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +25 -2
  202. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +26 -3
  203. data/lib/rubocop/cop/style/method_def_parentheses.rb +29 -3
  204. data/lib/rubocop/cop/style/missing_else.rb +7 -1
  205. data/lib/rubocop/cop/style/multiline_if_modifier.rb +45 -5
  206. data/lib/rubocop/cop/style/multiline_in_pattern_then.rb +7 -0
  207. data/lib/rubocop/cop/style/multiline_method_signature.rb +2 -5
  208. data/lib/rubocop/cop/style/multiline_ternary_operator.rb +7 -3
  209. data/lib/rubocop/cop/style/multiline_when_then.rb +7 -0
  210. data/lib/rubocop/cop/style/mutable_constant.rb +28 -1
  211. data/lib/rubocop/cop/style/negated_if_else_condition.rb +2 -1
  212. data/lib/rubocop/cop/style/negative_array_index.rb +9 -1
  213. data/lib/rubocop/cop/style/nested_modifier.rb +36 -12
  214. data/lib/rubocop/cop/style/nested_ternary_operator.rb +26 -8
  215. data/lib/rubocop/cop/style/next.rb +24 -10
  216. data/lib/rubocop/cop/style/nil_comparison.rb +48 -8
  217. data/lib/rubocop/cop/style/nil_lambda.rb +1 -1
  218. data/lib/rubocop/cop/style/non_nil_check.rb +18 -2
  219. data/lib/rubocop/cop/style/not.rb +10 -3
  220. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +11 -1
  221. data/lib/rubocop/cop/style/numeric_predicate.rb +21 -5
  222. data/lib/rubocop/cop/style/one_line_conditional.rb +14 -3
  223. data/lib/rubocop/cop/style/parallel_assignment.rb +1 -1
  224. data/lib/rubocop/cop/style/parentheses_around_condition.rb +6 -1
  225. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +14 -3
  226. data/lib/rubocop/cop/style/reduce_to_hash.rb +17 -1
  227. data/lib/rubocop/cop/style/redundant_begin.rb +20 -3
  228. data/lib/rubocop/cop/style/redundant_condition.rb +34 -17
  229. data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +16 -1
  230. data/lib/rubocop/cop/style/redundant_exception.rb +15 -3
  231. data/lib/rubocop/cop/style/redundant_fetch_block.rb +10 -2
  232. data/lib/rubocop/cop/style/redundant_freeze.rb +10 -1
  233. data/lib/rubocop/cop/style/redundant_parentheses.rb +23 -2
  234. data/lib/rubocop/cop/style/redundant_regexp_argument.rb +7 -0
  235. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +6 -5
  236. data/lib/rubocop/cop/style/redundant_regexp_constructor.rb +25 -5
  237. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +4 -0
  238. data/lib/rubocop/cop/style/regexp_literal.rb +75 -26
  239. data/lib/rubocop/cop/style/require_order.rb +9 -0
  240. data/lib/rubocop/cop/style/rescue_modifier.rb +5 -9
  241. data/lib/rubocop/cop/style/return_nil.rb +17 -2
  242. data/lib/rubocop/cop/style/return_nil_in_predicate_method_definition.rb +11 -1
  243. data/lib/rubocop/cop/style/sample.rb +9 -8
  244. data/lib/rubocop/cop/style/self_assignment.rb +12 -15
  245. data/lib/rubocop/cop/style/semicolon.rb +16 -5
  246. data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
  247. data/lib/rubocop/cop/style/single_line_methods.rb +16 -4
  248. data/lib/rubocop/cop/style/special_global_vars.rb +1 -1
  249. data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +29 -5
  250. data/lib/rubocop/cop/style/string_concatenation.rb +9 -3
  251. data/lib/rubocop/cop/style/struct_inheritance.rb +14 -0
  252. data/lib/rubocop/cop/style/super_arguments.rb +3 -0
  253. data/lib/rubocop/cop/style/symbol_proc.rb +23 -5
  254. data/lib/rubocop/cop/style/ternary_parentheses.rb +23 -1
  255. data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +1 -1
  256. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +23 -19
  257. data/lib/rubocop/cop/style/while_until_modifier.rb +1 -1
  258. data/lib/rubocop/cop/style/yoda_condition.rb +24 -9
  259. data/lib/rubocop/cop/style/yoda_expression.rb +10 -1
  260. data/lib/rubocop/cop/style.rb +0 -1
  261. data/lib/rubocop/cop/team.rb +10 -5
  262. data/lib/rubocop/cop/util.rb +1 -1
  263. data/lib/rubocop/cop/variable_force/assignment.rb +1 -1
  264. data/lib/rubocop/cop/variable_force/variable.rb +14 -1
  265. data/lib/rubocop/cops_documentation_generator.rb +23 -2
  266. data/lib/rubocop/directive_comment.rb +37 -8
  267. data/lib/rubocop/formatter/base_formatter.rb +22 -0
  268. data/lib/rubocop/formatter/disabled_config_formatter.rb +19 -1
  269. data/lib/rubocop/formatter/formatter_set.rb +6 -1
  270. data/lib/rubocop/formatter/github_actions_formatter.rb +6 -5
  271. data/lib/rubocop/formatter/html_formatter.rb +2 -2
  272. data/lib/rubocop/formatter/json_formatter.rb +71 -1
  273. data/lib/rubocop/formatter/junit_formatter.rb +1 -1
  274. data/lib/rubocop/formatter/offense_count_formatter.rb +3 -1
  275. data/lib/rubocop/formatter/pacman_formatter.rb +3 -1
  276. data/lib/rubocop/formatter/sarif_formatter.rb +186 -0
  277. data/lib/rubocop/formatter/worst_offenders_formatter.rb +3 -1
  278. data/lib/rubocop/formatter.rb +1 -0
  279. data/lib/rubocop/lsp/runtime.rb +47 -11
  280. data/lib/rubocop/lsp/stdin_runner.rb +11 -5
  281. data/lib/rubocop/lsp.rb +5 -2
  282. data/lib/rubocop/magic_comment.rb +27 -0
  283. data/lib/rubocop/mcp/autocorrection_request.rb +52 -0
  284. data/lib/rubocop/mcp/explain_tool.rb +68 -0
  285. data/lib/rubocop/mcp/scope.rb +65 -0
  286. data/lib/rubocop/mcp/server.rb +184 -76
  287. data/lib/rubocop/mcp/source_files.rb +35 -0
  288. data/lib/rubocop/offense_limit.rb +30 -0
  289. data/lib/rubocop/options.rb +97 -4
  290. data/lib/rubocop/path_util.rb +1 -1
  291. data/lib/rubocop/plugin/configuration_integrator.rb +12 -5
  292. data/lib/rubocop/plugin/loader.rb +1 -1
  293. data/lib/rubocop/rake_task.rb +1 -1
  294. data/lib/rubocop/remote_config.rb +8 -5
  295. data/lib/rubocop/result_cache.rb +36 -18
  296. data/lib/rubocop/runner.rb +160 -49
  297. data/lib/rubocop/server/cache.rb +2 -2
  298. data/lib/rubocop/unified_diff.rb +257 -0
  299. data/lib/rubocop/util.rb +69 -0
  300. data/lib/rubocop/version.rb +1 -1
  301. data/lib/rubocop.rb +9 -1
  302. metadata +21 -6
  303. data/lib/rubocop/cop/style/double_cop_disable_directive.rb +0 -46
@@ -164,8 +164,12 @@ module RuboCop
164
164
  cop_config['IndentOneStep']
165
165
  end
166
166
 
167
+ # Under tabs one step is a single tab character, which counts as one column
168
+ # regardless of the configured indentation width.
167
169
  def indentation_width
168
- indent_one_step? ? configured_indentation_width : 0
170
+ return 0 unless indent_one_step?
171
+
172
+ using_tabs? ? 1 : configured_indentation_width
169
173
  end
170
174
 
171
175
  def incorrect_style(when_node, branch_type)
@@ -176,8 +180,10 @@ module RuboCop
176
180
  detect_incorrect_style(when_node)
177
181
 
178
182
  whitespace = whitespace_range(when_node)
183
+ next unless whitespace.source.strip.empty?
179
184
 
180
- corrector.replace(whitespace, replacement(when_node)) if whitespace.source.strip.empty?
185
+ indentation = replacement(when_node)
186
+ corrector.replace(whitespace, indentation) if indentation
181
187
  end
182
188
  end
183
189
 
@@ -193,10 +199,7 @@ module RuboCop
193
199
  end
194
200
 
195
201
  def base_column(case_node, base)
196
- case base
197
- when :case then case_node.location.keyword.column
198
- when :end then case_node.location.end.column
199
- end
202
+ base_location(case_node, base)&.column
200
203
  end
201
204
 
202
205
  def whitespace_range(node)
@@ -207,13 +210,26 @@ module RuboCop
207
210
  end
208
211
 
209
212
  def replacement(node)
213
+ base_loc = configured_base_location(node)
214
+
215
+ return ' ' * (base_loc.column + indentation_width) unless using_tabs?
216
+ return unless begins_its_line?(base_loc)
217
+
218
+ base_loc.source_line[/\A\s*/] + ("\t" * indentation_width)
219
+ end
220
+
221
+ def configured_base_location(node)
210
222
  case_node = node.each_ancestor(:case, :case_match).first
211
223
  base_type = cop_config[style_parameter_name] == 'end' ? :end : :case
212
224
 
213
- column = base_column(case_node, base_type)
214
- column += indentation_width
225
+ base_location(case_node, base_type)
226
+ end
215
227
 
216
- ' ' * column
228
+ def base_location(case_node, base)
229
+ case base
230
+ when :case then case_node.location.keyword
231
+ when :end then case_node.location.end
232
+ end
217
233
  end
218
234
  end
219
235
  end
@@ -188,6 +188,14 @@ module RuboCop
188
188
 
189
189
  MSG = '`%<category>s` is supposed to appear before `%<previous>s`.'
190
190
 
191
+ # A moved element is inserted before the line break that precedes its anchor.
192
+ # When the anchor follows a blank line, `Layout/EmptyLines`,
193
+ # `Layout/EmptyLinesAroundAccessModifier` or `Layout/EmptyLinesAroundClassBody`
194
+ # may remove that line break in the same pass.
195
+ def self.autocorrect_incompatible_with
196
+ [Layout::EmptyLines, Layout::EmptyLinesAroundAccessModifier, Layout::EmptyLinesAroundClassBody]
197
+ end
198
+
191
199
  # Validates code style on class declaration.
192
200
  # Add offense when find a node out of expected order.
193
201
  # A node is out of order when its category is expected earlier than
@@ -423,7 +431,7 @@ module RuboCop
423
431
  def end_position_for(node)
424
432
  if node.casgn_type?
425
433
  heredoc = find_heredoc(node)
426
- return heredoc.location.heredoc_end.end_pos + 1 if heredoc
434
+ return heredoc.location.heredoc_end.end_pos if heredoc
427
435
  end
428
436
 
429
437
  end_line = buffer.line_for_position(node.source_range.end_pos)
@@ -64,10 +64,10 @@ module RuboCop
64
64
  autocorrect_one(corrector, comment)
65
65
  end
66
66
 
67
- # Corrects all comment lines that occur immediately before the given
68
- # comment and have the same indentation. This is to avoid a long chain
69
- # of correcting, saving the file, parsing and inspecting again, and
70
- # then correcting one more line, and so on.
67
+ # Corrects all preceding comment lines that have the same indentation
68
+ # and are separated from the given comment by nothing but blank lines.
69
+ # This is to avoid a long chain of correcting, saving the file, parsing
70
+ # and inspecting again, and then correcting one more line, and so on.
71
71
  def autocorrect_preceding_comments(corrector, comment)
72
72
  comments = processed_source.comments
73
73
  index = comments.index(comment)
@@ -82,7 +82,10 @@ module RuboCop
82
82
  def should_correct?(preceding_comment, reference_comment)
83
83
  loc = preceding_comment.loc
84
84
  ref_loc = reference_comment.loc
85
- loc.line == ref_loc.line - 1 && loc.column == ref_loc.column
85
+ return false unless loc.column == ref_loc.column
86
+ return false unless own_line_comment?(preceding_comment)
87
+
88
+ ((loc.line + 1)...ref_loc.line).all? { |line| processed_source[line - 1].blank? }
86
89
  end
87
90
 
88
91
  def autocorrect_one(corrector, comment)
@@ -49,6 +49,10 @@ module RuboCop
49
49
  return unless node.def_modifier?
50
50
 
51
51
  method_def = node.each_descendant(:any_def).first
52
+ # A single-line `def` has nothing to align, even when a line
53
+ # continuation puts it on a later line than the modifier.
54
+ return if method_def.single_line?
55
+
52
56
  expr = node.source_range
53
57
 
54
58
  line_start = range_between(expr.begin_pos, method_def.loc.keyword.end_pos)
@@ -93,6 +93,7 @@ module RuboCop
93
93
  when :def, :defs then base_for_method_definition(parent)
94
94
  when :kwbegin then parent.loc.begin
95
95
  when :block, :numblock, :itblock then start_line_range(parent)
96
+ when :class, :module, :sclass then parent.loc.keyword
96
97
  else node.loc.keyword
97
98
  end
98
99
  end
@@ -63,12 +63,14 @@ module RuboCop
63
63
  if node.modifier_form?
64
64
  check_condition(node.condition) if node.right_sibling
65
65
  else
66
- check_condition(node.condition)
66
+ check_condition(node.condition, node.if_branch)
67
67
  end
68
68
  end
69
69
 
70
70
  def on_while(node)
71
- check_condition(node.condition)
71
+ return if node.modifier_form? && !node.right_sibling
72
+
73
+ check_condition(node.condition, node.modifier_form? ? nil : node.body)
72
74
  end
73
75
  alias on_until on_while
74
76
 
@@ -84,7 +86,8 @@ module RuboCop
84
86
  last_condition = when_node.conditions.last
85
87
 
86
88
  next if !multiline_when_condition?(when_node) ||
87
- next_line_empty?(last_condition.last_line)
89
+ next_line_empty?(last_condition.last_line) ||
90
+ body_on_line?(when_node.body, last_condition.last_line)
88
91
 
89
92
  add_offense(when_node, &autocorrect(last_condition))
90
93
  end
@@ -94,7 +97,8 @@ module RuboCop
94
97
  node.resbody_branches.each do |resbody|
95
98
  rescued_exceptions = resbody.exceptions
96
99
  next if !multiline_rescue_exceptions?(rescued_exceptions) ||
97
- next_line_empty?(rescued_exceptions.last.last_line)
100
+ next_line_empty?(rescued_exceptions.last.last_line) ||
101
+ body_on_line?(resbody.body, rescued_exceptions.last.last_line)
98
102
 
99
103
  add_offense(resbody, &autocorrect(rescued_exceptions.last))
100
104
  end
@@ -102,9 +106,10 @@ module RuboCop
102
106
 
103
107
  private
104
108
 
105
- def check_condition(condition)
109
+ def check_condition(condition, body = nil)
106
110
  return unless condition.multiline?
107
111
  return if next_line_empty?(condition.last_line)
112
+ return if body_on_line?(body, condition.last_line)
108
113
 
109
114
  add_offense(condition, &autocorrect(condition))
110
115
  end
@@ -113,6 +118,10 @@ module RuboCop
113
118
  processed_source[line].blank?
114
119
  end
115
120
 
121
+ def body_on_line?(body, line)
122
+ body&.first_line == line
123
+ end
124
+
116
125
  def multiline_when_condition?(when_node)
117
126
  when_node.conditions.first.first_line != when_node.conditions.last.last_line
118
127
  end
@@ -27,8 +27,7 @@ module RuboCop
27
27
 
28
28
  def on_new_investigation
29
29
  return if processed_source.tokens.empty?
30
- # Quick check if we possibly have consecutive blank lines.
31
- return unless processed_source.raw_source.include?("\n\n\n")
30
+ return unless consecutive_blank_lines_possible?
32
31
 
33
32
  lines = Set.new
34
33
  processed_source.tokens.each { |token| lines << token.line }
@@ -42,6 +41,10 @@ module RuboCop
42
41
 
43
42
  private
44
43
 
44
+ def consecutive_blank_lines_possible?
45
+ processed_source.buffer.source.include?("\n\n\n")
46
+ end
47
+
45
48
  def each_extra_empty_line(lines)
46
49
  prev_line = 1
47
50
 
@@ -91,7 +91,7 @@ module RuboCop
91
91
  end
92
92
 
93
93
  def next_line_node(node)
94
- return if node.parent.if_type?
94
+ return if node.parent.type?(:if, :rescue, :ensure)
95
95
 
96
96
  node.right_sibling
97
97
  end
@@ -111,6 +111,7 @@ module RuboCop
111
111
 
112
112
  def require_empty_line?(node)
113
113
  return false unless node.respond_to?(:type)
114
+ return false if node.left_sibling.last_line == node.first_line
114
115
 
115
116
  !allow_alias?(node) && !attribute_or_allowed_method?(node)
116
117
  end
@@ -38,7 +38,7 @@ module RuboCop
38
38
  KIND = 'block'
39
39
 
40
40
  def on_block(node)
41
- first_line = node.send_node.last_line
41
+ first_line = node.loc.begin.line
42
42
 
43
43
  check(node, node.body, adjusted_first_line: first_line)
44
44
  end
@@ -85,8 +85,12 @@ module RuboCop
85
85
  next if line == line_of_def_or_kwbegin || last_body_and_end_on_same_line?(body)
86
86
 
87
87
  keyword = loc.source
88
+
88
89
  # below the keyword
89
- check_line(style, line, message('after', keyword), &:empty?)
90
+ unless left_to_block_body_cop?(body, line)
91
+ check_line(style, line, message('after', keyword), &:empty?)
92
+ end
93
+
90
94
  # above the keyword
91
95
  check_line(style, line - 2, message('before', keyword), &:empty?)
92
96
  end
@@ -122,6 +126,15 @@ module RuboCop
122
126
  end
123
127
  end
124
128
 
129
+ def left_to_block_body_cop?(body, keyword_line)
130
+ return false unless body.parent.any_block_type?
131
+
132
+ cop_config = config.for_enabled_cop('Layout/EmptyLinesAroundBlockBody')
133
+ return false if cop_config['EnforcedStyle'] != 'empty_lines'
134
+
135
+ only_empty_lines_until_end?(body, keyword_line)
136
+ end
137
+
125
138
  def keyword_locations_in_rescue(node)
126
139
  [node.loc.else, *node.resbody_branches.map { |body| body.loc.keyword }].compact
127
140
  end
@@ -133,6 +146,15 @@ module RuboCop
133
146
  *keyword_locations(rescue_body_without_ensure)
134
147
  ]
135
148
  end
149
+
150
+ def only_empty_lines_until_end?(body, keyword_line)
151
+ end_line = body.parent.loc.end.line
152
+ next_line = (keyword_line + 1).upto(end_line).find do |line_number|
153
+ !processed_source.lines[line_number - 1].strip.empty?
154
+ end
155
+
156
+ next_line == end_line
157
+ end
136
158
  end
137
159
  end
138
160
  end
@@ -123,16 +123,8 @@ module RuboCop
123
123
  AlignmentCorrector.align_end(corrector, processed_source, node, alignment_node(node))
124
124
  end
125
125
 
126
- # rubocop:disable-next Metrics/CyclomaticComplexity
127
126
  def check_assignment(node, rhs)
128
- # If there are method calls chained to the right hand side of the
129
- # assignment, we let rhs be the receiver of those method calls before
130
- # we check if it's an if/unless/while/until.
131
- return unless (rhs = first_part_of_call_chain(rhs))
132
-
133
- # If `rhs` is a `begin` node or a logical operator,
134
- # unwrap to find the leading conditional.
135
- rhs = rhs.child_nodes.first while rhs&.type?(:begin, :or, :and)
127
+ rhs = leading_node(rhs)
136
128
 
137
129
  return unless rhs&.conditional?
138
130
  return if rhs.if_type? && rhs.ternary?
@@ -151,6 +143,16 @@ module RuboCop
151
143
  ignore_node(inner_node)
152
144
  end
153
145
 
146
+ def leading_node(rhs)
147
+ # If there are method calls chained to the right hand side of the assignment,
148
+ # we let rhs be the receiver of those method calls.
149
+ rhs = first_part_of_call_chain(rhs)
150
+
151
+ # If `rhs` is a `begin` node or a logical operator, unwrap to find the leading node.
152
+ rhs = rhs.child_nodes.first while rhs&.type?(:begin, :or, :and)
153
+ rhs
154
+ end
155
+
154
156
  def asgn_variable_align_with(outer_node, inner_node)
155
157
  expr = outer_node.source_range
156
158
 
@@ -207,7 +209,11 @@ module RuboCop
207
209
 
208
210
  def assignment_or_operator_method(node)
209
211
  node.ancestors.find do |ancestor|
210
- ancestor.assignment_or_similar? || (ancestor.send_type? && ancestor.operator_method?)
212
+ if ancestor.assignment_or_similar?
213
+ leading_node(extract_rhs(ancestor)).equal?(node)
214
+ elsif ancestor.send_type? && ancestor.operator_method?
215
+ !leading_node(ancestor).equal?(node)
216
+ end
211
217
  end
212
218
  end
213
219
  end
@@ -36,6 +36,10 @@ module RuboCop
36
36
  MSG_UNNECESSARY = 'Unnecessary spacing detected.'
37
37
  MSG_UNALIGNED_ASGN = '`=` is not aligned with the %<location>s assignment.'
38
38
 
39
+ def self.autocorrect_incompatible_with
40
+ [Style::SelfAssignment]
41
+ end
42
+
39
43
  def on_new_investigation
40
44
  return if processed_source.blank?
41
45
 
@@ -189,6 +189,7 @@ module RuboCop
189
189
  return false unless style == :special_for_inner_method_call_in_parentheses
190
190
  return false unless inner_call?(top_level_send)
191
191
  return false unless display_column(send_node.source_range) < column_delta.abs
192
+ return false if column_delta.positive?
192
193
 
193
194
  top_level_send != send_node || begins_its_line?(top_level_send.loc.end)
194
195
  end
@@ -89,15 +89,16 @@ module RuboCop
89
89
  'in an array, relative to %<base_description>s.'
90
90
 
91
91
  def on_array(node)
92
- return if style != :consistent && enforce_first_argument_with_fixed_indentation?
92
+ return unless node.loc.begin
93
+ return if autocorrect_incompatible_with_other_cops?(node, nil)
93
94
 
94
- check(node, nil) if node.loc.begin
95
+ check(node, nil)
95
96
  end
96
97
 
97
98
  def on_send(node)
98
- return if style != :consistent && enforce_first_argument_with_fixed_indentation?
99
-
100
99
  each_argument_node(node, :array) do |array_node, left_parenthesis|
100
+ next if autocorrect_incompatible_with_other_cops?(array_node, left_parenthesis)
101
+
101
102
  check(array_node, left_parenthesis)
102
103
  end
103
104
  end
@@ -105,6 +106,18 @@ module RuboCop
105
106
 
106
107
  private
107
108
 
109
+ def autocorrect_incompatible_with_other_cops?(array_node, left_parenthesis)
110
+ return false unless enforce_first_argument_with_fixed_indentation?
111
+ return true if style != :consistent
112
+
113
+ # `Layout/ArrayAlignment` does not align single-element arrays.
114
+ return false if array_node.children.size < 2
115
+
116
+ _base_column, indent_base_type =
117
+ indent_base(array_node.loc.begin, array_node.values.first, left_parenthesis)
118
+ indent_base_type != :start_of_line
119
+ end
120
+
108
121
  def autocorrect(corrector, node)
109
122
  AlignmentCorrector.correct(corrector, processed_source, node, @column_delta)
110
123
  end
@@ -187,9 +187,11 @@ module RuboCop
187
187
  end
188
188
 
189
189
  def check_based_on_longest_key(hash_node, left_brace, left_parenthesis)
190
- key_lengths = hash_node.keys.map { |key| key.source_range.length }
191
- check_first(hash_node.pairs.first, left_brace, left_parenthesis,
192
- key_lengths.max - key_lengths.first)
190
+ first_key = hash_node.keys.first
191
+ key_lengths = hash_node.keys.select(&:single_line?).map { |key| key.source_range.length }
192
+ offset = first_key.single_line? ? key_lengths.max - first_key.source_range.length : 0
193
+
194
+ check_first(hash_node.pairs.first, left_brace, left_parenthesis, offset)
193
195
  end
194
196
 
195
197
  # Returns the description of what the correct indentation is based on.
@@ -75,6 +75,12 @@ module RuboCop
75
75
 
76
76
  MSG = 'Add a line break before the first argument of a multi-line method argument list.'
77
77
 
78
+ # A line break inserted after `(` while `Style/MethodCallWithArgsParentheses` removes
79
+ # the parentheses in the same pass leaves the method name alone on its line.
80
+ def self.autocorrect_incompatible_with
81
+ [Style::MethodCallWithArgsParentheses]
82
+ end
83
+
78
84
  def on_send(node)
79
85
  return if allowed_method?(node.method_name)
80
86
 
@@ -59,6 +59,10 @@ module RuboCop
59
59
 
60
60
  MSG = 'Add a line break before the first parameter of a multi-line method parameter list.'
61
61
 
62
+ def self.autocorrect_incompatible_with
63
+ [Style::MethodDefParentheses]
64
+ end
65
+
62
66
  def on_def(node)
63
67
  check_method_line_break(node, node.arguments, ignore_last: ignore_last_element?)
64
68
  end
@@ -53,6 +53,7 @@ module RuboCop
53
53
  def on_def(node)
54
54
  return if node.arguments.empty?
55
55
  return if node.arguments.loc.begin.nil?
56
+ return if autocorrect_incompatible_with_other_cops?(node)
56
57
 
57
58
  check(node)
58
59
  end
@@ -60,6 +61,11 @@ module RuboCop
60
61
 
61
62
  private
62
63
 
64
+ def autocorrect_incompatible_with_other_cops?(node)
65
+ node.arguments.size >= 2 &&
66
+ style == :align_parentheses && enforce_parameter_with_fixed_indentation?
67
+ end
68
+
63
69
  def autocorrect(corrector, node)
64
70
  AlignmentCorrector.correct(corrector, processed_source, node, @column_delta)
65
71
  end
@@ -95,6 +101,11 @@ module RuboCop
95
101
  base_description: base_description
96
102
  )
97
103
  end
104
+
105
+ def enforce_parameter_with_fixed_indentation?
106
+ parameter_alignment_config = config.for_enabled_cop('Layout/ParameterAlignment')
107
+ parameter_alignment_config['EnforcedStyle'] == 'with_fixed_indentation'
108
+ end
98
109
  end
99
110
  end
100
111
  end
@@ -215,7 +215,7 @@ module RuboCop
215
215
  check_pairs(node)
216
216
  end
217
217
 
218
- attr_accessor :offenses_by, :column_deltas
218
+ attr_accessor :offenses_by, :column_deltas, :unalignable_styles
219
219
 
220
220
  private
221
221
 
@@ -240,6 +240,7 @@ module RuboCop
240
240
  def reset!
241
241
  self.offenses_by = {}
242
242
  self.column_deltas = Hash.new { |hash, key| hash[key] = {} }
243
+ self.unalignable_styles = []
243
244
  end
244
245
 
245
246
  def check_pairs(node)
@@ -265,7 +266,9 @@ module RuboCop
265
266
  kwsplat_offenses = offenses_by.delete(KeywordSplatAlignment)
266
267
  register_offenses_with_format(kwsplat_offenses, KeywordSplatAlignment)
267
268
 
268
- format, offenses = offenses_by.min_by { |_, v| v.length }
269
+ candidates = offenses_by.reject { |style, _| unalignable_styles.include?(style) }
270
+ candidates = offenses_by if candidates.empty?
271
+ format, offenses = candidates.min_by { |_, v| v.length }
269
272
  register_offenses_with_format(offenses, format)
270
273
  end
271
274
 
@@ -283,10 +286,19 @@ module RuboCop
283
286
  offenses_by[alignment.class] ||= []
284
287
  return if good_alignment? delta
285
288
 
289
+ if key_out_of_line?(delta, node)
290
+ unalignable_styles << alignment.class
291
+ return
292
+ end
293
+
286
294
  column_deltas[alignment.class][node] = delta
287
295
  offenses_by[alignment.class].push(node)
288
296
  end
289
297
 
298
+ def key_out_of_line?(delta, node)
299
+ (delta[:key] || 0) < -node.source_range.column
300
+ end
301
+
290
302
  def ignore_hash_argument?(node)
291
303
  case cop_config['EnforcedLastArgumentHashStyle']
292
304
  when 'always_inspect' then false
@@ -325,14 +337,10 @@ module RuboCop
325
337
  node.loc.operator)
326
338
  else
327
339
  delta_value = delta[:key] || 0
328
- correct_no_value(corrector, delta_value, node.source_range)
340
+ adjust(corrector, delta_value, node.source_range)
329
341
  end
330
342
  end
331
343
 
332
- def correct_no_value(corrector, key_delta, key)
333
- adjust(corrector, key_delta, key)
334
- end
335
-
336
344
  def correct_key_value(corrector, delta, key, value, separator)
337
345
  # We can't use the instance variable inside the lambda. That would
338
346
  # just give each lambda the same reference and they would all get the
@@ -341,9 +349,6 @@ module RuboCop
341
349
  value_delta = delta[:value] || 0
342
350
  key_delta = delta[:key] || 0
343
351
 
344
- key_column = key.column
345
- key_delta = -key_column if key_delta < -key_column
346
-
347
352
  adjust(corrector, key_delta, key)
348
353
  adjust(corrector, separator_delta, separator)
349
354
  adjust(corrector, value_delta, value)
@@ -117,6 +117,8 @@ module RuboCop
117
117
  previous = heredoc
118
118
  current = previous.parent
119
119
  until send_missing_closing_parens?(current, previous, heredoc)
120
+ return if current&.any_block_type? && !current.send_node.equal?(previous)
121
+
120
122
  previous = current
121
123
  current = current.parent
122
124
  return unless previous && current
@@ -55,6 +55,10 @@ module RuboCop
55
55
  (send _ {:squish :squish!})
56
56
  PATTERN
57
57
 
58
+ def on_new_investigation
59
+ @offending_heredoc_bodies = nil
60
+ end
61
+
58
62
  def on_heredoc(node)
59
63
  body = heredoc_body(node)
60
64
  return if body.strip.empty?
@@ -77,6 +81,9 @@ module RuboCop
77
81
  private
78
82
 
79
83
  def register_offense(node, heredoc_indent_type)
84
+ return if within_offending_heredoc?(node)
85
+
86
+ offending_heredoc_bodies << node.loc.heredoc_body
80
87
  message = message(heredoc_indent_type)
81
88
 
82
89
  add_offense(node.loc.heredoc_body, message: message) do |corrector|
@@ -90,6 +97,14 @@ module RuboCop
90
97
  end
91
98
  end
92
99
 
100
+ def within_offending_heredoc?(node)
101
+ offending_heredoc_bodies.any? { |body| body.contains?(node.source_range) }
102
+ end
103
+
104
+ def offending_heredoc_bodies
105
+ @offending_heredoc_bodies ||= []
106
+ end
107
+
93
108
  def message(heredoc_indent_type)
94
109
  current_indent_type = "<<#{heredoc_indent_type}"
95
110
 
@@ -6,6 +6,9 @@ module RuboCop
6
6
  # Checks that the indentation method is consistent.
7
7
  # Either tabs only or spaces only are used for indentation.
8
8
  #
9
+ # With `EnforcedStyle: tabs`, spaces that follow the indenting tabs are
10
+ # taken to be alignment rather than indentation, and are left alone.
11
+ #
9
12
  # @example EnforcedStyle: spaces (default)
10
13
  # # bad
11
14
  # # This example uses a tab to indent bar.
@@ -67,7 +70,7 @@ module RuboCop
67
70
  match = if style == :spaces
68
71
  line.match(/\A\s*\t+/)
69
72
  else
70
- line.match(/\A\s* +/)
73
+ line.match(/\A +/)
71
74
  end
72
75
  return unless match
73
76
 
@@ -82,7 +82,7 @@ module RuboCop
82
82
 
83
83
  # @!method access_modifier?(node)
84
84
  def_node_matcher :access_modifier?, <<~PATTERN
85
- [(send ...) access_modifier?]
85
+ [(send ...) bare_access_modifier?]
86
86
  PATTERN
87
87
 
88
88
  def on_rescue(node)
@@ -250,7 +250,7 @@ module RuboCop
250
250
 
251
251
  def check_members_for_normal_style(base, members)
252
252
  members.first.children.each do |member|
253
- next if member.send_type? && member.access_modifier?
253
+ next if member.send_type? && member.bare_access_modifier?
254
254
 
255
255
  check_indentation(base, member)
256
256
  end
@@ -400,7 +400,7 @@ module RuboCop
400
400
  if body_node.rescue_type?
401
401
  check_rescue?(body_node)
402
402
  elsif body_node.ensure_type?
403
- block_body, = *body_node # rubocop:disable InternalAffairs/NodeDestructuring
403
+ block_body, = *body_node # rubocop:disable InternalAffairs/NodeDestructuring -- `EnsureNode` has no accessor for the protected body
404
404
  if block_body&.rescue_type?
405
405
  check_rescue?(block_body)
406
406
  else
@@ -440,7 +440,7 @@ module RuboCop
440
440
  begin_pos - indentation
441
441
  end
442
442
 
443
- pos = indentation >= 0 ? ind..begin_pos : begin_pos..ind
443
+ pos = ind <= begin_pos ? ind..begin_pos : begin_pos..ind
444
444
  range_between(pos.begin, pos.end)
445
445
  end
446
446