class ERBLint::Reporters::CompactReporter

Public Instance Methods

preview() click to toggle source
# File lib/erb_lint/reporters/compact_reporter.rb, line 6
def preview
  puts "Linting #{stats.files} files with "\
    "#{stats.linters} #{"autocorrectable " if autocorrect}linters..."
end
show() click to toggle source
# File lib/erb_lint/reporters/compact_reporter.rb, line 11
def show
  processed_files.each do |filename, offenses|
    offenses.each do |offense|
      puts format_offense(filename, offense)
    end
  end

  footer
  summary
end

Private Instance Methods

format_offense(filename, offense) click to toggle source
# File lib/erb_lint/reporters/compact_reporter.rb, line 24
def format_offense(filename, offense)
  [
    "#{filename}:",
    "#{offense.line_number}:",
    "#{offense.column}: ",
    offense.message.to_s,
  ].join
end
report_corrected_offenses() click to toggle source
# File lib/erb_lint/reporters/compact_reporter.rb, line 51
def report_corrected_offenses
  corrected_found_diff = stats.found - stats.corrected

  if corrected_found_diff > 0
    message = Rainbow(
      "#{stats.corrected} error(s) corrected and #{corrected_found_diff} error(s) remaining in ERB files"
    ).red

    warn(message)
  else
    puts Rainbow("#{stats.corrected} error(s) corrected in ERB files").green
  end
end
summary() click to toggle source
# File lib/erb_lint/reporters/compact_reporter.rb, line 35
def summary
  if stats.corrected > 0
    report_corrected_offenses
  elsif stats.ignored > 0 || stats.found > 0
    if stats.ignored > 0
      warn(Rainbow("#{stats.ignored} error(s) were ignored in ERB files").yellow)
    end

    if stats.found > 0
      warn(Rainbow("#{stats.found} error(s) were found in ERB files").red)
    end
  else
    puts Rainbow("No errors were found in ERB files").green
  end
end