]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/vet: remove "only" from error message
authorKevin Burke <kev@inburke.com>
Thu, 26 Apr 2018 06:04:36 +0000 (23:04 -0700)
committerKevin Burke <kev@inburke.com>
Fri, 27 Apr 2018 03:07:26 +0000 (03:07 +0000)
If the vetted function supplies zero arguments, previously you would
get an error message like this:

    Printf format %v reads arg #1, but call has only 0 args

"has only 0 args" is an odd construction, and "has 0 args" sounds
better. Getting rid of "only" in all cases simplifies the code and
reads just as well.

Change-Id: I4706dfe4a75f13bf4db9c0650e459ca676710752
Reviewed-on: https://go-review.googlesource.com/109457
Run-TryBot: Kevin Burke <kev@inburke.com>
Run-TryBot: David Symonds <dsymonds@golang.org>
Reviewed-by: David Symonds <dsymonds@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/vet/print.go
src/cmd/vet/testdata/print.go

index 38d6f72419ba19fb0709249faed58ac85e6e8a5c..294688f4ea629f08365ad150f0f7028409f6fe27 100644 (file)
@@ -708,7 +708,7 @@ func (f *File) argCanBeChecked(call *ast.CallExpr, formatArg int, state *formatS
        // There are bad indexes in the format or there are fewer arguments than the format needs.
        // This is the argument number relative to the format: Printf("%s", "hi") will give 1 for the "hi".
        arg := argNum - state.firstArg + 1 // People think of arguments as 1-indexed.
-       f.Badf(call.Pos(), "%s format %s reads arg #%d, but call has only %v", state.name, state.format, arg, count(len(call.Args)-state.firstArg, "arg"))
+       f.Badf(call.Pos(), "%s format %s reads arg #%d, but call has %v", state.name, state.format, arg, count(len(call.Args)-state.firstArg, "arg"))
        return false
 }
 
index 6508c8e61552e5a56cdf5ce9b4662c9ac79c0143..1669a047daf0afc89fce56daaa7bd9edc8edcb4d 100644 (file)
@@ -166,8 +166,8 @@ func PrintfTests() {
        Printf("hi")                       // ok
        const format = "%s %s\n"
        Printf(format, "hi", "there")
-       Printf(format, "hi")              // ERROR "Printf format %s reads arg #2, but call has only 1 arg$"
-       Printf("%s %d %.3v %q", "str", 4) // ERROR "Printf format %.3v reads arg #3, but call has only 2 args"
+       Printf(format, "hi")              // ERROR "Printf format %s reads arg #2, but call has 1 arg$"
+       Printf("%s %d %.3v %q", "str", 4) // ERROR "Printf format %.3v reads arg #3, but call has 2 args"
        f := new(ptrStringer)
        f.Warn(0, "%s", "hello", 3)           // ERROR "Warn call has possible formatting directive %s"
        f.Warnf(0, "%s", "hello", 3)          // ERROR "Warnf call needs 1 arg but has 2 args"
@@ -240,7 +240,7 @@ func PrintfTests() {
        // Multiple string arguments before variadic args
        // errorf("WARNING", "foobar")            // OK
        // errorf("INFO", "s=%s, n=%d", "foo", 1) // OK
-       // errorf("ERROR", "%d")                  // no error "errorf format %d reads arg #1, but call has only 0 args"
+       // errorf("ERROR", "%d")                  // no error "errorf format %d reads arg #1, but call has 0 args"
 
        // Printf from external package
        // externalprintf.Printf("%d", 42) // OK
@@ -248,7 +248,7 @@ func PrintfTests() {
        // level := 123
        // externalprintf.Logf(level, "%d", 42)                        // OK
        // externalprintf.Errorf(level, level, "foo %q bar", "foobar") // OK
-       // externalprintf.Logf(level, "%d")                            // no error "Logf format %d reads arg #1, but call has only 0 args"
+       // externalprintf.Logf(level, "%d")                            // no error "Logf format %d reads arg #1, but call has 0 args"
        // var formatStr = "%s %s"
        // externalprintf.Sprintf(formatStr, "a", "b")     // OK
        // externalprintf.Logf(level, formatStr, "a", "b") // OK
@@ -269,7 +269,7 @@ func PrintfTests() {
        Printf("%d %[0]d %d %[2]d x", 1, 2, 3, 4)             // ERROR "Printf format has invalid argument index \[0\]"
        Printf("%d %[3]d %d %[-2]d x", 1, 2, 3, 4)            // ERROR "Printf format has invalid argument index \[-2\]"
        Printf("%d %[3]d %d %[2234234234234]d x", 1, 2, 3, 4) // ERROR "Printf format has invalid argument index \[2234234234234\]"
-       Printf("%d %[3]d %-10d %[2]d x", 1, 2, 3)             // ERROR "Printf format %-10d reads arg #4, but call has only 3 args"
+       Printf("%d %[3]d %-10d %[2]d x", 1, 2, 3)             // ERROR "Printf format %-10d reads arg #4, but call has 3 args"
        Printf("%[1][3]d x", 1, 2)                            // ERROR "Printf format %\[1\]\[ has unknown verb \["
        Printf("%[1]d x", 1, 2)                               // OK
        Printf("%d %[3]d %d %[2]d x", 1, 2, 3, 4, 5)          // OK