2018-01-24 15:44:03 -08:00
|
|
|
package lint
|
2017-08-27 16:57:16 -07:00
|
|
|
|
|
|
|
import (
|
|
|
|
"go/token"
|
|
|
|
)
|
|
|
|
|
2017-09-01 18:36:47 -07:00
|
|
|
// DisabledInterval contains a single disabled interval and the associated rule name.
|
|
|
|
type DisabledInterval struct {
|
|
|
|
From token.Position
|
|
|
|
To token.Position
|
|
|
|
RuleName string
|
2017-08-27 16:57:16 -07:00
|
|
|
}
|
|
|
|
|
2017-11-19 17:18:16 -08:00
|
|
|
// Rule defines an abstract rule interaface
|
2017-08-27 16:57:16 -07:00
|
|
|
type Rule interface {
|
2017-11-19 17:18:16 -08:00
|
|
|
Name() string
|
2018-01-21 18:04:41 -08:00
|
|
|
Apply(*File, Arguments) []Failure
|
2017-11-19 17:18:16 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// AbstractRule defines an abstract rule.
|
|
|
|
type AbstractRule struct {
|
2017-11-19 17:58:28 -08:00
|
|
|
Failures []Failure
|
2017-11-19 17:18:16 -08:00
|
|
|
}
|
|
|
|
|
2017-11-19 17:58:28 -08:00
|
|
|
// ToFailurePosition returns the failure position.
|
2018-01-21 18:04:41 -08:00
|
|
|
func ToFailurePosition(start token.Pos, end token.Pos, file *File) FailurePosition {
|
2017-11-19 17:18:16 -08:00
|
|
|
return FailurePosition{
|
2017-11-19 17:35:56 -08:00
|
|
|
Start: file.ToPosition(start),
|
|
|
|
End: file.ToPosition(end),
|
2017-11-19 17:18:16 -08:00
|
|
|
}
|
2017-08-27 16:57:16 -07:00
|
|
|
}
|