review

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2019 License: MIT Imports: 6 Imported by: 0

README

go-review

Publish reports from different Go linters as gerrit reviews

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func LinesToReviewComments

func LinesToReviewComments(r io.Reader) (comments map[string][]gerrit.CommentInput, err error)

LinesToReviewComments reads linter reports and converts those to Gerrit Review Comments. Key in returned map is file name and value all associated problems as comments.

Example
// Mock Gerrit server
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
	data, _ := ioutil.ReadAll(r.Body)
	fmt.Printf("%s", data)
	fmt.Fprint(w, ")]}\n{}")
}))
defer s.Close()

input := strings.NewReader(`file_1.go:1:2: some problem`)
comments, err := review.LinesToReviewComments(input)
if err != nil {
	if err == review.ErrNoProblemsFound {
		return
	}
	log.Fatal(err)
}

r := gerrit.ReviewInput{
	Message:  "go-review",
	Comments: comments,
}

c := gerrit.NewClient(s.URL, gerrit.NoAuth)
if err := c.SetReview(context.Background(), "some-change-id", "some-revision", r); err != nil {
	log.Fatal(err)
}

// {
//   "message": "go-review",
//   "comments": {
//     "file_1.go": [
//       {
//         "line": 1,
//         "message": "some problem"
//       }
//     ]
//   }
// }
Output:

Types

type ErrorString

type ErrorString string
const (
	ErrNoProblemsFound ErrorString = "no problems to convert into review comments"
	ErrSplitLine       ErrorString = "failed to split line to location and description"
	ErrSplitLocation   ErrorString = "failed split location to filename and position"
)

func (ErrorString) Error

func (e ErrorString) Error() string

type ParseError

type ParseError struct {
	LineNumber int
	Err        error
}

func (*ParseError) Error

func (e *ParseError) Error() string

type Position

type Position struct {
	Line   int
	Column int
}

type Problem

type Problem struct {
	FileName    string
	Description string
	Position
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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