An escaped percent followed by the letter w ("%%w") is a literal, not a wrapping verb: a real unwrapped error in the same call must still be flagged.
(t *testing.T)
| 31 | // An escaped percent followed by the letter w ("%%w") is a literal, not a |
| 32 | // wrapping verb: a real unwrapped error in the same call must still be flagged. |
| 33 | func TestWrapErrorsFlagsEscapedPercentW(t *testing.T) { |
| 34 | t.Parallel() |
| 35 | src := `package p |
| 36 | import "fmt" |
| 37 | func f(err error) error { return fmt.Errorf("done 50%%w: %v", err) } |
| 38 | ` |
| 39 | offenses := coptest.RunTyped(t, WrapErrors, src) |
| 40 | require.Len(t, offenses, 1) |
| 41 | assert.Equal(t, "Lint/WrapErrors", offenses[0].CopName) |
| 42 | } |
| 43 | |
| 44 | func TestWrapErrorsIgnoresNonErrorArgs(t *testing.T) { |
| 45 | t.Parallel() |