Skip to content

Commit

Permalink
Avoid comments_before_line
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre authored and bbatsov committed Aug 10, 2020
1 parent 8a02e42 commit 14a5c20
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions lib/rubocop/cop/layout/class_structure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,11 @@ def end_position_for(node)
end

def begin_pos_with_comment(node)
annotation_line = node.first_line - 1
first_comment = nil
(node.first_line - 1).downto(1) do |annotation_line|
break unless (comment = processed_source.comment_at_line(annotation_line))

processed_source.comments_before_line(annotation_line)
.reverse_each do |comment|
if comment.location.line == annotation_line
first_comment = comment
annotation_line -= 1
end
first_comment = comment
end

start_line_position(first_comment || node)
Expand Down

0 comments on commit 14a5c20

Please sign in to comment.