forked from mgechev/revive
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update error-strings rule (mgechev#608)
- Loading branch information
Showing
3 changed files
with
110 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package test | ||
|
||
import ( | ||
"github.com/mgechev/revive/rule" | ||
"testing" | ||
) | ||
|
||
func TestErrorStrings(t *testing.T) { | ||
testRule(t, "error-strings-pkg-errors", &rule.ErrorStringsRule{}) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Package foo ... | ||
package foo | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
) | ||
|
||
// Check for the error strings themselves. | ||
|
||
func errorsStrings(x int) error { | ||
var err error | ||
err = errors.Wrap(err, "This %d is too low") // MATCH /error strings should not be capitalized or end with punctuation or a newline/ | ||
err = errors.New("This %d is too low") // MATCH /error strings should not be capitalized or end with punctuation or a newline/ | ||
err = errors.Wrapf(err, "This %d is too low", x) // MATCH /error strings should not be capitalized or end with punctuation or a newline/ | ||
err = errors.WithMessage(err, "This %d is too low") // MATCH /error strings should not be capitalized or end with punctuation or a newline/ | ||
err = errors.WithMessagef(err, "This %d is too low", x) // MATCH /error strings should not be capitalized or end with punctuation or a newline/ | ||
return err | ||
} |