Class: PmdTester::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/pmdtester/report_diff.rb

Overview

A full report, created by the report XML parser, can be diffed with another report into a ReportDiff

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(report_document: nil, file: '', exec_time: 0, timestamp: '0', exit_code: '?') ⇒ Report

Returns a new instance of Report.



65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/pmdtester/report_diff.rb', line 65

def initialize(report_document: nil,
               file: '',
               exec_time: 0,
               timestamp: '0',
               exit_code: '?')
  initialize_empty
  initialize_with_report_document report_document unless report_document.nil?
  @exec_time = exec_time
  @timestamp = timestamp
  @file = file
  @exit_code = exit_code
end

Instance Attribute Details

#configerrors_by_ruleObject (readonly)

Returns the value of attribute configerrors_by_rule.



55
56
57
# File 'lib/pmdtester/report_diff.rb', line 55

def configerrors_by_rule
  @configerrors_by_rule
end

#errors_by_fileObject (readonly)

Returns the value of attribute errors_by_file.



55
56
57
# File 'lib/pmdtester/report_diff.rb', line 55

def errors_by_file
  @errors_by_file
end

#exec_timeObject (readonly)

Returns the value of attribute exec_time.



55
56
57
# File 'lib/pmdtester/report_diff.rb', line 55

def exec_time
  @exec_time
end

#exit_codeObject (readonly)

Returns the value of attribute exit_code.



55
56
57
# File 'lib/pmdtester/report_diff.rb', line 55

def exit_code
  @exit_code
end

#fileObject (readonly)

Returns the value of attribute file.



55
56
57
# File 'lib/pmdtester/report_diff.rb', line 55

def file
  @file
end

#report_folderObject

Returns the value of attribute report_folder.



63
64
65
# File 'lib/pmdtester/report_diff.rb', line 63

def report_folder
  @report_folder
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



55
56
57
# File 'lib/pmdtester/report_diff.rb', line 55

def timestamp
  @timestamp
end

#violations_by_fileObject (readonly)

Returns the value of attribute violations_by_file.



55
56
57
# File 'lib/pmdtester/report_diff.rb', line 55

def violations_by_file
  @violations_by_file
end

Class Method Details

.emptyObject



78
79
80
# File 'lib/pmdtester/report_diff.rb', line 78

def self.empty
  new
end

Instance Method Details

#rule_summariesObject



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/pmdtester/report_diff.rb', line 82

def rule_summaries
  summary = {}
  @violations_by_file.each_value do |violation|
    unless summary.key?(violation.rule_name)
      summary[violation.rule_name] = {
        'name' => violation.rule_name,
        'info_url' => violation.info_url,
        'count' => 0
      }
    end
    summary[violation.rule_name]['count'] += 1
  end

  summary.values
end