Documentation
¶
Overview ¶
Package report defines LintPal's validated, deterministic findings artifact.
Index ¶
- Constants
- Variables
- func BlockingCount(bundle Bundle) int
- func BundleBlocks(bundle Bundle) bool
- func MeetsGate(artifact Report, threshold Threshold) (bool, error)
- func RenderGitHubFinding(finding Finding) []byte
- func RenderGitHubResult(bundle Bundle, unanchoredIDs []string) ([]byte, error)
- func RenderMarkdown(bundle Bundle) []byte
- func Validate(report Report) error
- func WriteAndGate(writer io.Writer, artifact Report, format Format, threshold Threshold) error
- func WriteArtifact(path string, payload []byte) error
- func WriteJSON(writer io.Writer, artifact Report) error
- func WriteMarkdown(writer io.Writer, artifact Report) error
- type Bundle
- type Diagnostic
- type Evidence
- type Finding
- type Format
- type Report
- type Skip
- type Stats
- type Threshold
Constants ¶
const MaxBundleBytes = 64 << 20
const SchemaVersion = "v5"
Variables ¶
var ErrExport = errors.New("lint report export failed")
var ErrGate = errors.New("lint severity gate failed")
var ErrInvalidFormat = errors.New("invalid lint report format")
var ErrInvalidReport = errors.New("invalid lint report")
var ErrInvalidThreshold = errors.New("invalid lint severity threshold")
Functions ¶
func BlockingCount ¶ added in v0.4.0
func BundleBlocks ¶ added in v0.4.0
func RenderGitHubFinding ¶ added in v0.4.0
RenderGitHubFinding builds one deterministic inline body from validated finding fields. It does not add semantic analysis or remediation text.
func RenderGitHubResult ¶ added in v0.4.0
RenderGitHubResult builds the deterministic top-level GitHub feedback body. unanchoredIDs contains validated findings that the GitHub transport could not attach to a diff line. Unknown or duplicate IDs are rejected.
func RenderMarkdown ¶ added in v0.4.0
RenderMarkdown builds complete feedback from a validated findings bundle.
func Validate ¶
Validate checks the public artifact before it is rendered or gated. Exact changed-line provenance is checked by New, which has the Git work items.
func WriteAndGate ¶
func WriteArtifact ¶ added in v0.4.0
WriteArtifact replaces a report file only after the complete payload is synced.
Types ¶
type Bundle ¶ added in v0.4.0
type Bundle struct {
Version string `json:"version"`
ReviewID string `json:"review_id"`
BaseSHA string `json:"base_sha"`
HeadSHA string `json:"head_sha"`
MergeBaseSHA string `json:"merge_base_sha"`
Findings []Finding `json:"findings"`
Skips []Skip `json:"skips"`
Stats Stats `json:"stats"`
}
func BundleFromReport ¶ added in v0.4.0
BundleFromReport converts an internal report through its public v5 shape.
func ParseBundle ¶ added in v0.4.0
ParseBundle validates a shared findings v5 artifact before using its fields.
func ReadBundle ¶ added in v0.4.0
ReadBundle bounds a stored report before parsing it. Errors contain no report text.
type Diagnostic ¶
type Diagnostic struct {
RuleID string `json:"rule_id"`
WorkItemID string `json:"work_item_id"`
Severity rules.Severity `json:"severity"`
Path string `json:"path"`
Side git.Side `json:"side"`
StartLine int `json:"start_line"`
EndLine int `json:"end_line"`
Title string `json:"title"`
Message string `json:"message"`
Provider string `json:"provider"`
Model string `json:"model"`
Evidence Evidence `json:"evidence"`
}
type Finding ¶ added in v0.4.0
type Finding struct {
ID string `json:"id"`
ReviewID string `json:"review_id"`
Category string `json:"category"`
Severity string `json:"severity"`
Title string `json:"title"`
Message string `json:"message"`
Path string `json:"path"`
StartLine int `json:"start_line"`
EndLine int `json:"end_line"`
ChangedSpan struct {
Path string `json:"path"`
StartLine int `json:"start_line"`
EndLine int `json:"end_line"`
Side string `json:"side"`
} `json:"changed_span"`
Evidence struct {
Kind string `json:"kind"`
RuleID string `json:"rule_id"`
Anchor string `json:"anchor"`
} `json:"evidence"`
Decision struct {
Kind string `json:"kind"`
Value float64 `json:"value"`
} `json:"decision"`
Blocking bool `json:"blocking"`
Provider string `json:"provider"`
Model string `json:"model"`
WorkItemID string `json:"work_item_id"`
}
type Report ¶
type Report struct {
SchemaVersion string `json:"schema_version"`
BaseSHA string `json:"base_sha"`
HeadSHA string `json:"head_sha"`
MergeBaseSHA string `json:"merge_base_sha"`
Diagnostics []Diagnostic `json:"diagnostics"`
Skips []Skip `json:"skips"`
Stats Stats `json:"stats"`
// contains filtered or unexported fields
}
func New ¶
func New(result git.Result, decisions []rules.Decision, provider, model string, stats Stats, identitySalt ...string) (Report, error)
New checks every decision against the original changed-line work items.
func WithGate ¶ added in v0.4.0
WithGate binds the report's blocking flags to the selected CLI gate.
func (Report) MarshalJSON ¶ added in v0.4.0
type Skip ¶
type Skip struct {
OldPath string `json:"old_path,omitempty"`
NewPath string `json:"new_path,omitempty"`
Reason git.SkipReason `json:"reason"`
}