diff --git a/analyzer/analyzer.go b/analyzer/analyzer.go index 0d32826..2cd4f30 100644 --- a/analyzer/analyzer.go +++ b/analyzer/analyzer.go @@ -473,10 +473,10 @@ func (n *perfSprint) run(pass *analysis.Pass) (interface{}, error) { d = &analysis.Diagnostic{ Pos: call.Pos(), End: call.End(), - Message: fn + " can be replaced with string addition", + Message: fn + " can be replaced with string concatenation", SuggestedFixes: []analysis.SuggestedFix{ { - Message: "Use string addition", + Message: "Use string concatenation", TextEdits: []analysis.TextEdit{{ Pos: call.Pos(), End: call.End(), diff --git a/analyzer/replacements_bench_test.go b/analyzer/replacements_bench_test.go index 54cb664..90e0472 100644 --- a/analyzer/replacements_bench_test.go +++ b/analyzer/replacements_bench_test.go @@ -225,7 +225,7 @@ func BenchmarkStringAdditionFormatting(b *testing.B) { b.ReportAllocs() }) - b.Run("string addition", func(b *testing.B) { + b.Run("string concatenation", func(b *testing.B) { for n := 0; n < b.N; n++ { _ = "Hello " + "world" } diff --git a/analyzer/testdata/src/p/p.go b/analyzer/testdata/src/p/p.go index be26c7c..2c12099 100644 --- a/analyzer/testdata/src/p/p.go +++ b/analyzer/testdata/src/p/p.go @@ -24,9 +24,9 @@ func positive() { fmt.Sprint(s) // want "fmt.Sprint can be replaced with just using the string" fmt.Errorf("hello") // want "fmt.Errorf can be replaced with errors.New" - fmt.Sprintf("Hello %s", s) // want "fmt.Sprintf can be replaced with string addition" - fmt.Sprintf("%s says Hello", s) // want "fmt.Sprintf can be replaced with string addition" - fmt.Sprintf("Hello says %[1]s", s) // want "fmt.Sprintf can be replaced with string addition" + fmt.Sprintf("Hello %s", s) // want "fmt.Sprintf can be replaced with string concatenation" + fmt.Sprintf("%s says Hello", s) // want "fmt.Sprintf can be replaced with string concatenation" + fmt.Sprintf("Hello says %[1]s", s) // want "fmt.Sprintf can be replaced with string concatenation" var err error fmt.Sprintf("%s", errSentinel) // want "fmt.Sprintf can be replaced with errSentinel.Error()" diff --git a/analyzer/testdata/src/p/p.go.golden b/analyzer/testdata/src/p/p.go.golden index 5c9d7e7..527d33b 100644 --- a/analyzer/testdata/src/p/p.go.golden +++ b/analyzer/testdata/src/p/p.go.golden @@ -26,9 +26,9 @@ func positive() { s // want "fmt.Sprint can be replaced with just using the string" errors.New("hello") // want "fmt.Errorf can be replaced with errors.New" - "Hello " + s // want "fmt.Sprintf can be replaced with string addition" - s + " says Hello" // want "fmt.Sprintf can be replaced with string addition" - "Hello says " + s // want "fmt.Sprintf can be replaced with string addition" + "Hello " + s // want "fmt.Sprintf can be replaced with string concatenation" + s + " says Hello" // want "fmt.Sprintf can be replaced with string concatenation" + "Hello says " + s // want "fmt.Sprintf can be replaced with string concatenation" var err error errSentinel.Error() // want "fmt.Sprintf can be replaced with errSentinel.Error()"