Sha256: 3a8e7fbc0a5fd9156d75a3df1bf2740d607ef4b6e28ccf97dd61fb3ffe6c27bf

Contents?: true

Size: 835 Bytes

Versions: 20

Compression:

Stored size: 835 Bytes

Contents

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
    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

20 entries across 20 versions & 1 rubygems

Version Path
slim_lint-0.15.1 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.15.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.14.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.13.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.12.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.11.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.10.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.9.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.8.3 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.8.2 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.8.1 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.8.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.7.2 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.7.1 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.7.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.6.1 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.6.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.5.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.4.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.3.0 lib/slim_lint/reporter/default_reporter.rb