From 3ff5d2a0b72a14860b0945e56ac1295dd51a991b Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Tue, 16 Apr 2024 13:52:22 +0200 Subject: pkg/cover: remove function coverage percents These numbers seem confusing to syzkaller users. If there's demand for them, we may consider re-enabling the calculation under some extra syzkaller config parameter. --- pkg/cover/html.go | 43 +++++++++++++------------------------------ 1 file changed, 13 insertions(+), 30 deletions(-) (limited to 'pkg') diff --git a/pkg/cover/html.go b/pkg/cover/html.go index 3ab1ada6f..5a78b75f8 100644 --- a/pkg/cover/html.go +++ b/pkg/cover/html.go @@ -70,19 +70,12 @@ func (rg *ReportGenerator) DoHTML(w io.Writer, params CoverHandlerParams) error pos = pos.Dirs[dir] fname = fname[sep+1:] } - var TotalInCoveredFunc int - for _, function := range file.functions { - if function.covered > 0 { - TotalInCoveredFunc += function.pcs - } - } f := &templateFile{ templateBase: templateBase{ - Path: path, - Name: fname, - Total: file.totalPCs, - TotalInCoveredFunc: TotalInCoveredFunc, - Covered: file.coveredPCs, + Path: path, + Name: fname, + Total: file.totalPCs, + Covered: file.coveredPCs, }, HasFunctions: len(file.functions) != 0, } @@ -816,22 +809,14 @@ func processDir(dir *templateDir) { for _, f := range dir.Files { dir.Total += f.Total dir.Covered += f.Covered - dir.TotalInCoveredFunc += f.TotalInCoveredFunc f.Percent = percent(f.Covered, f.Total) - if f.TotalInCoveredFunc > 0 { - f.PercentInCoveredFunc = percent(f.Covered, f.TotalInCoveredFunc) - } } for _, child := range dir.Dirs { processDir(child) dir.Total += child.Total dir.Covered += child.Covered - dir.TotalInCoveredFunc += child.TotalInCoveredFunc } dir.Percent = percent(dir.Covered, dir.Total) - if dir.TotalInCoveredFunc > 0 { - dir.PercentInCoveredFunc += percent(dir.Covered, dir.TotalInCoveredFunc) - } if dir.Covered == 0 { dir.Dirs = nil dir.Files = nil @@ -880,13 +865,11 @@ type templateProg struct { } type templateBase struct { - Name string - Path string - Total int - Covered int - TotalInCoveredFunc int - Percent int - PercentInCoveredFunc int + Name string + Path string + Total int + Covered int + Percent int } type templateDir struct { @@ -1095,8 +1078,8 @@ var coverTemplate = template.Must(template.New("").Parse(` {{$dir.Name}} - {{if $dir.Covered}}{{$dir.Percent}}%({{$dir.PercentInCoveredFunc}}%){{else}}---{{end}} - of {{$dir.Total}}({{$dir.TotalInCoveredFunc}}) + {{if $dir.Covered}}{{$dir.Percent}}%{{else}}---{{end}} + of {{$dir.Total}}