github.com/Johnny2210/revive@v1.0.8-0.20210625134200-febf37ccd0f5/lint/failure.go (about)

     1  package lint
     2  
     3  import (
     4  	"go/ast"
     5  	"go/token"
     6  )
     7  
     8  const (
     9  	// SeverityWarning declares failures of type warning
    10  	SeverityWarning = "warning"
    11  	// SeverityError declares failures of type error.
    12  	SeverityError = "error"
    13  )
    14  
    15  // Severity is the type for the failure types.
    16  type Severity string
    17  
    18  // FailurePosition returns the failure position
    19  type FailurePosition struct {
    20  	Start token.Position
    21  	End   token.Position
    22  }
    23  
    24  // Failure defines a struct for a linting failure.
    25  type Failure struct {
    26  	Failure    string
    27  	RuleName   string
    28  	Category   string
    29  	Position   FailurePosition
    30  	Node       ast.Node `json:"-"`
    31  	Confidence float64
    32  	// For future use
    33  	ReplacementLine string
    34  }
    35  
    36  // GetFilename returns the filename.
    37  func (f *Failure) GetFilename() string {
    38  	return f.Position.Start.Filename
    39  }