@@ -60,33 +60,72 @@ fn add_header(report: &mut String, repository: &str, base_branch: &str, head_bra
60
60
}
61
61
62
62
/// Add summary table by rule
63
- /// Add summary table by rule
64
- fn add_rule_summary ( report : & mut String , analysis : & AnalysisResult , rules : & [ String ] , ignored_crate : & str ) {
63
+ fn add_rule_summary (
64
+ report : & mut String ,
65
+ analysis : & AnalysisResult ,
66
+ rules : & [ String ] ,
67
+ ignored_crate : & str ,
68
+ ) {
65
69
report. push_str ( "### Summary by Rule\n \n " ) ;
66
70
report. push_str ( "| Rule | Base Branch | PR Branch | Change |\n " ) ;
67
71
report. push_str ( "|------|------------|-----------|--------|\n " ) ;
68
72
69
73
let mut total_base = 0 ;
70
74
let mut total_head = 0 ;
71
75
72
- // Use the original counts - these already contain the data we need
73
- // We don't need to filter and recalculate for rule summary
74
- for rule_str in rules {
75
- let rule = Rc :: new ( rule_str. clone ( ) ) ;
76
- let base_count = * analysis. base_counts . get ( & rule) . unwrap_or ( & 0 ) ;
77
- let head_count = * analysis. head_counts . get ( & rule) . unwrap_or ( & 0 ) ;
76
+ // If we're ignoring a crate, we need to filter and recalculate counts
77
+ if !ignored_crate. is_empty ( ) {
78
+ // Filter out annotations from the ignored crate
79
+ let filtered_base_annotations: Vec < & ClippyAnnotation > = analysis
80
+ . base_annotations
81
+ . iter ( )
82
+ . filter ( |anno| {
83
+ let file_path = anno. file . as_str ( ) ;
84
+ !file_path. contains ( & format ! ( ".github/actions/{}/" , ignored_crate) )
85
+ } )
86
+ . collect ( ) ;
87
+
88
+ let filtered_head_annotations: Vec < & ClippyAnnotation > = analysis
89
+ . head_annotations
90
+ . iter ( )
91
+ . filter ( |anno| {
92
+ let file_path = anno. file . as_str ( ) ;
93
+ !file_path. contains ( & format ! ( ".github/actions/{}/" , ignored_crate) )
94
+ } )
95
+ . collect ( ) ;
96
+
97
+ // Count by rule
98
+ let filtered_base_counts = count_annotations_by_rule_refs ( & filtered_base_annotations) ;
99
+ let filtered_head_counts = count_annotations_by_rule_refs ( & filtered_head_annotations) ;
100
+
101
+ // Generate the rule summary
102
+ for rule_str in rules {
103
+ let base_count = filtered_base_counts. get ( rule_str) . copied ( ) . unwrap_or ( 0 ) ;
104
+ let head_count = filtered_head_counts. get ( rule_str) . copied ( ) . unwrap_or ( 0 ) ;
105
+
106
+ total_base += base_count;
107
+ total_head += head_count;
108
+
109
+ add_table_row ( report, rule_str, base_count, head_count) ;
110
+ }
111
+ } else {
112
+ // Use the original counts - this is the test path
113
+ for rule_str in rules {
114
+ let rule = Rc :: new ( rule_str. clone ( ) ) ;
115
+ let base_count = * analysis. base_counts . get ( & rule) . unwrap_or ( & 0 ) ;
116
+ let head_count = * analysis. head_counts . get ( & rule) . unwrap_or ( & 0 ) ;
78
117
79
- total_base += base_count;
80
- total_head += head_count;
118
+ total_base += base_count;
119
+ total_head += head_count;
81
120
82
- add_table_row ( report, rule_str, base_count, head_count) ;
121
+ add_table_row ( report, rule_str, base_count, head_count) ;
122
+ }
83
123
}
84
124
85
125
// Add total row
86
126
add_table_row ( report, "**Total**" , total_base, total_head) ;
87
127
report. push ( '\n' ) ;
88
128
}
89
-
90
129
// Helper function to count annotations by rule from references
91
130
fn count_annotations_by_rule_refs ( annotations : & [ & ClippyAnnotation ] ) -> HashMap < Rc < String > , usize > {
92
131
let mut counts = HashMap :: new ( ) ;
0 commit comments