Documentation
¶
Overview ¶
Package report provides a pluggable section registry for stringer report. Each section consumes metrics from collectors and renders a focused analysis.
Index ¶
- Constants
- Variables
- func ColorAssessment(val string) string
- func ColorRiskLevel(val string) string
- func ColorStability(val string) string
- func List() []string
- func Register(s Section)
- func RenderJSON(result *signal.ScanResult, repoPath string, collectorNames []string, ...) error
- func ResolveSections(filter []string) []string
- func SectionTitle(title string) string
- type Alignment
- type CollectorResultJSON
- type ColorFunc
- type Column
- type Recommendation
- type ReportJSON
- type Section
- type SectionJSON
- type SignalSummaryJSON
- type Table
Constants ¶
const ( SeverityHigh = "high" SeverityMedium = "medium" SeverityLow = "low" )
Severity levels for recommendations.
Variables ¶
var ErrMetricsNotAvailable = errors.New("metrics not available")
ErrMetricsNotAvailable indicates a section's required metrics are missing, typically because the corresponding collector was not run.
Functions ¶
func ColorAssessment ¶
ColorAssessment colors test coverage assessments.
func ColorRiskLevel ¶
ColorRiskLevel colors CRITICAL/WARNING/ok risk labels.
func ColorStability ¶
ColorStability colors stability labels.
func List ¶
func List() []string
List returns the names of all registered sections in registration order.
func Register ¶
func Register(s Section)
Register adds a section to the global registry. It panics if a section with the same name is already registered.
func RenderJSON ¶ added in v0.6.0
func RenderJSON(result *signal.ScanResult, repoPath string, collectorNames []string, sections []string, w interface{ Write([]byte) (int, error) }) error
RenderJSON writes the report as machine-readable JSON.
func ResolveSections ¶ added in v0.6.0
ResolveSections determines which sections to run without printing warnings. If filter is empty, all registered sections are used.
func SectionTitle ¶
SectionTitle renders a bold section title.
Types ¶
type CollectorResultJSON ¶ added in v0.6.0
type CollectorResultJSON struct {
Name string `json:"name"`
Signals int `json:"signals"`
Duration string `json:"duration"`
Error string `json:"error,omitempty"`
HasMetrics bool `json:"has_metrics"`
}
CollectorResultJSON is the JSON representation of a single collector result.
type Column ¶
type Column struct {
Header string
Align Alignment
Color ColorFunc // optional per-cell color function
}
Column describes a single table column.
type Recommendation ¶
Recommendation is a single actionable suggestion derived from metrics.
type ReportJSON ¶ added in v0.6.0
type ReportJSON struct {
Repository string `json:"repository"`
Generated string `json:"generated"`
Duration string `json:"duration"`
Collectors []CollectorResultJSON `json:"collectors"`
Signals SignalSummaryJSON `json:"signals"`
Sections []SectionJSON `json:"sections,omitempty"`
}
ReportJSON is the top-level JSON structure for --format json output.
type Section ¶
type Section interface {
// Name returns the unique identifier for this section (e.g., "lottery-risk").
Name() string
// Description returns a human-readable description of what this section reports.
Description() string
// Analyze processes the scan result and prepares internal state for rendering.
// Returns ErrMetricsNotAvailable (wrapped) if required metrics are missing.
Analyze(result *signal.ScanResult) error
// Render writes the section output to w.
Render(w io.Writer) error
}
Section is a pluggable report section that analyzes scan results and renders a focused report segment.
type SectionJSON ¶ added in v0.6.0
type SectionJSON struct {
Name string `json:"name"`
Description string `json:"description"`
Status string `json:"status"` // "ok", "skipped"
Content string `json:"content,omitempty"` // rendered text
}
SectionJSON is the JSON representation of a single report section.
type SignalSummaryJSON ¶ added in v0.6.0
SignalSummaryJSON is the JSON representation of the signal summary.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table renders aligned text tables to an io.Writer.