2018-01-25 01:44:03 +02:00
|
|
|
package lint
|
2017-08-28 01:57:16 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"go/token"
|
|
|
|
)
|
|
|
|
|
2017-09-02 03:36:47 +02: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-28 01:57:16 +02:00
|
|
|
}
|
|
|
|
|
2021-10-14 20:56:29 +02:00
|
|
|
// Rule defines an abstract rule interface
|
2017-08-28 01:57:16 +02:00
|
|
|
type Rule interface {
|
2017-11-20 03:18:16 +02:00
|
|
|
Name() string
|
2018-01-22 04:04:41 +02:00
|
|
|
Apply(*File, Arguments) []Failure
|
2017-11-20 03:18:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// AbstractRule defines an abstract rule.
|
|
|
|
type AbstractRule struct {
|
2017-11-20 03:58:28 +02:00
|
|
|
Failures []Failure
|
2017-11-20 03:18:16 +02:00
|
|
|
}
|
|
|
|
|
2017-11-20 03:58:28 +02:00
|
|
|
// ToFailurePosition returns the failure position.
|
2022-03-02 09:24:55 +02:00
|
|
|
func ToFailurePosition(start, end token.Pos, file *File) FailurePosition {
|
2017-11-20 03:18:16 +02:00
|
|
|
return FailurePosition{
|
2017-11-20 03:35:56 +02:00
|
|
|
Start: file.ToPosition(start),
|
|
|
|
End: file.ToPosition(end),
|
2017-11-20 03:18:16 +02:00
|
|
|
}
|
2017-08-28 01:57:16 +02:00
|
|
|
}
|