@@ -34,10 +34,12 @@ export function generateMdReportsDiff(diff: ReportsDiff): string {
34
34
35
35
function formatDiffHeaderSection ( diff : ReportsDiff ) : string {
36
36
const outcomeTexts : Record < DiffOutcome , string > = {
37
- positive : `🙌 Code PushUp report has ${ style ( 'improved' ) } ` ,
37
+ positive : `🥳 Code PushUp report has ${ style ( 'improved' ) } ` ,
38
38
negative : `😟 Code PushUp report has ${ style ( 'regressed' ) } ` ,
39
- neutral : `Code PushUp report is ${ style ( 'unchanged' ) } ` ,
40
- mixed : `😐 Code PushUp report has both ${ style ( 'improved and regressed' ) } ` ,
39
+ neutral : `😐 Code PushUp report is ${ style ( 'unchanged' ) } ` ,
40
+ mixed : `🤨 Code PushUp report has both ${ style (
41
+ 'improvements and regressions' ,
42
+ ) } `,
41
43
} ;
42
44
const outcome = mergeDiffOutcomes (
43
45
changesToDiffOutcomes ( [
@@ -64,25 +66,29 @@ function formatDiffHeaderSection(diff: ReportsDiff): string {
64
66
65
67
function formatDiffCategoriesSection ( diff : ReportsDiff ) : string {
66
68
const { changed, unchanged } = diff . categories ;
69
+ if ( changed . length + unchanged . length === 0 ) {
70
+ return '' ;
71
+ }
67
72
return paragraphs (
68
73
h2 ( '🏷️ Categories' ) ,
69
- tableMd (
70
- [
74
+ changed . length > 0 &&
75
+ tableMd (
71
76
[
72
- '🏷️ Category' ,
73
- '⭐ Current score' ,
74
- '⭐ Previous score' ,
75
- '🗠 Score change' ,
77
+ [
78
+ '🏷️ Category' ,
79
+ '⭐ Current score' ,
80
+ '⭐ Previous score' ,
81
+ '🗠 Score change' ,
82
+ ] ,
83
+ ...changed . map ( category => [
84
+ category . title ,
85
+ formatScoreWithColor ( category . scores . after ) ,
86
+ formatScoreWithColor ( category . scores . before , { skipBold : true } ) ,
87
+ formatScoreChange ( category . scores . diff ) ,
88
+ ] ) ,
76
89
] ,
77
- ...changed . map ( category => [
78
- category . title ,
79
- formatScoreWithColor ( category . scores . after ) ,
80
- formatScoreWithColor ( category . scores . before , { skipBold : true } ) ,
81
- formatScoreChange ( category . scores . diff ) ,
82
- ] ) ,
83
- ] ,
84
- [ 'l' , 'c' , 'c' , 'c' ] ,
85
- ) ,
90
+ [ 'l' , 'c' , 'c' , 'c' ] ,
91
+ ) ,
86
92
unchanged . length > 0 &&
87
93
details (
88
94
summarizeUnchanged ( 'category' , { changed, unchanged } ) ,
@@ -96,6 +102,9 @@ function formatDiffCategoriesSection(diff: ReportsDiff): string {
96
102
}
97
103
98
104
function formatDiffGroupsSection ( diff : ReportsDiff ) : string {
105
+ if ( diff . groups . changed . length + diff . groups . unchanged . length === 0 ) {
106
+ return '' ;
107
+ }
99
108
return paragraphs (
100
109
h2 ( '🎗️ Groups' ) ,
101
110
formatGroupsOrAuditsDetails ( 'group' , diff . groups , {
@@ -201,7 +210,7 @@ function summarizeUnchanged(
201
210
changed . length > 0
202
211
? pluralizeToken ( `other ${ token } ` , unchanged . length )
203
212
: `All of ${ pluralizeToken ( token , unchanged . length ) } ` ,
204
- unchanged . length > 1 ? 'are ' : 'is ' ,
213
+ unchanged . length === 1 ? 'is ' : 'are ' ,
205
214
'unchanged.' ,
206
215
] . join ( ' ' ) ;
207
216
}
@@ -247,6 +256,9 @@ function changesToDiffOutcomes(
247
256
}
248
257
249
258
function mergeDiffOutcomes ( outcomes : DiffOutcome [ ] ) : DiffOutcome {
259
+ if ( outcomes . length === 0 ) {
260
+ return 'neutral' ;
261
+ }
250
262
if (
251
263
outcomes . every ( outcome => outcome === 'positive' || outcome === 'neutral' )
252
264
) {
0 commit comments