Skip to content

Commit fa59ce0

Browse files
committed
Suppress "notice:" output on check not run when there is no explanation
The check functions may output an explanation when they are unable to run, which is printed to the console following a "notice:" check result label. If no explanation was provided by the check function author, this resulted in a confusing line in the console. Although it is best for an explanation to always be provided, this is not guaranteed to always be done, so it's more user friendly to suppress the check level display in this situation.
1 parent 6caf4c6 commit fa59ce0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Diff for: result/result.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@ func (results *Type) Record(checkedProject project.Type, checkConfiguration chec
103103
summaryText := fmt.Sprintf("%s\n", checkResult)
104104

105105
if checkResult == checkresult.NotRun {
106-
// TODO: make the check functions output an explanation for why they didn't run
107-
summaryText += fmt.Sprintf("%s: %s\n", checklevel.Notice, checkOutput)
106+
if checkOutput != "" {
107+
summaryText += fmt.Sprintf("%s: %s\n", checklevel.Notice, checkOutput)
108+
}
108109
} else if checkResult != checkresult.Pass {
109110
summaryText += fmt.Sprintf("%s: %s\n", checkLevel, checkMessage)
110111
}

Diff for: result/result_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ func TestRecord(t *testing.T) {
6565
assert.Equal(t, fmt.Sprintf("%s\n", checkresult.Pass), summaryText)
6666
summaryText = results.Record(checkedProject, checkConfiguration, checkresult.NotRun, checkOutput)
6767
assert.Equal(t, fmt.Sprintf("%s\n%s: %s\n", checkresult.NotRun, checklevel.Notice, checkOutput), summaryText)
68+
summaryText = results.Record(checkedProject, checkConfiguration, checkresult.NotRun, "")
69+
assert.Equal(t, "", "", summaryText)
6870
summaryText = results.Record(checkedProject, checkConfiguration, checkresult.Fail, checkOutput)
6971
assert.Equal(t, fmt.Sprintf("%s\n%s: %s\n", checkresult.Fail, checklevel.Error, message(checkConfiguration.MessageTemplate, checkOutput)), summaryText)
7072

0 commit comments

Comments
 (0)