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.



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

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.



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

def base_report
  @base_report
end

#configerror_countsObject (readonly)

Returns the value of attribute configerror_counts.



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

def configerror_counts
  @configerror_counts
end

#configerror_diffs_by_ruleObject

Returns the value of attribute configerror_diffs_by_rule.



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

def configerror_diffs_by_rule
  @configerror_diffs_by_rule
end

#error_countsObject (readonly)

Returns the value of attribute error_counts.



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

def error_counts
  @error_counts
end

#error_diffs_by_fileObject

Returns the value of attribute error_diffs_by_file.



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

def error_diffs_by_file
  @error_diffs_by_file
end

#patch_reportObject

Returns the value of attribute patch_report.



130
131
132
# File 'lib/pmdtester/report_diff.rb', line 130

def patch_report
  @patch_report
end

#rule_infos_unionObject

Returns the value of attribute rule_infos_union.



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

def rule_infos_union
  @rule_infos_union
end

#violation_countsObject (readonly)

Returns the value of attribute violation_counts.



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

def violation_counts
  @violation_counts
end

#violation_diffs_by_fileObject

Returns the value of attribute violation_diffs_by_file.



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

def violation_diffs_by_file
  @violation_diffs_by_file
end

Instance Method Details

#rule_summariesObject



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

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