lib/rubocop/cop/layout/empty_comment.rb in rubocop-1.12.1 vs lib/rubocop/cop/layout/empty_comment.rb in rubocop-1.13.0
- old
+ new
@@ -73,13 +73,11 @@
investigate(comments)
else
processed_source.comments.each do |comment|
next unless empty_comment_only?(comment_text(comment))
- add_offense(comment) do |corrector|
- autocorrect(corrector, comment)
- end
+ add_offense(comment) { |corrector| autocorrect(corrector, comment) }
end
end
end
private
@@ -97,23 +95,20 @@
end
def autocorrect(corrector, node)
previous_token = previous_token(node)
range = if previous_token && node.loc.line == previous_token.line
- range_with_surrounding_space(range: node.loc.expression,
- newlines: false)
+ range_with_surrounding_space(range: node.loc.expression, newlines: false)
else
- range_by_whole_lines(node.loc.expression,
- include_final_newline: true)
+ range_by_whole_lines(node.loc.expression, include_final_newline: true)
end
corrector.remove(range)
end
def concat_consecutive_comments(comments)
- consecutive_comments =
- comments.chunk_while { |i, j| i.loc.line.succ == j.loc.line }
+ consecutive_comments = comments.chunk_while { |i, j| i.loc.line.succ == j.loc.line }
consecutive_comments.map do |chunk|
joined_text = chunk.map { |c| comment_text(c) }.join
[joined_text, chunk]
end
@@ -140,12 +135,10 @@
def allow_margin_comment?
cop_config['AllowMarginComment']
end
def current_token(comment)
- processed_source.find_token do |token|
- token.pos == comment.loc.expression
- end
+ processed_source.find_token { |token| token.pos == comment.loc.expression }
end
def previous_token(node)
current_token = current_token(node)
index = processed_source.tokens.index(current_token)