1
0
mirror of https://github.com/mgechev/revive.git synced 2025-01-10 03:17:11 +02:00
revive/rules/rule.go

50 lines
1006 B
Go
Raw Normal View History

2017-08-28 01:57:16 +02:00
package rules
import (
"go/token"
"github.com/mgechev/golinter/file"
)
const (
// FailureTypeWarning declares failures of type warning
FailureTypeWarning = "warning"
// FailureTypeError declares failures of type error.
FailureTypeError = "error"
)
// FailureType is the type for the failure types.
type FailureType string
// Failure defines a struct for a linting failure.
type Failure struct {
Failure string
Type FailureType
Position FailurePosition
file *file.File
}
// GetFilename returns the filename.
func (f *Failure) GetFilename() string {
return f.Position.Start.Filename
}
// FailurePosition returns the failure position
type FailurePosition struct {
Start token.Position
End token.Position
}
// RuleArguments is type used for the arguments of a rule.
type RuleArguments []string
type RuleConfig struct {
Name string
Arguments RuleArguments
}
// Rule defines an abstract rule.
type Rule interface {
Apply(file *file.File, args RuleArguments) []Failure
}