@@ -18,21 +18,16 @@ pub fn generate_report(
18
18
base_branch : & str ,
19
19
head_branch : & str ,
20
20
) -> String {
21
+ // TODO: This is hardcoded for now, as the presence of the clippy-annotation-reporter crate in
22
+ // the repo is temporary. A future feature can allow users to specify crates to ignore.
23
+ const IGNORED_CRATE : & str = "clippy-annotation-reporter" ;
24
+
21
25
let mut report = String :: new ( ) ;
22
26
23
- // Add header and branch information
24
27
add_header ( & mut report, repository, base_branch, head_branch) ;
25
-
26
- // Add rule summary section
27
28
add_rule_summary ( & mut report, analysis, rules) ;
28
-
29
- // Add file-level section
30
- add_file_level_section ( & mut report, analysis) ;
31
-
32
- // Add crate-level section
33
- add_crate_level_section ( & mut report, analysis) ;
34
-
35
- // Add explanation
29
+ add_file_level_section ( & mut report, analysis, IGNORED_CRATE ) ;
30
+ add_crate_level_section ( & mut report, analysis, IGNORED_CRATE ) ;
36
31
add_explanation ( & mut report) ;
37
32
38
33
report
@@ -79,7 +74,7 @@ fn add_rule_summary(report: &mut String, analysis: &AnalysisResult, rules: &[Str
79
74
}
80
75
81
76
/// Add section showing annotation counts by file
82
- fn add_file_level_section ( report : & mut String , analysis : & AnalysisResult ) {
77
+ fn add_file_level_section ( report : & mut String , analysis : & AnalysisResult , ignored_crate : & str ) {
83
78
if analysis. changed_files . is_empty ( ) {
84
79
return ;
85
80
}
@@ -98,8 +93,15 @@ fn add_file_level_section(report: &mut String, analysis: &AnalysisResult) {
98
93
99
94
// Add row for each file
100
95
for file in all_files {
101
- let base_count = * base_file_counts. get ( & file) . unwrap_or ( & 0 ) ;
102
- let head_count = * head_file_counts. get ( & file) . unwrap_or ( & 0 ) ;
96
+ // Skip files that belong to the ignored crate
97
+ if !ignored_crate. is_empty ( )
98
+ && file. contains ( & format ! ( ".github/actions/{}/" , ignored_crate) )
99
+ {
100
+ continue ;
101
+ }
102
+
103
+ let base_count = * base_file_counts. get ( & Rc :: new ( file. clone ( ) ) ) . unwrap_or ( & 0 ) ;
104
+ let head_count = * head_file_counts. get ( & Rc :: new ( file. clone ( ) ) ) . unwrap_or ( & 0 ) ;
103
105
104
106
// Skip files with no annotations in either branch
105
107
if base_count == 0 && head_count == 0 {
@@ -113,7 +115,7 @@ fn add_file_level_section(report: &mut String, analysis: &AnalysisResult) {
113
115
}
114
116
115
117
/// Add section showing annotation stats by crate
116
- fn add_crate_level_section ( report : & mut String , analysis : & AnalysisResult ) {
118
+ fn add_crate_level_section ( report : & mut String , analysis : & AnalysisResult , ignored_crate : & str ) {
117
119
report. push_str ( "### Annotation Stats by Crate\n \n " ) ;
118
120
report. push_str ( "| Crate | Base Branch | PR Branch | Change |\n " ) ;
119
121
report. push_str ( "|-------|------------|-----------|--------|\n " ) ;
@@ -126,6 +128,11 @@ fn add_crate_level_section(report: &mut String, analysis: &AnalysisResult) {
126
128
127
129
// Add row for each crate
128
130
for crate_name in all_crates {
131
+ // Skip the ignored crate
132
+ if !ignored_crate. is_empty ( ) && * crate_name == ignored_crate {
133
+ continue ;
134
+ }
135
+
129
136
let base_count = * analysis. base_crate_counts . get ( & crate_name) . unwrap_or ( & 0 ) ;
130
137
let head_count = * analysis. head_crate_counts . get ( & crate_name) . unwrap_or ( & 0 ) ;
131
138
0 commit comments