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 ¶
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 ¶
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 ¶
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.