Sha256: 545072e473a031b73fc1ba22f9f9bf4969f74c7c9e949dbe618a593e952d2420

Contents?: true

Size: 962 Bytes

Versions: 9

Compression:

Stored size: 962 Bytes

Contents

module Goodcheck
  module Reporters
    class Text
      attr_reader :stdout

      def initialize(stdout:)
        @stdout = stdout
      end

      def analysis
        yield
      end

      def file(path)
        yield
      end

      def rule(rule)
        yield
      end

      def issue(issue)
        line = issue.buffer.line(issue.location.start_line).chomp
        end_column = if issue.location.start_line == issue.location.end_line
                       issue.location.end_column
                     else
                       line.bytesize
                     end
        colored_line = line.byteslice(0, issue.location.start_column) + Rainbow(line.byteslice(issue.location.start_column, end_column - issue.location.start_column)).red + line.byteslice(end_column, line.bytesize - end_column)
        stdout.puts "#{issue.path}:#{issue.location.start_line}:#{colored_line}:\t#{issue.rule.message.lines.first.chomp}"
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
goodcheck-1.4.1 lib/goodcheck/reporters/text.rb
goodcheck-1.4.0 lib/goodcheck/reporters/text.rb
goodcheck-1.3.1 lib/goodcheck/reporters/text.rb
goodcheck-1.2.0 lib/goodcheck/reporters/text.rb
goodcheck-1.1.0 lib/goodcheck/reporters/text.rb
goodcheck-1.0.0 lib/goodcheck/reporters/text.rb
goodcheck-0.3.0 lib/goodcheck/reporters/text.rb
goodcheck-0.2.0 lib/goodcheck/reporters/text.rb
goodcheck-0.1.0 lib/goodcheck/reporters/text.rb