Sha256: fcf9454678c83cc93fd4ae62cae0246efe5e81de20384964ba4809be3d98d2d0

Contents?: true

Size: 818 Bytes

Versions: 2

Compression:

Stored size: 818 Bytes

Contents

module SlimLint
  # Outputs lints in a simple format with the filename, line number, and lint
  # message.
  class Reporter::DefaultReporter < Reporter
    def report_lints
      sorted_lints = 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
    end

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

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

      log.log lint.message
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slim_lint-0.2.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.1.0 lib/slim_lint/reporter/default_reporter.rb