github.com/Johnny2210/revive@v1.0.8-0.20210625134200-febf37ccd0f5/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 interaface
    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 token.Pos, end token.Pos, file *File) FailurePosition {
    27  	return FailurePosition{
    28  		Start: file.ToPosition(start),
    29  		End:   file.ToPosition(end),
    30  	}
    31  }