report

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package report builds and serializes crawl reports (JSON, CSV, and HTML).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Explanations added in v0.6.0

func Explanations() map[string]Explanation

Explanations returns a copy of every registered issue-code explanation, keyed by Code. It backs the web API's /api/explanations endpoint, which lets the live report view show the same what/impact/fix text as the HTML report without duplicating this map in the frontend. Returns a copy so a caller can't mutate the package's single source of truth.

Types

type CSVReporter

type CSVReporter struct{}

CSVReporter writes one row per issue.

func (CSVReporter) Write

func (CSVReporter) Write(w io.Writer, r *Report) error

Write implements Reporter.

type Explanation

type Explanation struct {
	// What the issue entails — a plain-language description of the finding.
	What string `json:"what"`
	// Impact — why it matters / the potential consequence if left unaddressed.
	Impact string `json:"impact"`
	// Fix — the recommended remediation.
	Fix string `json:"fix"`
}

Explanation describes a single issue code in plain language: what the finding means, why it matters, and what to do about it. It is keyed by an Issue's Code and surfaced in the HTML report so a reader can act on a finding without consulting external documentation.

type HTMLReporter

type HTMLReporter struct{}

HTMLReporter writes a self-contained HTML report (inline CSS, no external assets) suitable for opening in a browser or sharing as an artifact.

func (HTMLReporter) Write

func (HTMLReporter) Write(w io.Writer, r *Report) error

Write implements Reporter.

type JSONReporter

type JSONReporter struct{}

JSONReporter writes an indented JSON report.

func (JSONReporter) Write

func (JSONReporter) Write(w io.Writer, r *Report) error

Write implements Reporter.

type Report

type Report struct {
	Seed         string          `json:"seed"`
	StartedAt    string          `json:"started_at"`
	FinishedAt   string          `json:"finished_at"`
	PagesCrawled int             `json:"pages_crawled"`
	Summary      Summary         `json:"summary"`
	Issues       []analyze.Issue `json:"issues"`
	// Notes carries human-readable advisories about the run itself (e.g. analyzers skipped
	// because of a conflicting option), not page findings. Omitted when empty.
	Notes []string `json:"notes,omitempty"`
	// Coverage reports whether the crawl reached every in-scope URL it found. When it didn't,
	// findings that depend on fetching a page (broken links especially) may be incomplete, and
	// the HTML report shows a banner saying so. A pointer so re-rendering an older JSON report
	// that predates this field doesn't falsely claim partial coverage.
	Coverage *crawler.Coverage `json:"coverage,omitempty"`
	// SiteMap is the crawled site as a tree, annotated with the issues found on each page. It
	// powers the "Site map" tab of the HTML report and the optional sitemap.xml side output.
	// It is serialized so a JSON report is a complete artifact that `gocrawl render` can turn
	// back into HTML (including the Site map tab) without recrawling.
	SiteMap *sitemapgen.Map `json:"site_map,omitempty"`
}

Report is the serializable result of a crawl plus analysis.

func Build

func Build(result *crawler.Result, issues []analyze.Issue) *Report

Build assembles a Report from a crawl Result and its issues.

func (*Report) SummaryLines

func (r *Report) SummaryLines() []string

SummaryLines returns a short human-readable summary for stderr.

type Reporter

type Reporter interface {
	Write(w io.Writer, r *Report) error
}

Reporter serializes a Report to a writer.

func For

func For(format string) Reporter

For returns the Reporter for the given format ("json", "csv", or "html"; default json).

type Summary

type Summary struct {
	BySeverity map[string]int `json:"by_severity"`
	ByAnalyzer map[string]int `json:"by_analyzer"`
	ByStatus   map[string]int `json:"pages_by_status"`
}

Summary aggregates issue counts.

Jump to

Keyboard shortcuts

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