Sha256: 642e15992b4feed33b9f15b1dda51cfb419e1d21a5a4ea7656ad67ccb9d8c914

Contents?: true

Size: 897 Bytes

Versions: 4

Compression:

Stored size: 897 Bytes

Contents

require_relative './file_reviewer.rb'

module Checkstyle
  class Reviewer

    attr_reader :repository, :report_file_path, :syntax_violation_report

    def initialize(repository, report_file_path)
      @report_file_path = report_file_path
      @syntax_violation_report = JSON.parse(File.open(report_file_path).read).fetch('files', [])
      @repository = repository
    end

    def review
      log "Reviewing based on #{report_file_path}"

      syntax_violation_report.each do |file_report|
        next if file_report.fetch('offenses', []).empty?

        review_file(file_report)
      end
    end

    private

    def review_file(file_report)
      path = file_report.fetch('path', "")
      violations = file_report.fetch('offenses', [])

      FileReviewer.new(repository, path, violations).review
    end

    def log(text)
      puts "[CHECKSTYLE][Review] #{text}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
copperizer-3.3.0 lib/checkstyle/reviewer.rb
copperizer-3.2.2 lib/checkstyle/reviewer.rb
copperizer-3.2.1 lib/checkstyle/reviewer.rb
copperizer-3.1.0 lib/checkstyle/reviewer.rb