Documentation
¶
Overview ¶
Package cli implements the Telescope command-line interface using cobra.
Index ¶
- func Execute()
- func GeneratePRComment(report *LintReport, repo, headRef string) []string
- func SaveBaseline(allDiags []fileDiagnostics) error
- type Baseline
- type BaselineComparison
- type BreakingChangeFile
- type DiagFingerprint
- type FileDetail
- type GitHubClient
- func (c *GitHubClient) CreateReview(prNumber int, commitSHA, body string, comments []reviewComment) error
- func (c *GitHubClient) DeleteComment(commentID int64) error
- func (c *GitHubClient) ListComments(prNumber int) ([]ghComment, error)
- func (c *GitHubClient) ListPRFiles(prNumber int) ([]prFile, error)
- func (c *GitHubClient) PostComment(prNumber int, body string) error
- func (c *GitHubClient) UpdateComment(commentID int64, body string) error
- func (c *GitHubClient) UpsertComments(prNumber int, bodies []string) error
- type LintReport
- type ScopeMetadata
- type SeverityCounts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GeneratePRComment ¶
func GeneratePRComment(report *LintReport, repo, headRef string) []string
GeneratePRComment creates markdown comment bodies from a lint report, grouped by rule with clickable GitHub links. It returns one or more chunks under githubMaxIssueCommentBytes, splitting at rule-group boundaries and splitting large single-rule tables by row.
func SaveBaseline ¶
func SaveBaseline(allDiags []fileDiagnostics) error
SaveBaseline writes the current diagnostics as a baseline file.
Types ¶
type Baseline ¶
type Baseline struct {
Version string `json:"version"`
Diagnostics map[string][]DiagFingerprint `json:"diagnostics"` // file → fingerprints
}
Baseline stores fingerprinted diagnostics for comparison.
type BaselineComparison ¶
type BaselineComparison struct {
BaselineCount int
CurrentCount int
NewCount int
FixedCount int
NewDiags []fileDiagnostics // only new diagnostics
}
BaselineComparison holds the result of comparing current diagnostics against a baseline.
func CompareBaseline ¶
func CompareBaseline(baseline *Baseline, current []fileDiagnostics) BaselineComparison
CompareBaseline compares current diagnostics against a saved baseline.
type BreakingChangeFile ¶
type BreakingChangeFile struct {
Path string `json:"path"`
TotalChanges int `json:"totalChanges"`
TotalBreakingChanges int `json:"totalBreakingChanges"`
SkipReason string `json:"skipReason,omitempty"`
}
BreakingChangeFile summarizes semantic diff vs the CI base ref for one file.
type DiagFingerprint ¶
type DiagFingerprint struct {
RuleID string `json:"ruleId"`
Line uint32 `json:"line"`
Hash string `json:"hash"` // sha256 of message
}
DiagFingerprint uniquely identifies a diagnostic for baseline comparison.
type FileDetail ¶
type FileDetail struct {
Path string `json:"path"`
Count int `json:"count"`
Errors int `json:"errors"`
Warnings int `json:"warnings"`
}
FileDetail provides per-file diagnostic breakdown for reports.
type GitHubClient ¶
type GitHubClient struct {
// contains filtered or unexported fields
}
GitHubClient posts comments and reviews to GitHub PRs.
func NewGitHubClient ¶
func NewGitHubClient() (*GitHubClient, error)
NewGitHubClient creates a client from environment variables.
func (*GitHubClient) CreateReview ¶
func (c *GitHubClient) CreateReview(prNumber int, commitSHA, body string, comments []reviewComment) error
CreateReview posts a pull request review with inline comments.
func (*GitHubClient) DeleteComment ¶
func (c *GitHubClient) DeleteComment(commentID int64) error
DeleteComment deletes an issue comment by ID.
func (*GitHubClient) ListComments ¶
func (c *GitHubClient) ListComments(prNumber int) ([]ghComment, error)
ListComments retrieves comments on a PR, following pagination up to 5 pages.
func (*GitHubClient) ListPRFiles ¶
func (c *GitHubClient) ListPRFiles(prNumber int) ([]prFile, error)
ListPRFiles retrieves files changed in a PR with pagination.
func (*GitHubClient) PostComment ¶
func (c *GitHubClient) PostComment(prNumber int, body string) error
PostComment posts a comment on a PR.
func (*GitHubClient) UpdateComment ¶
func (c *GitHubClient) UpdateComment(commentID int64, body string) error
UpdateComment updates an existing comment by ID.
func (*GitHubClient) UpsertComments ¶
func (c *GitHubClient) UpsertComments(prNumber int, bodies []string) error
UpsertComments creates or updates Telescope comments on a PR. Each element of bodies is one chunk (e.g. from GeneratePRComment). Existing comments with the same marker index are updated; extra chunks are created; leftover comments (when chunks shrink) are deleted.
type LintReport ¶
type LintReport struct {
Workspace string `json:"workspace"`
RepoRoot string `json:"repoRoot,omitempty"`
GeneratedAt string `json:"generatedAt"`
DiagnosticCount int `json:"diagnosticCount"`
Files []fileDiagnostics `json:"files"`
Counts SeverityCounts `json:"counts"`
ByFile map[string]int `json:"byFile"`
ByRule map[string]int `json:"byRule"`
RuleDocs map[string]string `json:"ruleDocs,omitempty"`
FileDetails []FileDetail `json:"fileDetails"`
Scope *ScopeMetadata `json:"scope,omitempty"`
BreakingChanges []BreakingChangeFile `json:"breakingChanges,omitempty"`
}
LintReport is the structured output written by --report-json.
type ScopeMetadata ¶
type ScopeMetadata struct {
Mode string `json:"mode,omitempty"`
ChangedFileCount int `json:"changedFileCount,omitempty"`
ImpactedFileCount int `json:"impactedFileCount,omitempty"`
AnalyzedFileCount int `json:"analyzedFileCount,omitempty"`
FallbackReason string `json:"fallbackReason,omitempty"`
}
ScopeMetadata describes how the CI run selected files for analysis.