lib/rubocop/cop/layout/class_structure.rb in rubocop-1.44.1 vs lib/rubocop/cop/layout/class_structure.rb in rubocop-1.45.0

- old
+ new

@@ -132,10 +132,11 @@ # end # end # class ClassStructure < Base include VisibilityHelp + include CommentsHelp extend AutoCorrector HUMANIZED_NODE_TYPE = { casgn: :constants, defs: :public_class_methods, @@ -161,11 +162,11 @@ private # Autocorrect by swapping between two nodes autocorrecting them def autocorrect(corrector, node) - previous = node.left_siblings.find do |sibling| + previous = node.left_siblings.reverse.find do |sibling| !ignore_for_autocorrect?(node, sibling) end return unless previous current_range = source_range_with_comment(node) @@ -279,24 +280,9 @@ def marked_as_private_constant?(node, name) return false unless node.method?(:private_constant) node.arguments.any? { |arg| (arg.sym_type? || arg.str_type?) && arg.value == name } - end - - def source_range_with_comment(node) - begin_pos, end_pos = - if (node.def_type? && !node.method?(:initialize)) || - (node.send_type? && node.def_modifier?) - start_node = find_visibility_start(node) || node - end_node = find_visibility_end(node) || node - [begin_pos_with_comment(start_node), - end_position_for(end_node) + 1] - else - [begin_pos_with_comment(node), end_position_for(node)] - end - - Parser::Source::Range.new(buffer, begin_pos, end_pos) end def end_position_for(node) heredoc = find_heredoc(node) return heredoc.location.heredoc_end.end_pos + 1 if heredoc