result

package
v0.18.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const MaxLineLength = 200

MaxLineLength is the max line length that this printer will show the source of the finding and the location within the line of the finding. Helps avoid consuming the console when minified files contain findings.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileResults

type FileResults struct {
	Filename string
	Results  []Result
}

FileResults contains all the Results for the file

func (FileResults) Len

func (fr FileResults) Len() int

Len is part of sort.Interface

func (FileResults) Less

func (fr FileResults) Less(i, j int) bool

Less is part of sort.Interface

func (*FileResults) String

func (fr *FileResults) String() string

func (FileResults) Swap

func (fr FileResults) Swap(i, j int)

Swap is part of sort.Interface

type LineResult

type LineResult struct {
	Rule    *rule.Rule
	Finding string
	// Line is the full string of the line, unless it's over MaxLintLength,
	// where Line will be an empty string
	Line          string
	StartPosition *token.Position
	EndPosition   *token.Position
}

LineResult contains data about the result of a broken rule

func NewLineResult

func NewLineResult(r *rule.Rule, finding, filename string, line, startColumn, endColumn int) LineResult

NewLineResult returns a LineResult based on the metadata from a finding

func (LineResult) GetEndPosition

func (r LineResult) GetEndPosition() *token.Position

GetEndPosition returns the start position for the Result

func (LineResult) GetLine

func (r LineResult) GetLine() string

GetLine returns the entire line for the LineResult

func (LineResult) GetRuleName

func (r LineResult) GetRuleName() string

GetRuleName returns the rule name for the Result

func (LineResult) GetSeverity

func (r LineResult) GetSeverity() rule.Severity

GetSeverity returns the rule severity for the Result

func (LineResult) GetStartPosition

func (r LineResult) GetStartPosition() *token.Position

GetStartPosition returns the start position for the Result

func (LineResult) MarshalJSON

func (r LineResult) MarshalJSON() ([]byte, error)

MarshalJSON override to include Reason in the json response

func (LineResult) Reason

func (r LineResult) Reason() string

Reason outputs the suggested alternatives for this rule

func (LineResult) String

func (r LineResult) String() string

type PathResult

type PathResult struct {
	LineResult
}

PathResult is a Result meant for showing findings in a file path

func MatchPath

func MatchPath(r *rule.Rule, path string) (rs []PathResult)

MatchPath matches the path against the rule. If it is a match, it will return a PathResult with the line/start column/end column all at 1

func MatchPathRules

func MatchPathRules(rules []*rule.Rule, path string) (rs []PathResult)

MatchPathRules will match the path against all the rules provided

func (PathResult) Reason

func (r PathResult) Reason() string

Reason is the reason for the PathResult finding. It is similar to Result.Reason, but makes it clear that the finding is with the file path and not a line in the file

type Result

type Result interface {
	GetSeverity() rule.Severity
	GetRuleName() string
	GetStartPosition() *token.Position
	GetEndPosition() *token.Position
	Reason() string
	String() string
	GetLine() string
}

Result is an interface for a finding of a rule

func FindResults

func FindResults(r *rule.Rule, filename, text string, line int) (rs []Result)

FindResults returns the results that match the rule for the given text. filename and line are only used for the Position

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL