Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GitPatch ¶
GitPatch returns a patch from a git repository, if no git repository was was found and no errors occurred, nil is returned, else an error is returned revisionFrom and revisionTo defines the git diff parameters, if left blank and there are unstaged changes or untracked files, only those will be returned else only check changes since HEAD~. If revisionFrom is set but revisionTo is not, untracked files will be included, to exclude untracked files set revisionTo to HEAD~. It's incorrect to specify revisionTo without a revisionFrom.
Types ¶
type Checker ¶
type Checker struct { // Patch file (unified) to read to detect lines being changed, if nil revgrep // will attempt to detect the VCS and generate an appropriate patch. Auto // detection will search for uncommitted changes first, if none found, will // generate a patch from last committed change. File paths within patches // must be relative to current working directory. Patch io.Reader // NewFiles is a list of file names (with absolute paths) where the entire // contents of the file is new. NewFiles []string // Debug sets the debug writer for additional output. Debug io.Writer // RevisionFrom check revision starting at, leave blank for auto detection // ignored if patch is set. RevisionFrom string // RevisionTo checks revision finishing at, leave blank for auto detection // ignored if patch is set. RevisionTo string // Regexp to match path, line number, optional column number, and message. Regexp string // AbsPath is used to make an absolute path of an issue's filename to be // relative in order to match patch file. If not set, current working // directory is used. AbsPath string }
Checker provides APIs to filter static analysis tools to specific commits, such as showing only issues since last commit.
func (Checker) Check ¶
Check scans reader and writes any lines to writer that have been added in Checker.Patch.
Returns issues written to writer when no error occurs.
If no VCS could be found or other VCS errors occur, all issues are written to writer and an error is returned.
File paths in reader must be relative to current working directory or absolute.
type Issue ¶
type Issue struct { // File is the name of the file as it appeared from the patch. File string // LineNo is the line number of the file. LineNo int // ColNo is the column number or 0 if none could be parsed. ColNo int // HunkPos is position from file's first @@, for new files this will be the // line number. // // See also: https://developer.github.com/v3/pulls/comments/#create-a-comment HunkPos int // Issue text as it appeared from the tool. Issue string // Message is the issue without file name, line number and column number. Message string }
Issue contains metadata about an issue found.