@@ -50,30 +50,38 @@ def initialize(name, info_url)
5050 class Report
5151 attr_reader :violations_by_file ,
5252 :errors_by_file ,
53+ :configerrors_by_rule ,
5354 :exec_time ,
5455 :timestamp ,
5556 :infos_by_rule
5657
57- def initialize ( violations_by_file :,
58- errors_by_file :,
59- exec_time :,
60- timestamp :,
61- infos_by_rule :)
62- @violations_by_file = violations_by_file
63- @errors_by_file = errors_by_file
58+ def initialize ( report_document : nil ,
59+ exec_time : 0 ,
60+ timestamp : '0' )
61+ initialize_empty
62+ initialize_with_report_document report_document unless report_document . nil?
6463 @exec_time = exec_time
6564 @timestamp = timestamp
66- @infos_by_rule = infos_by_rule
6765 end
6866
6967 def self . empty
70- new (
71- violations_by_file : CollectionByFile . new ,
72- errors_by_file : CollectionByFile . new ,
73- exec_time : 0 ,
74- timestamp : '0' ,
75- infos_by_rule : { }
76- )
68+ new
69+ end
70+
71+ private
72+
73+ def initialize_with_report_document ( report_document )
74+ @violations_by_file = report_document . violations
75+ @errors_by_file = report_document . errors
76+ @configerrors_by_rule = report_document . configerrors
77+ @infos_by_rule = report_document . infos_by_rules
78+ end
79+
80+ def initialize_empty
81+ @violations_by_file = CollectionByFile . new
82+ @errors_by_file = CollectionByFile . new
83+ @configerrors_by_rule = { }
84+ @infos_by_rule = { }
7785 end
7886 end
7987
@@ -85,9 +93,11 @@ class ReportDiff
8593
8694 attr_reader :error_counts
8795 attr_reader :violation_counts
96+ attr_reader :configerror_counts
8897
8998 attr_accessor :violation_diffs_by_file
9099 attr_accessor :error_diffs_by_file
100+ attr_accessor :configerror_diffs_by_rule
91101
92102 attr_accessor :rule_infos_union
93103 attr_accessor :base_report
@@ -96,15 +106,17 @@ class ReportDiff
96106 def initialize ( base_report :, patch_report :)
97107 @violation_counts = RunningDiffCounters . new ( base_report . violations_by_file . total_size )
98108 @error_counts = RunningDiffCounters . new ( base_report . errors_by_file . total_size )
99- @violation_diffs_by_rule = { }
100-
101- @base_report = base_report
102- @patch_report = patch_report
109+ @configerror_counts = RunningDiffCounters . new ( base_report . configerrors_by_rule . values . flatten . length )
103110
104- @rule_infos_union = base_report . infos_by_rule . dup
105111 @violation_diffs_by_file = { }
106112 @error_diffs_by_file = { }
113+ @configerror_diffs_by_rule = { }
114+
115+ @rule_infos_union = base_report . infos_by_rule . dup
116+ @base_report = base_report
117+ @patch_report = patch_report
107118
119+ @violation_diffs_by_rule = { }
108120 diff_with ( patch_report )
109121 end
110122
@@ -123,11 +135,13 @@ def rule_summaries
123135 def diff_with ( patch_report )
124136 @violation_counts . patch_total = patch_report . violations_by_file . total_size
125137 @error_counts . patch_total = patch_report . errors_by_file . total_size
138+ @configerror_counts . patch_total = patch_report . configerrors_by_rule . values . flatten . length
126139
127140 @violation_diffs_by_file = build_diffs ( @violation_counts , &:violations_by_file )
128141 count ( @violation_diffs_by_file ) { |v | getvdiff ( v . rule_name ) } # record the diffs in the rule counter
129142
130143 @error_diffs_by_file = build_diffs ( @error_counts , &:errors_by_file )
144+ @configerror_diffs_by_rule = build_diffs ( @configerror_counts , &:configerrors_by_rule )
131145
132146 count_by_rule ( @base_report . violations_by_file , base : true )
133147 count_by_rule ( @patch_report . violations_by_file , base : false )
@@ -178,6 +192,7 @@ def build_diffs(counters, &getter)
178192 end
179193
180194 # @param diff_h a hash { filename => list[violation]}, containing those that changed
195+ # in case of config errors it's a hash { rulename => list[configerror] }
181196 def merge_changed_items ( diff_h )
182197 diff_h . each do |fname , different |
183198 different . sort_by! ( &:sort_key )
0 commit comments