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) error
Report outputs the analysis results to the console
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 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) 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
- 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.
Currently supported formats:
- "console" (default): Human-readable console output with tables
Returns an error if the configured format is not supported.