reporter

package
v0.68.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BitBucketDescription = "pint is a Prometheus rule linter/validator.\n" +
		"It will inspect all Prometheus recording and alerting rules for problems that could prevent these from working correctly.\n" +
		"Checks can be either offline (static checks using only rule definition) or online (validate rule against live Prometheus server)."
)

Variables

This section is empty.

Functions

func Submit added in v0.59.0

func Submit(ctx context.Context, s Summary, c Commenter) error

Types

type BitBucketAnnotation

type BitBucketAnnotation struct {
	Path     string `json:"path"`
	Message  string `json:"message"`
	Severity string `json:"severity"`
	Type     string `json:"type"`
	Link     string `json:"link"`
	Line     int    `json:"line"`
}

type BitBucketAnnotations

type BitBucketAnnotations struct {
	Annotations []BitBucketAnnotation `json:"annotations"`
}

type BitBucketCommentAnchor added in v0.49.0

type BitBucketCommentAnchor struct {
	LineType string `json:"lineType"`
	DiffType string `json:"diffType"`
	Path     string `json:"path"`
	Line     int    `json:"line"`
	Orphaned bool   `json:"orphaned"`
}

type BitBucketCommentAuthor added in v0.49.0

type BitBucketCommentAuthor struct {
	Name string `json:"name"`
}

type BitBucketCommentSeverityUpdate added in v0.51.0

type BitBucketCommentSeverityUpdate struct {
	Severity string `json:"severity"`
	Version  int    `json:"version"`
}

type BitBucketCommentStateUpdate added in v0.51.0

type BitBucketCommentStateUpdate struct {
	State   string `json:"state"`
	Version int    `json:"version"`
}

type BitBucketDiffHunk added in v0.49.0

type BitBucketDiffHunk struct {
	Segments []BitBucketDiffSegment `json:"segments"`
}

type BitBucketDiffLine added in v0.49.0

type BitBucketDiffLine struct {
	Source      int `json:"source"`
	Destination int `json:"destination"`
}

type BitBucketDiffSegment added in v0.49.0

type BitBucketDiffSegment struct {
	Type  string              `json:"type"`
	Lines []BitBucketDiffLine `json:"lines"`
}

type BitBucketFileDiff added in v0.49.0

type BitBucketFileDiff struct {
	Hunks []BitBucketDiffHunk `json:"hunks"`
}

type BitBucketFileDiffs added in v0.49.0

type BitBucketFileDiffs struct {
	Diffs []BitBucketFileDiff `json:"diffs"`
}

type BitBucketPath added in v0.49.0

type BitBucketPath struct {
	ToString string `json:"toString"`
}

type BitBucketPendingComment added in v0.49.0

type BitBucketPendingComment struct {
	Text     string                        `json:"text"`
	Severity string                        `json:"severity"`
	Anchor   BitBucketPendingCommentAnchor `json:"anchor"`
}

type BitBucketPendingCommentAnchor added in v0.49.0

type BitBucketPendingCommentAnchor struct {
	Path     string `json:"path,omitempty"`
	LineType string `json:"lineType,omitempty"`
	FileType string `json:"fileType,omitempty"`
	DiffType string `json:"diffType"`
	Line     int    `json:"line,omitempty"`
}

type BitBucketPullRequest added in v0.49.0

type BitBucketPullRequest struct {
	FromRef BitBucketRef `json:"fromRef"`
	ToRef   BitBucketRef `json:"toRef"`
	ID      int          `json:"id"`
	Open    bool         `json:"open"`
}

type BitBucketPullRequestActivities added in v0.49.0

type BitBucketPullRequestActivities struct {
	Values        []BitBucketPullRequestActivity `json:"values"`
	Start         int                            `json:"start"`
	NextPageStart int                            `json:"nextPageStart"`
	IsLastPage    bool                           `json:"isLastPage"`
}

type BitBucketPullRequestActivity added in v0.49.0

type BitBucketPullRequestActivity struct {
	Action        string                      `json:"action"`
	CommentAction string                      `json:"commentAction"`
	CommentAnchor BitBucketCommentAnchor      `json:"commentAnchor"`
	Comment       BitBucketPullRequestComment `json:"comment"`
}

type BitBucketPullRequestChange added in v0.49.0

type BitBucketPullRequestChange struct {
	Path BitBucketPath `json:"path"`
}

type BitBucketPullRequestChanges added in v0.49.0

type BitBucketPullRequestChanges struct {
	Values        []BitBucketPullRequestChange `json:"values"`
	Start         int                          `json:"start"`
	NextPageStart int                          `json:"nextPageStart"`
	IsLastPage    bool                         `json:"isLastPage"`
}

type BitBucketPullRequestComment added in v0.49.0

type BitBucketPullRequestComment struct {
	State    string                        `json:"state"`
	Author   BitBucketCommentAuthor        `json:"author"`
	Text     string                        `json:"text"`
	Severity string                        `json:"severity"`
	Comments []BitBucketPullRequestComment `json:"comments"`
	ID       int                           `json:"id"`
	Version  int                           `json:"version"`
	Resolved bool                          `json:"threadResolved"`
}

type BitBucketPullRequests added in v0.49.0

type BitBucketPullRequests struct {
	Values        []BitBucketPullRequest `json:"values"`
	Start         int                    `json:"start"`
	NextPageStart int                    `json:"nextPageStart"`
	IsLastPage    bool                   `json:"isLastPage"`
}

type BitBucketRef added in v0.49.0

type BitBucketRef struct {
	ID     string `json:"id"`
	Commit string `json:"latestCommit"`
}

type BitBucketReport

type BitBucketReport struct {
	Reporter string                `json:"reporter"`
	Title    string                `json:"title"`
	Result   string                `json:"result"`
	Details  string                `json:"details"`
	Link     string                `json:"link"`
	Data     []BitBucketReportData `json:"data"`
}

type BitBucketReportData added in v0.27.0

type BitBucketReportData struct {
	Value any      `json:"value"`
	Title string   `json:"title"`
	Type  DataType `json:"type"`
}

type BitBucketReporter

type BitBucketReporter struct {
	// contains filtered or unexported fields
}

BitBucketReporter send linter results to BitBucket using https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-code-insights-rest.html

func NewBitBucketReporter

func NewBitBucketReporter(version, uri string, timeout time.Duration, token, project, repo string, maxComments int, gitCmd git.CommandRunner) BitBucketReporter

func (BitBucketReporter) Submit

func (bb BitBucketReporter) Submit(summary Summary) (err error)

type CheckStyleReporter added in v0.67.0

type CheckStyleReporter struct {
	// contains filtered or unexported fields
}

func NewCheckStyleReporter added in v0.67.0

func NewCheckStyleReporter(output io.Writer) CheckStyleReporter

func (CheckStyleReporter) Submit added in v0.67.0

func (cs CheckStyleReporter) Submit(summary Summary) error

type CommentReporter added in v0.63.0

type CommentReporter struct {
	// contains filtered or unexported fields
}

func NewCommentReporter added in v0.63.0

func NewCommentReporter(c Commenter) CommentReporter

func (CommentReporter) Submit added in v0.63.0

func (cr CommentReporter) Submit(summary Summary) (err error)

type Commenter added in v0.59.0

type Commenter interface {
	Describe() string
	Destinations(context.Context) ([]any, error)
	Summary(context.Context, any, Summary, []error) error
	List(context.Context, any) ([]ExistingComment, error)
	Create(context.Context, any, PendingComment) error
	Delete(context.Context, any, ExistingComment) error
	CanCreate(int) bool
	CanDelete(ExistingComment) bool
	IsEqual(any, ExistingComment, PendingComment) bool
}

type ConsoleReporter

type ConsoleReporter struct {
	// contains filtered or unexported fields
}

func NewConsoleReporter

func NewConsoleReporter(output io.Writer, minSeverity checks.Severity) ConsoleReporter

func (ConsoleReporter) Submit

func (cr ConsoleReporter) Submit(summary Summary) (err error)

type DataType added in v0.27.0

type DataType string
const (
	BooleanType    DataType = "BOOLEAN"
	DateType       DataType = "DATA"
	DurationType   DataType = "DURATION"
	LinkType       DataType = "LINK"
	NumberType     DataType = "NUMBER"
	PercentageType DataType = "PERCENTAGE"
	TextType       DataType = "TEXT"
)

type ExistingComment added in v0.63.0

type ExistingComment struct {
	// contains filtered or unexported fields
}

type GitLabReporter added in v0.59.0

type GitLabReporter struct {
	// contains filtered or unexported fields
}

func NewGitLabReporter added in v0.59.0

func NewGitLabReporter(version, branch, uri string, timeout time.Duration, token string, project, maxComments int) (_ GitLabReporter, err error)

func (GitLabReporter) CanCreate added in v0.59.0

func (gl GitLabReporter) CanCreate(done int) bool

func (GitLabReporter) CanDelete added in v0.63.0

func (gl GitLabReporter) CanDelete(ExistingComment) bool

func (GitLabReporter) Create added in v0.59.0

func (gl GitLabReporter) Create(ctx context.Context, dst any, comment PendingComment) error

func (GitLabReporter) Delete added in v0.59.0

func (gl GitLabReporter) Delete(ctx context.Context, dst any, comment ExistingComment) error

func (GitLabReporter) Describe added in v0.59.0

func (gl GitLabReporter) Describe() string

func (GitLabReporter) Destinations added in v0.59.0

func (gl GitLabReporter) Destinations(ctx context.Context) ([]any, error)

func (GitLabReporter) IsEqual added in v0.59.0

func (gl GitLabReporter) IsEqual(_ any, existing ExistingComment, pending PendingComment) bool

func (GitLabReporter) List added in v0.59.0

func (gl GitLabReporter) List(ctx context.Context, dst any) ([]ExistingComment, error)

func (GitLabReporter) Summary added in v0.59.0

func (gl GitLabReporter) Summary(ctx context.Context, dst any, s Summary, errs []error) (err error)

type GithubReporter

type GithubReporter struct {
	// contains filtered or unexported fields
}

func NewGithubReporter

func NewGithubReporter(version, baseURL, uploadURL string, timeout time.Duration, token, owner, repo string, prNum, maxComments int, headCommit string) (_ GithubReporter, err error)

NewGithubReporter creates a new GitHub reporter that reports problems via comments on a given pull request number (integer).

func (GithubReporter) CanCreate added in v0.63.0

func (gr GithubReporter) CanCreate(done int) bool

func (GithubReporter) CanDelete added in v0.63.0

func (gr GithubReporter) CanDelete(ExistingComment) bool

func (GithubReporter) Create added in v0.63.0

func (gr GithubReporter) Create(ctx context.Context, dst any, p PendingComment) error

func (GithubReporter) Delete added in v0.63.0

func (GithubReporter) Describe added in v0.63.0

func (gr GithubReporter) Describe() string

func (GithubReporter) Destinations added in v0.63.0

func (gr GithubReporter) Destinations(ctx context.Context) (_ []any, err error)

func (GithubReporter) IsEqual added in v0.63.0

func (gr GithubReporter) IsEqual(dst any, existing ExistingComment, pending PendingComment) bool

func (GithubReporter) List added in v0.63.0

func (gr GithubReporter) List(ctx context.Context, _ any) ([]ExistingComment, error)

func (GithubReporter) Summary added in v0.63.0

func (gr GithubReporter) Summary(ctx context.Context, _ any, s Summary, errs []error) error

type JSONReport added in v0.67.0

type JSONReport struct {
	Path     string `json:"path"`
	Owner    string `json:"owner,omitempty"`
	Reporter string `json:"reporter"`
	Problem  string `json:"problem"`
	Details  string `json:"details,omitempty"`
	Severity string `json:"severity"`
	Lines    []int  `json:"lines"`
}

type JSONReporter added in v0.67.0

type JSONReporter struct {
	// contains filtered or unexported fields
}

func NewJSONReporter added in v0.67.0

func NewJSONReporter(output io.Writer) JSONReporter

func (JSONReporter) Submit added in v0.67.0

func (jr JSONReporter) Submit(summary Summary) (err error)

type PendingComment added in v0.63.0

type PendingComment struct {
	// contains filtered or unexported fields
}

type Report

type Report struct {
	Path          discovery.Path
	Owner         string
	ModifiedLines []int
	Rule          parser.Rule
	Problem       checks.Problem
}

func (Report) MarshalXML added in v0.67.0

func (r Report) MarshalXML(e *xml.Encoder, _ xml.StartElement) (err error)

type Reporter

type Reporter interface {
	Submit(Summary) error
}

type Summary

type Summary struct {
	OfflineChecks  int64
	OnlineChecks   int64
	Duration       time.Duration
	TotalEntries   int
	CheckedEntries int64
	// contains filtered or unexported fields
}

func NewSummary added in v0.27.0

func NewSummary(reports []Report) Summary

func (Summary) CountBySeverity

func (s Summary) CountBySeverity() map[checks.Severity]int

func (Summary) HasFatalProblems

func (s Summary) HasFatalProblems() bool

func (*Summary) Report added in v0.27.0

func (s *Summary) Report(reps ...Report)

func (Summary) Reports

func (s Summary) Reports() (reports []Report)

func (*Summary) SortReports added in v0.49.0

func (s *Summary) SortReports()

type TeamCityReporter added in v0.49.0

type TeamCityReporter struct {
	// contains filtered or unexported fields
}

func NewTeamCityReporter added in v0.49.0

func NewTeamCityReporter(output io.Writer) TeamCityReporter

func (TeamCityReporter) Submit added in v0.49.0

func (tc TeamCityReporter) Submit(summary Summary) error

Jump to

Keyboard shortcuts

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