Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to customize user functions in rule
error-strings
(#703)
* Allow to customize user functions in rule `error-strings` * Rollback the Available Rules table format in README * adds memoization of the rule's configuration Co-authored-by: chavacava <salvadorcavadini+github@gmail.com>
- Loading branch information
Showing
4 changed files
with
67 additions
and
8 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
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,15 @@ | ||
package test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/mgechev/revive/lint" | ||
"github.com/mgechev/revive/rule" | ||
) | ||
|
||
func TestErrorStringsWithCustomFunctions(t *testing.T) { | ||
args := []interface{}{"pkgErrors.Wrap"} | ||
testRule(t, "error-strings-with-custom-functions", &rule.ErrorStringsRule{}, &lint.RuleConfig{ | ||
Arguments: args, | ||
}) | ||
} |
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,12 @@ | ||
package fixtures | ||
|
||
import ( | ||
pkgErrors "github.com/pkg/errors" | ||
) | ||
|
||
// Check for the error strings themselves. | ||
|
||
func errorsStrings(x int) error { | ||
var err error | ||
return pkgErrors.Wrap(err, "This %d is too low") // MATCH /error strings should not be capitalized or end with punctuation or a newline/ | ||
} |