Sha256: 4f74f830600870e1937877d3c712f0965d8c9898341fec7fc2007a88a93413ef

Contents?: true

Size: 640 Bytes

Versions: 2

Compression:

Stored size: 640 Bytes

Contents

require 'json'
require 'comment'

module Inputs
  class CoffeeLintRaw
    attr_accessor :filename

    def initialize(filename = 'coffeelint_report.json')
      self.filename = filename

      fail "#{filename} does not exist" unless File.exist?(filename)
    end

    def comments
      report.map do |file, problems|
        problems.map do |problem|
          Comment.new(
            file: file,
            line: problem['lineNumber'],
            text: "(#{problem['level']}) #{problem['message']}"
          )
        end
      end.flatten
    end

    private

    def report
      JSON.parse(File.read(filename))
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stash_pull_request_commenter-0.2.1 lib/stash_pull_request_commenter/inputs/coffeelint_raw.rb
stash_pull_request_commenter-0.2.0 lib/stash_pull_request_commenter/inputs/coffeelint_raw.rb