Sha256: c7729470f88404a2767b85b6b66f893548ca070f80e4d435a7fd452162485e72

Contents?: true

Size: 884 Bytes

Versions: 5

Compression:

Stored size: 884 Bytes

Contents

# frozen_string_literal: true

module SlimLint
  # Outputs lints in a simple format with the filename, line number, and lint
  # message.
  class Reporter::DefaultReporter < Reporter
    def display_report(report)
      sorted_lints = report.lints.sort_by { |l| [l.filename, l.line] }

      sorted_lints.each do |lint|
        print_location(lint)
        print_type(lint)
        print_message(lint)
      end
    end

    private

    def print_location(lint)
      log.info lint.filename, false
      log.log ":", false
      log.bold lint.line, false
      log.log ":", false
      log.bold lint.column, false
    end

    def print_type(lint)
      if lint.error?
        log.error " [E] ", false
      else
        log.warning " [W] ", false
      end
    end

    def print_message(lint)
      log.success("#{lint.name}: ", false)
      log.log lint.message
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
slim_lint_standard-0.0.2.2 lib/slim_lint/reporter/default_reporter.rb
slim_lint_standard-0.0.2.1 lib/slim_lint/reporter/default_reporter.rb
slim_lint_standard-0.0.2 lib/slim_lint/reporter/default_reporter.rb
slim_lint_standard-0.0.1 lib/slim_lint/reporter/default_reporter.rb
slim_lint_standard-0.0.0 lib/slim_lint/reporter/default_reporter.rb