Skip to content

Commit

Permalink
hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
illabo committed Oct 29, 2020
1 parent 19907b5 commit 832e8bd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
6 changes: 6 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@

### Hotfix (0.3.2)
- Added missing warning message for file coverage % when reduced.
- Some warnings weren't visible. Seem GitHub Actions warnings should be oneliners. Removed newline symbols.
- Some code duplications cleaned.

### Hotfix (0.3.1)
- "Increased" and "Decreased" messages was swapped.

Expand Down
46 changes: 29 additions & 17 deletions reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,36 +117,48 @@ func diffTargets(rnCnd *RunConditions, lastTgt, currentTgt *Target) {
continue
}

fileReport := "\n"
if curFile.CoveredLines < lstFile.CoveredLines {
var warnMsg string
if rnCnd.Config.MeterLOC {
warnMsg = fmt.Sprintf("covered %dLOC, was %dLOC.", curFile.CoveredLines, lstFile.CoveredLines)
}
fileReport = fmt.Sprintf("File coverage is reduced: %s\n", warnMsg)
var fileReport string
if curFile.CoveredLines < lstFile.CoveredLines && rnCnd.Config.MeterLOC {
fileReport = fmt.Sprintf(
"File coverage is reduced: %s",
fmt.Sprintf(
"covered %dLOC, was %dLOC.",
curFile.CoveredLines,
lstFile.CoveredLines,
))
}
curPct := percentify(linesRatio(curFile.CoveredLines, curFile.ExecutableLines))
lstPct := percentify(linesRatio(lstFile.CoveredLines, lstFile.ExecutableLines))
if curPct < lstPct && !rnCnd.Config.MeterLOC {
fileReport = fmt.Sprintf(
"File coverage is reduced: %s",
fmt.Sprintf("covered %d%%, was %d%%.",
curPct,
lstPct,
))
}
if curFile.CoveredLines == 0 {
fileReport = "File is not covered.\n"
fileReport = "File is not covered."
}

for _, curFunc := range curFile.Functions {
if lstFunc, ok := lfsFlatFuncs[curFunc.Name]; ok {
fileReport = fmt.Sprintf("%s%s", fileReport, warnFuncCov(&lstFunc, &curFunc))
} else {
fileReport = fmt.Sprintf("%s%s", fileReport, warnZeroFuncCov(&curFunc))
lstFunc := lfsFlatFuncs[curFunc.Name]
cov := warnFuncCov(&lstFunc, &curFunc)
if cov != "" {
fileReport = fmt.Sprintf("%s %s", fileReport, cov)
}
}
if fileReport != "\n" {
fmt.Printf("::warning file=%s::%s", curFilePth, fileReport)
if strings.TrimSpace(fileReport) != "" {
fmt.Printf("::warning file=%s::%s\n", curFilePth, fileReport)
}

}
}

func warnFuncCov(lstFunc, curFunc *Function) string {
if lstFunc.LineCoverage > curFunc.LineCoverage {
if lstFunc != nil && lstFunc.LineCoverage > curFunc.LineCoverage {
return fmt.Sprintf(
"%d | %s coverage is lowered to %d%% (was %d%%).\n",
"Line %d: %s coverage is lowered to %d%% (was %d%%).",
curFunc.LineNumber,
curFunc.Name,
percentify(curFunc.LineCoverage),
Expand All @@ -160,7 +172,7 @@ func warnFuncCov(lstFunc, curFunc *Function) string {
func warnZeroFuncCov(curFunc *Function) string {
if percentify(curFunc.LineCoverage) == 0 {
return fmt.Sprintf(
"%d | %s is not covered.\n",
"Line %d: %s is not covered.",
curFunc.LineNumber,
curFunc.Name,
)
Expand Down

0 comments on commit 832e8bd

Please sign in to comment.