class RuboCop::Cop::Lint::EmptyFile


# File consisting only of comments
# bad
@example AllowComments: false
# File consisting only of comments
# good
@example AllowComments: true (default)
# File containing non commented source lines
# good
# Empty file
# bad
@example
This cop enforces that Ruby source files are not empty.

def contains_only_comments?

def contains_only_comments?
  processed_source.lines.all? do |line|
    line.blank? || comment_line?(line)
  end
end

def empty_file?

def empty_file?
  processed_source.buffer.source.empty?
end

def offending?

def offending?
  empty_file? || (!cop_config['AllowComments'] && contains_only_comments?)
end

def on_new_investigation

def on_new_investigation
  add_global_offense(MSG) if offending?
end