mirror of
https://github.com/mgechev/revive.git
synced 2025-07-07 00:35:38 +02:00
Add rule
This commit is contained in:
@ -53,14 +53,14 @@ func stripAnnotations(code string) string {
|
||||
}
|
||||
|
||||
// AssertSuccess checks if given rule runs correctly with no failures.
|
||||
func AssertSuccess(t *testing.T, code string, testingRule rule.Rule, args rule.Arguments) {
|
||||
func AssertSuccessWithName(t *testing.T, code, name string, testingRule rule.Rule, args rule.Arguments) {
|
||||
annotations := extractFailures(code)
|
||||
if annotations != nil {
|
||||
t.Errorf("There should be no failure annotations when verifying successful rule analysis")
|
||||
}
|
||||
|
||||
var fileSet token.FileSet
|
||||
file, err := file.New("testing.go", []byte(stripAnnotations(code)), &fileSet)
|
||||
file, err := file.New(name, []byte(stripAnnotations(code)), &fileSet)
|
||||
if err != nil {
|
||||
t.Errorf("Cannot parse testing file: %s", err.Error())
|
||||
}
|
||||
@ -78,6 +78,11 @@ func AssertSuccess(t *testing.T, code string, testingRule rule.Rule, args rule.A
|
||||
}
|
||||
}
|
||||
|
||||
// AssertSuccess checks if given rule runs correctly with no failures.
|
||||
func AssertSuccess(t *testing.T, code string, testingRule rule.Rule, args rule.Arguments) {
|
||||
AssertSuccessWithName(t, code, "testing.go", testingRule, args)
|
||||
}
|
||||
|
||||
// AssertFailures checks if given rule runs correctly with failures.
|
||||
func AssertFailures(t *testing.T, code string, testingRule rule.Rule, args rule.Arguments) {
|
||||
annotations := extractFailures(code)
|
||||
|
Reference in New Issue
Block a user