diff options
Diffstat (limited to 'tools/golangci-lint/gitaly/testdata/src/quote/quote_test.go')
-rw-r--r-- | tools/golangci-lint/gitaly/testdata/src/quote/quote_test.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/golangci-lint/gitaly/testdata/src/quote/quote_test.go b/tools/golangci-lint/gitaly/testdata/src/quote/quote_test.go new file mode 100644 index 000000000..d0e832c59 --- /dev/null +++ b/tools/golangci-lint/gitaly/testdata/src/quote/quote_test.go @@ -0,0 +1,27 @@ +package quote + +import "fmt" + +// This file is the test fixture for Gitaly linters + +func quoteOkay() { + fmt.Printf("hello world: %q", "today is a good day") + fmt.Printf("hello world: %d", 123) + fmt.Printf("%s something", "hello") + fmt.Printf("hello world: %s", "this is good") + fmt.Printf("hello world: %s something", "this is good") +} + +func quoteNotOkay() { + fmt.Printf("hello world: '%s'", "today is a good day") // want "wrapping %s verb with quotes is not encouraged, please use %q instead" + fmt.Printf(`hello world: "%s"`, "today is a good day") // want "wrapping %s verb with quotes is not encouraged, please use %q instead" + fmt.Printf(`hello world: "%s"`, "today is a good day") // want "wrapping %s verb with quotes is not encouraged, please use %q instead" + str := `so is +tomorrow` + fmt.Printf("hello world: '%s'", str) // want "wrapping %s verb with quotes is not encouraged, please use %q instead" + fmt.Printf(`hello world: "%s"`, str) // want "wrapping %s verb with quotes is not encouraged, please use %q instead" + fmt.Printf(`hello world: "%s"`, str) // want "wrapping %s verb with quotes is not encouraged, please use %q instead" + + fmt.Printf("hello world:%s %s '%s'", "today", "is a", "good day") // want "wrapping %s verb with quotes is not encouraged, please use %q instead" + fmt.Printf("hello world: %d '%s'", 123, "today is a good day") // want "wrapping %s verb with quotes is not encouraged, please use %q instead" +} |