Skip to content

Commit 60b5734

Browse files
author
Mathias M
authored
Show a 100% coverage for empty functions/methods (#19)
Fixes #16
1 parent 0b8d152 commit 60b5734

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
v 1.1.1
2+
- Show a 100% coverage for empty functions/methods. #16
23
- Update project layout and show program version. #17
34

45
v 1.1

pkg/cov/const.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2013 Mathias Monnerville
1+
// Copyright (c) 2013-2022 Mathias Monnerville
22
//
33
// Permission is hereby granted, free of charge, to any person obtaining a copy
44
// of this software and associated documentation files (the "Software"), to

pkg/cov/report.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ package cov
2323
import (
2424
"encoding/json"
2525
"fmt"
26-
"github.com/axw/gocov"
2726
"io"
2827
"io/ioutil"
2928
"os"
3029
"path/filepath"
3130
"sort"
3231
"text/tabwriter"
3332
"time"
33+
34+
"github.com/axw/gocov"
3435
)
3536

3637
func unmarshalJson(data []byte) (packages []*gocov.Package, err error) {
@@ -221,6 +222,8 @@ func printPackage(w io.Writer, r *report, rp reportPackage) {
221222
var stmtPercent float64 = 0
222223
if len(fn.Statements) > 0 {
223224
stmtPercent = float64(reached) / float64(len(fn.Statements)) * 100
225+
} else if len(fn.Statements) == 0 {
226+
stmtPercent = 100
224227
}
225228
fmt.Fprintf(w, "<tr id=\"s_fn_%s\"><td><code><a href=\"#fn_%s\">%s(...)</a></code></td><td><code>%s/%s</code></td><td class=\"percent\"><code>%.2f%%</code></td><td class=\"linecount\"><code>%d/%d</code></td></tr>\n",
226229
fn.Name, fn.Name, fn.Name, rp.pkg.Name, filepath.Base(fn.File), stmtPercent,

0 commit comments

Comments
 (0)