@@ -104,31 +104,22 @@ define! {
104104 th[ style = "text-align: right;" ] {
105105 "Lines"
106106 }
107- @if ( summary. hit_lines as f32 / summary. total_lines as f32 )
108- * 100.0 >= 90.0 {
107+ @let ratio = if summary. total_lines == 0 {
108+ 0.0
109+ } else {
110+ summary. hit_lines as f32 / summary. total_lines as f32 * 100.0
111+ } ;
112+ @if ratio >= 90.0 {
109113 td[ style = "text-align: right; background-color: #a7fc9d;" ] {
110- @format!(
111- "{:.02}%" ,
112- ( summary. hit_lines as f32 / summary. total_lines as f32 )
113- * 100.0
114- )
114+ @format!( "{ratio:.02}%" )
115115 }
116- } else if ( summary. hit_lines as f32 / summary. total_lines as f32 )
117- * 100.0 >= 30.0 {
116+ } else if ratio >= 30.0 {
118117 td[ style = "text-align: right; background-color: #ffea20;" ] {
119- @format!(
120- "{:.02}%" ,
121- ( summary. hit_lines as f32 / summary. total_lines as f32 )
122- * 100.0
123- )
118+ @format!( "{ratio:.02}%" )
124119 }
125120 } else {
126121 td[ style = "text-align: right; background-color: #ff6230;" ] {
127- @format!(
128- "{:.02}%" ,
129- ( summary. hit_lines as f32 / summary. total_lines as f32 )
130- * 100.0
131- )
122+ @format!( "{ratio:.02}%" )
132123 }
133124 }
134125
@@ -143,32 +134,23 @@ define! {
143134 th[ style = "text-align: right;" ] {
144135 "Functions"
145136 }
146- @if ( summary. hit_functions as f32 / summary. total_functions as f32 )
147- * 100.0 >= 90.0 {
137+ @let ratio = if summary. total_functions == 0 {
138+ 0.0
139+ } else {
140+ summary. hit_functions as f32 / summary. total_functions as f32 * 100.0
141+ } ;
142+ @if ratio >= 90.0 {
148143 td[ style = "text-align: right; background-color: #a7fc9d;" ] {
149- @format!(
150- "{:.02}%" ,
151- ( summary. hit_functions as f32 / summary. total_functions as f32 )
152- * 100.0
153- )
144+ @format!( "{ratio:.02}%" )
154145 }
155- } else if ( summary. hit_functions as f32 / summary. total_functions as f32 )
156- * 100.0 >= 30.0 {
146+ } else if ratio >= 30.0 {
157147 td[ style = "text-align: right; background-color: #ffea20;" ] {
158- @format!(
159- "{:.02}%" ,
160- ( summary. hit_functions as f32 / summary. total_functions as f32 )
161- * 100.0
162- )
148+ @format!( "{ratio:.02}%" )
163149 }
164150
165151 } else {
166152 td[ style = "text-align: right; background-color: #ff6230;" ] {
167- @format!(
168- "{:.02}%" ,
169- ( summary. hit_functions as f32 / summary. total_functions as f32 )
170- * 100.0
171- )
153+ @format!( "{ratio:.02}%" )
172154 }
173155 }
174156 td[ style = "text-align: right; background-color: #cad7fe;" ] {
@@ -351,69 +333,58 @@ define! {
351333 "<unknown>"
352334 }
353335 }
354- @if ( summary. hit_lines as f32 / summary. total_lines as f32 )
355- * 100.0 >= 90.0 {
336+ @let line_ratio = if summary. total_lines == 0 {
337+ 0.0
338+ } else {
339+ summary. hit_lines as f32 / summary. total_lines as f32 * 100.0
340+ } ;
341+
342+ @let function_ratio = if summary. total_functions == 0 {
343+ 0.0
344+ } else {
345+ summary. hit_functions as f32 / summary. total_functions as f32 * 100.0
346+ } ;
347+
348+ @if line_ratio >= 90.0 {
356349 td[ style = "text-align: right; background-color: #a7fc9d;" ] {
357- @format!(
358- "{:.02}%" ,
359- ( summary. hit_lines as f32 / summary. total_lines as f32 )
360- * 100.0
361- )
350+ @format!( "{line_ratio:.02}%" )
362351 }
363- } else if ( summary. hit_lines as f32 / summary. total_lines as f32 )
364- * 100.0 >= 30.0 {
352+ } else if line_ratio >= 30.0 {
365353 td[ style = "text-align: right; background-color: #ffea20;" ] {
366- @format!(
367- "{:.02}%" ,
368- ( summary. hit_lines as f32 / summary. total_lines as f32 )
369- * 100.0
370- )
354+ @format!( "{line_ratio:.02}%" )
371355 }
372356 } else {
373357 td[ style = "text-align: right; background-color: #ff6230;" ] {
374- @format!(
375- "{:.02}%" ,
376- ( summary. hit_lines as f32 / summary. total_lines as f32 )
377- * 100.0
378- )
358+ @format!( "{line_ratio:.02}%" )
379359 }
380360 }
361+
381362 td[ style = "text-align: right; background-color: #cad7fe;" ] {
382363 @summary. total_lines
383364 }
365+
384366 td[ style = "text-align: right; background-color: #cad7fe;" ] {
385367 @summary. hit_lines
386368 }
387- @ if ( summary . hit_functions as f32 / summary . total_functions as f32 )
388- * 100.0 >= 90.0 {
369+
370+ @ if function_ratio >= 90.0 {
389371 td[ style = "text-align: right; background-color: #a7fc9d;" ] {
390- @format!(
391- "{:.02}%" ,
392- ( summary. hit_functions as f32 / summary. total_functions as f32 )
393- * 100.0
394- )
372+ @format!( "{function_ratio:.02}%" )
395373 }
396- } else if ( summary. hit_functions as f32 / summary. total_functions as f32 )
397- * 100.0 >= 30.0 {
374+ } else if function_ratio >= 30.0 {
398375 td[ style = "text-align: right; background-color: #ffea20;" ] {
399- @format!(
400- "{:.02}%" ,
401- ( summary. hit_functions as f32 / summary. total_functions as f32 )
402- * 100.0
403- )
376+ @format!( "{function_ratio:.02}%" )
404377 }
405378 } else {
406379 td[ style = "text-align: right; background-color: #ff6230;" ] {
407- @format!(
408- "{:.02}%" ,
409- ( summary. hit_functions as f32 / summary. total_functions as f32 )
410- * 100.0
411- )
380+ @format!( "{function_ratio:.02}%" )
412381 }
413382 }
383+
414384 td[ style = "text-align: right; background-color: #cad7fe;" ] {
415385 @summary. total_functions
416386 }
387+
417388 td[ style = "text-align: right; background-color: #cad7fe;" ] {
418389 @summary. hit_functions
419390 }
0 commit comments