class Inputs::RubocopJson

Attributes

filename[RW]

Public Class Methods

new(filename = 'rubocop.json') click to toggle source
# File lib/stash_pull_request_commenter/inputs/rubocop_json.rb, line 8
def initialize(filename = 'rubocop.json')
  self.filename = filename

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

Public Instance Methods

comments() click to toggle source
# File lib/stash_pull_request_commenter/inputs/rubocop_json.rb, line 14
def comments
  report['files'].map do |file|
    file['offenses'].map do |offense|
      Comment.new(
        file: file['path'],
        line: offense['location']['line'],
        text: offense['message']
      )
    end
  end.flatten
end

Private Instance Methods

report() click to toggle source
# File lib/stash_pull_request_commenter/inputs/rubocop_json.rb, line 28
def report
  JSON.parse(File.read(filename))
end