diagnostics

package
v0.36.4 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package diagnostics handles diagnostics from the scanner and spec validation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reporter

type Reporter struct {
	// Root is the directory positions are reported relative to, so that a diagnostic names the file
	// the way the caller would.
	Root string
	// contains filtered or unexported fields
}

Reporter receives everything the scan observed.

codescan never writes to standard error itself - every observation arrives through a callback - so this is the only thing standing between a scan and a silent one. It also decides the exit status: a caller running this in a pipeline wants to be told, and a summary a human reads is not something a pipeline can act on.

func NewReporter

func NewReporter(cfg ReporterConfig) *Reporter

NewReporter wires a sink for the scan's diagnostics.

func (*Reporter) AboutConfiguration

func (r *Reporter) AboutConfiguration(path string, applied cliconf.Result)

AboutConfiguration reports what a configuration file decided, under -verbose.

It reports whether a config file was read at all, the keys it skipped and if a section was misspelled.

func (*Reporter) OnDiagnostic

func (r *Reporter) OnDiagnostic(diag codescan.Diagnostic)

OnDiagnostic is what codescan.Options.OnDiagnostic is given.

func (*Reporter) Summarize

func (r *Reporter) Summarize() error

Summarize reports what the command observed in all, and whether that is a failure.

The counts include what was muted. A scan whose hints were suppressed says how many there were, so a caller knows if going verbose has anything to add.

func (*Reporter) ValidateSpec

func (r *Reporter) ValidateSpec(asJSON []byte) error

ValidateSpec reports what is wrong with the document the scan produced.

The scanner diagnoses what is wrong with the syntax in annotations whereas [Check] verifies the output spec is a valid OpenAPI 2.0 specfication.

It runs on the rendered JSON rather than on the github.com/go-openapi/spec.Swagger it came from, so what is checked is exactly what was written - including whatever the round-trip through JSON did to it.

Findings go through the same Reporter as the scan's own diagnostics: to a reader they are the same kind of news about the same document, and giving them a second dialect would only mean two things to learn.

type ReporterConfig

type ReporterConfig struct {
	Quiet         bool
	Verbose       bool
	Color         bool
	FailThreshold codescan.Severity
	Failing       bool
	Stderr        io.Writer
	Output        string
}

ReporterConfig holds what part of the CLI config is of interest to a Reporter.

Jump to

Keyboard shortcuts

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