Sha256: 61fe48a3928e6a3b1b47cade494c85b229b083a41fc4f5f948ffe1cde5cdb0ed

Contents?: true

Size: 706 Bytes

Versions: 1

Compression:

Stored size: 706 Bytes

Contents

require 'json'
require 'face_control/comment'

module FaceControl
  module Inputs
    class RubocopJson
      attr_accessor :filename

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

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

      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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
face_control-0.2.1 lib/face_control/inputs/rubocop_json.rb