Class: PmdTester::ReportDiff

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

Overview

This class represents all the diff report information, including the summary information of the original pmd reports, as well as the specific information of the diff report.

Constant Summary

Constants included from PmdTester

BASE, PATCH, PR_NUM_ENV_VAR, VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PmdTester

#logger, logger

Constructor Details

#initialize(base_report:, patch_report:) ⇒ ReportDiff

Returns a new instance of ReportDiff.



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/pmdtester/report_diff.rb', line 130

def initialize(base_report:, patch_report:)
  @violation_counts = RunningDiffCounters.new(base_report.violations_by_file.total_size)
  @error_counts = RunningDiffCounters.new(base_report.errors_by_file.total_size)
  @configerror_counts = RunningDiffCounters.new(base_report.configerrors_by_rule.values.flatten.length)

  @violation_diffs_by_file = {}
  @error_diffs_by_file = {}
  @configerror_diffs_by_rule = {}

  @rule_infos_union = {}
  @base_report = base_report
  @patch_report = patch_report

  @violation_diffs_by_rule = {}
  diff_with(patch_report)
end

Instance Attribute Details

#base_reportObject

Returns the value of attribute base_report.



127
128
129
# File 'lib/pmdtester/report_diff.rb', line 127

def base_report
  @base_report
end

#configerror_countsObject (readonly)

Returns the value of attribute configerror_counts.



120
121
122
# File 'lib/pmdtester/report_diff.rb', line 120

def configerror_counts
  @configerror_counts
end

#configerror_diffs_by_ruleObject

Returns the value of attribute configerror_diffs_by_rule.



124
125
126
# File 'lib/pmdtester/report_diff.rb', line 124

def configerror_diffs_by_rule
  @configerror_diffs_by_rule
end

#error_countsObject (readonly)

Returns the value of attribute error_counts.



118
119
120
# File 'lib/pmdtester/report_diff.rb', line 118

def error_counts
  @error_counts
end

#error_diffs_by_fileObject

Returns the value of attribute error_diffs_by_file.



123
124
125
# File 'lib/pmdtester/report_diff.rb', line 123

def error_diffs_by_file
  @error_diffs_by_file
end

#patch_reportObject

Returns the value of attribute patch_report.



128
129
130
# File 'lib/pmdtester/report_diff.rb', line 128

def patch_report
  @patch_report
end

#rule_infos_unionObject

Returns the value of attribute rule_infos_union.



126
127
128
# File 'lib/pmdtester/report_diff.rb', line 126

def rule_infos_union
  @rule_infos_union
end

#violation_countsObject (readonly)

Returns the value of attribute violation_counts.



119
120
121
# File 'lib/pmdtester/report_diff.rb', line 119

def violation_counts
  @violation_counts
end

#violation_diffs_by_fileObject

Returns the value of attribute violation_diffs_by_file.



122
123
124
# File 'lib/pmdtester/report_diff.rb', line 122

def violation_diffs_by_file
  @violation_diffs_by_file
end

Instance Method Details

#rule_summariesObject



147
148
149
150
151
152
153
154
155
# File 'lib/pmdtester/report_diff.rb', line 147

def rule_summaries
  @violation_diffs_by_rule.map do |(rule, counters)|
    {
      'name' => rule,
      'info_url' => @rule_infos_union[rule].info_url,
      **counters.to_h.transform_keys(&:to_s)
    }
  end
end