Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeDiffPath ¶
NormalizeDiffPath return path normalized path from given path in diff with strip.
func NormalizePath ¶
NormalizePath return normalized path with workdir and relative path to project.
Types ¶
type DiffFilter ¶
type DiffFilter struct {
// contains filtered or unexported fields
}
DiffFilter filters lines by diff.
func NewDiffFilter ¶
NewDiffFilter creates a new DiffFilter.
func (*DiffFilter) DiffLine ¶
func (df *DiffFilter) DiffLine(path string, lnum int) *diff.Line
DiffLine returns diff data from given new path and lnum. Returns nil if not found.
func (*DiffFilter) ShouldReport ¶
ShouldReport returns true, if the given path should be reported depending on the filter Mode. It also optionally return diff file/line.
type FilteredDiagnostic ¶
type FilteredDiagnostic struct { Diagnostic *rdf.Diagnostic ShouldReport bool // false if the result is outside diff files. InDiffFile bool // true if the result is inside a diff hunk. // If it's a multiline result, both start and end must be in the same diff // hunk. InDiffContext bool // Similar to InDiffContext but for suggestion. True if first // suggestion is in diff context. FirstSuggestionInDiffContext bool // Source lines text of the diagnostic message's line-range. Key is line // number. If a suggestion range is broader than the diagnostic message's // line-range, suggestions' line-range are included too. It contains a whole // line even if the diagnostic range have column fields. // Optional. Currently available only when it's in diff context. SourceLines map[int]string OldPath string OldLine int }
FilteredDiagnostic represents Diagnostic with filtering info.
func FilterCheck ¶
func FilterCheck(results []*rdf.Diagnostic, diff []*diff.FileDiff, strip int, cwd string, mode Mode) []*FilteredDiagnostic
FilterCheck filters check results by diff. It doesn't drop check which is not in diff but set FilteredDiagnostic.ShouldReport field false.
type Mode ¶
type Mode int
Mode represents enumeration of available filter modes
const ( // ModeDefault represents default mode, which means users doesn't specify // filter-mode. The behavior can be changed depending on reporters/context // later if we want. Basically, it's same as ModeAdded because it's most safe // and basic mode for reporters implementation. ModeDefault Mode = iota // ModeAdded represents filtering by added/changed diff lines. ModeAdded // ModeDiffContext represents filtering by diff context. // i.e. changed lines +-N lines (e.g. N=3 for default git diff). ModeDiffContext // ModeFile represents filtering by changed files. ModeFile // ModeNoFilter doesn't filter out any results. ModeNoFilter )