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

32 lines
666 B
Go
Raw Normal View History

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
}
2017-11-20 03:18:16 +02:00
// Rule defines an abstract rule interaface
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.
2018-01-22 04:04:41 +02:00
func ToFailurePosition(start token.Pos, 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
}