github.com/songshiyun/revive@v1.1.5-0.20220323112655-f8433a19b3c5/lint/rule.go (about)

     1  package lint
     2  
     3  import (
     4  	"go/token"
     5  )
     6  
     7  // DisabledInterval contains a single disabled interval and the associated rule name.
     8  type DisabledInterval struct {
     9  	From     token.Position
    10  	To       token.Position
    11  	RuleName string
    12  }
    13  
    14  // Rule defines an abstract rule interface
    15  type Rule interface {
    16  	Name() string
    17  	Apply(*File, Arguments) []Failure
    18  }
    19  
    20  // AbstractRule defines an abstract rule.
    21  type AbstractRule struct {
    22  	Failures []Failure
    23  }
    24  
    25  // ToFailurePosition returns the failure position.
    26  func ToFailurePosition(start, end token.Pos, file *File) FailurePosition {
    27  	return FailurePosition{
    28  		Start: file.ToPosition(start),
    29  		End:   file.ToPosition(end),
    30  	}
    31  }