golangci-lint/pkg/result/issue.go

43 lines
585 B
Go
Raw Normal View History

package result
2018-05-08 11:54:30 +03:00
import "go/token"
type Range struct {
From, To int
}
type Issue struct {
FromLinter string
Text string
2018-05-08 11:54:30 +03:00
Pos token.Position
LineRange *Range `json:",omitempty"`
HunkPos int `json:",omitempty"`
}
2018-05-08 09:55:38 +03:00
func (i Issue) FilePath() string {
2018-05-08 11:54:30 +03:00
return i.Pos.Filename
2018-05-08 09:55:38 +03:00
}
func (i Issue) Line() int {
2018-05-08 11:54:30 +03:00
return i.Pos.Line
2018-05-08 09:55:38 +03:00
}
2018-05-08 11:54:30 +03:00
func (i Issue) GetLineRange() Range {
if i.LineRange == nil {
return Range{
From: i.Line(),
To: i.Line(),
}
}
2018-05-08 11:54:30 +03:00
if i.LineRange.From == 0 {
return Range{
From: i.Line(),
To: i.Line(),
}
}
2018-05-08 11:54:30 +03:00
return *i.LineRange
}