aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--syz-ci/manager.go2
-rw-r--r--tools/syz-linter/linter.go27
-rw-r--r--tools/syz-linter/testdata/src/lintertest/lintertest.go1
3 files changed, 16 insertions, 14 deletions
diff --git a/syz-ci/manager.go b/syz-ci/manager.go
index b715a5fa5..1e3c95c70 100644
--- a/syz-ci/manager.go
+++ b/syz-ci/manager.go
@@ -429,7 +429,7 @@ func (mgr *Manager) testImage(imageDir string, info *BuildInfo) error {
func (mgr *Manager) reportBuildError(rep *report.Report, info *BuildInfo, imageDir string) error {
if mgr.dash == nil {
- log.Logf(0, "%v: image testing failed: %v\n\n%s\n\n%s\n",
+ log.Logf(0, "%v: image testing failed: %v\n\n%s\n\n%s",
mgr.name, rep.Title, rep.Report, rep.Output)
return nil
}
diff --git a/tools/syz-linter/linter.go b/tools/syz-linter/linter.go
index 0b2a9f2b9..44fb91fbc 100644
--- a/tools/syz-linter/linter.go
+++ b/tools/syz-linter/linter.go
@@ -20,6 +20,7 @@ import (
"go/token"
"go/types"
"regexp"
+ "strconv"
"strings"
"unicode"
@@ -190,27 +191,27 @@ func checkLogErrorFormat(pass *analysis.Pass, n *ast.CallExpr) {
if !ok || lit.Kind != token.STRING {
return
}
- val := lit.Value[1 : len(lit.Value)-1] // the value includes quotes
+ report := func(msg string) {
+ pass.Report(analysis.Diagnostic{Pos: lit.Pos(), Message: msg})
+ }
+ val, err := strconv.Unquote(lit.Value)
+ if err != nil {
+ return
+ }
ln := len(val)
if ln == 0 {
- pass.Report(analysis.Diagnostic{
- Pos: n.Pos(),
- Message: "Don't use empty log/error messages",
- })
+ report("Don't use empty log/error messages")
return
}
if val[ln-1] == '.' && (ln < 3 || val[ln-2] != '.' || val[ln-3] != '.') {
- pass.Report(analysis.Diagnostic{
- Pos: n.Pos(),
- Message: "Don't use dot at the end of log/error messages",
- })
+ report("Don't use dot at the end of log/error messages")
+ }
+ if val[ln-1] == '\n' {
+ report("Don't use \\n at the end of log/error messages")
}
if ln >= 2 && unicode.IsUpper(rune(val[0])) && unicode.IsLower(rune(val[1])) &&
!publicIdentifier.MatchString(val) {
- pass.Report(analysis.Diagnostic{
- Pos: n.Pos(),
- Message: "Don't start log/error messages with a Capital letter",
- })
+ report("Don't start log/error messages with a Capital letter")
}
}
diff --git a/tools/syz-linter/testdata/src/lintertest/lintertest.go b/tools/syz-linter/testdata/src/lintertest/lintertest.go
index b36333797..7b8722693 100644
--- a/tools/syz-linter/testdata/src/lintertest/lintertest.go
+++ b/tools/syz-linter/testdata/src/lintertest/lintertest.go
@@ -63,5 +63,6 @@ func logErrorMessages() {
log.Printf("Bad message %v", 1) // want "Don't start log/error messages with a Capital letter"
log.Print("Bad message") // want "Don't start log/error messages with a Capital letter"
log.Print("also ad message.") // want "Don't use dot at the end of log/error messages"
+ log.Print("no new lines\n") // want "Don't use \\\\n at the end of log/error messages"
log.Print("") // want "Don't use empty log/error messages"
}