Documentation
¶
Overview ¶
Package reporter handles formatting and outputting analysis results.
The reporter package provides a flexible reporting interface that can output analysis results in different formats. Currently supports console output with formatted tables and sections.
Output Format ¶
The console reporter outputs: - Summary statistics (files, lines, functions) - Aggregate metrics (averages, percentiles, comment ratio) - Issues grouped by severity (warnings, info) - Test coverage report (if enabled) - Dependency analysis (if enabled) - Top N largest files and most complex functions
Usage ¶
Create a console reporter:
cfg := &config.OutputConfig{
Format: "console",
Verbose: true,
}
reporter, err := reporter.NewReporter(cfg)
if err != nil {
log.Fatal(err)
}
Output analysis results:
err = reporter.Report(analysisResult)
if err != nil {
log.Fatal(err)
}
Verbose mode includes additional details like full file paths and detailed issue descriptions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConsoleReporter ¶
type ConsoleReporter struct {
// contains filtered or unexported fields
}
ConsoleReporter implements Reporter for console output
func NewConsoleReporter ¶
func NewConsoleReporter(cfg *config.OutputConfig) *ConsoleReporter
NewConsoleReporter creates a new ConsoleReporter
func (*ConsoleReporter) Report ¶
func (cr *ConsoleReporter) Report(result *analyzer.AnalysisResult, comp *comparison.ComparisonResult) error
Report outputs the analysis results to the console
type JSONOutput ¶ added in v0.3.0
type JSONOutput struct {
Timestamp string `json:"timestamp"`
Version string `json:"version"`
Result *analyzer.AnalysisResult `json:"result"`
Comparison *comparison.ComparisonResult `json:"comparison,omitempty"` // Phase 3: Optional comparison
}
JSONOutput wraps the analysis result with metadata for JSON export
type JSONReporter ¶ added in v0.3.0
type JSONReporter struct {
// contains filtered or unexported fields
}
JSONReporter implements Reporter for JSON output
func NewJSONReporter ¶ added in v0.3.0
func NewJSONReporter(cfg *config.OutputConfig) *JSONReporter
NewJSONReporter creates a new JSONReporter
func (*JSONReporter) Report ¶ added in v0.3.0
func (jr *JSONReporter) Report(result *analyzer.AnalysisResult, comp *comparison.ComparisonResult) error
Report generates a JSON formatted report
type MarkdownReporter ¶ added in v0.3.0
type MarkdownReporter struct {
// contains filtered or unexported fields
}
MarkdownReporter implements Reporter for Markdown output
func NewMarkdownReporter ¶ added in v0.3.0
func NewMarkdownReporter(cfg *config.OutputConfig) *MarkdownReporter
NewMarkdownReporter creates a new MarkdownReporter
func (*MarkdownReporter) Report ¶ added in v0.3.0
func (mr *MarkdownReporter) Report(result *analyzer.AnalysisResult, comp *comparison.ComparisonResult) error
Report generates a Markdown formatted report
type Reporter ¶
type Reporter interface {
// Report formats and outputs the analysis results.
//
// The result parameter contains all analysis data including issues,
// metrics, coverage, and dependencies.
//
// The comparison parameter (Phase 3) contains comparison with previous
// report if available. Can be nil if no previous report exists or
// comparison is disabled.
//
// The implementation determines how this data is formatted and where it's sent.
//
// Returns an error if output fails (e.g., I/O error, formatting error).
Report(result *analyzer.AnalysisResult, comparison *comparison.ComparisonResult) error
}
Reporter defines the interface for formatting and outputting analysis results.
Implementations of this interface are responsible for:
- Formatting the AnalysisResult into the desired output format
- Including comparison data if available (Phase 3)
- Writing the formatted output to the appropriate destination
- Handling output errors gracefully
The analyzer package is output-agnostic; all formatting decisions are delegated to Reporter implementations.
func NewReporter ¶
func NewReporter(cfg *config.OutputConfig) (Reporter, error)
NewReporter creates a new Reporter based on the configured output format.
Supported formats:
- "console" (default): Human-readable console output with tables
- "markdown": GitHub-flavored Markdown with tables and sections
- "json": JSON output for programmatic consumption
Returns an error if the configured format is not supported.