Class: Checkstyle::Reviewer

Inherits:
Object
  • Object
show all
Defined in:
lib/checkstyle/reviewer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, report_file_path) ⇒ Reviewer

Returns a new instance of Reviewer.



8
9
10
11
12
# File 'lib/checkstyle/reviewer.rb', line 8

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

Instance Attribute Details

#report_file_pathObject (readonly)

Returns the value of attribute report_file_path.



6
7
8
# File 'lib/checkstyle/reviewer.rb', line 6

def report_file_path
  @report_file_path
end

#repositoryObject (readonly)

Returns the value of attribute repository.



6
7
8
# File 'lib/checkstyle/reviewer.rb', line 6

def repository
  @repository
end

#syntax_violation_reportObject (readonly)

Returns the value of attribute syntax_violation_report.



6
7
8
# File 'lib/checkstyle/reviewer.rb', line 6

def syntax_violation_report
  @syntax_violation_report
end

Instance Method Details

#reviewObject



14
15
16
17
18
19
20
21
22
# File 'lib/checkstyle/reviewer.rb', line 14

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