From 961ff19bfd08cd8881ff20d7d904c2cec6200d9d Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Tue, 21 Sep 2021 14:44:39 -0400 Subject: [PATCH] implements: don't panic if no counts for C functions are avaiable Signed-off-by: John Mulligan --- contrib/implements/internal/implements/report.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/contrib/implements/internal/implements/report.go b/contrib/implements/internal/implements/report.go index 306254e..50a0116 100644 --- a/contrib/implements/internal/implements/report.go +++ b/contrib/implements/internal/implements/report.go @@ -51,19 +51,24 @@ func (r *TextReport) Report(name string, ii *Inspector) error { found := len(ii.found) total := len(ii.expected) + missing := total - found - ii.deprecatedMissing + var percentFound, percentMissing int + if total > 0 { + percentFound = (100 * found) / total + percentMissing = (100 * missing) / total + } r.printf( "%s functions covered: %d/%d : %v%%\n", packageLabel, found, total, - (100*found)/total) - missing := total - found - ii.deprecatedMissing + percentFound) r.printf( "%s functions missing: %d/%d : %v%%\n", packageLabel, missing, total, - (100*missing)/total) + percentMissing) r.printf( " (note missing count does not include deprecated functions in ceph)\n")