Sha256: 30959580870d57f9eadeb98cb1878567d3aaf28ccb5f7d5a08fcfc39563af95f

Contents?: true

Size: 866 Bytes

Versions: 23

Compression:

Stored size: 866 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
    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

23 entries across 23 versions & 1 rubygems

Version Path
slim_lint-0.31.1 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.31.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.30.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.29.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.28.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.27.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.26.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.25.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.24.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.23.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.22.1 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.22.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.21.1 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.21.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.20.2 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.20.1 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.20.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.19.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.18.0 lib/slim_lint/reporter/default_reporter.rb
slim_lint-0.17.1 lib/slim_lint/reporter/default_reporter.rb