validation

package
v0.18.5 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SeverityError   = "error"
	SeverityWarning = "warning"
)

Severity constants

Variables

This section is empty.

Functions

func DetectDefaultReporter

func DetectDefaultReporter() string

func DoCheckReport

func DoCheckReport(result Check, reportingFormat string) error

func IdentifierMatches

func IdentifierMatches(resultIdentifier, ignoreIdentifier string) bool

IdentifierMatches reports whether a result identifier is covered by an ignore identifier. An ignore of "metadata.description" matches that exact identifier and any more specific child such as "metadata.description.length.de-DE".

func IgnoreMatches

func IgnoreMatches(result CheckResult, ignore ToolConfigIgnore, pathMatches func(resultPath, ignorePath string) bool) bool

IgnoreMatches reports whether a result should be removed for the given ignore rule. Path matching is delegated so callers can handle path normalization.

func NormalizeSourcePath

func NormalizeSourcePath(source, root string) string

NormalizeSourcePath rewrites a finding path so it is relative to root. Absolute workspace, extraction, and macOS /private prefixes are stripped. Paths that already are relative are returned as slash-normalized relatives.

func ResolveSourceRoot

func ResolveSourceRoot(root string) string

ResolveSourceRoot returns a cleaned, absolute source root used to rewrite finding locations. Temporary extraction directories stay usable as roots; only the reported path is rewritten to be relative to this root.

func StripRootFromText

func StripRootFromText(text, root string) string

StripRootFromText removes temporary or analysis-root prefixes from messages so reporter output never leaks the verifier workspace.

func ValidateReporter

func ValidateReporter(name string) error

ValidateReporter checks whether name identifies a supported validation report format.

Types

type Check

type Check interface {
	AddResult(CheckResult)
	RemoveByIdentifier([]ToolConfigIgnore) Check
	GetResults() []CheckResult
	HasErrors() bool
}

Check interface for validation checking

type CheckResult

type CheckResult struct {
	// The path to the file that was checked
	Path string `json:"path"`
	// The line number of the issue
	Line    int    `json:"line"`
	Message string `json:"message"`
	// The severity of the issue
	Severity string `json:"severity"`

	Identifier string `json:"identifier"`

	// Tip provides additional context or suggestions to fix the issue
	Tip string `json:"tip,omitempty"`
}

CheckResult represents a validation result

func NormalizeResult

func NormalizeResult(result CheckResult, root string) CheckResult

NormalizeResult rewrites path, message, and a missing line so every reporter sees the same stable source location.

type GitLabCodeQualityIssue

type GitLabCodeQualityIssue struct {
	Description string                    `json:"description"`
	CheckName   string                    `json:"check_name"`
	Fingerprint string                    `json:"fingerprint"`
	Severity    string                    `json:"severity"`
	Location    GitLabCodeQualityLocation `json:"location"`
}

type GitLabCodeQualityLines

type GitLabCodeQualityLines struct {
	Begin int `json:"begin"`
}

type GitLabCodeQualityLocation

type GitLabCodeQualityLocation struct {
	Path  string                 `json:"path"`
	Lines GitLabCodeQualityLines `json:"lines"`
}

type JUnitTestCase

type JUnitTestCase struct {
	Name      string            `xml:"name,attr"`
	ClassName string            `xml:"classname,attr"`
	Failure   *JUnitTestFailure `xml:"failure,omitempty"`
	Error     *JUnitTestError   `xml:"error,omitempty"`
}

type JUnitTestError

type JUnitTestError struct {
	Message string `xml:"message,attr"`
	Type    string `xml:"type,attr"`
	Content string `xml:",chardata"`
}

type JUnitTestFailure

type JUnitTestFailure struct {
	Message string `xml:"message,attr"`
	Type    string `xml:"type,attr"`
	Content string `xml:",chardata"`
}

type JUnitTestSuite

type JUnitTestSuite struct {
	XMLName  xml.Name        `xml:"testsuite"`
	Name     string          `xml:"name,attr"`
	Tests    int             `xml:"tests,attr"`
	Failures int             `xml:"failures,attr"`
	Errors   int             `xml:"errors,attr"`
	TestCase []JUnitTestCase `xml:"testcase"`
}

type ToolConfigIgnore

type ToolConfigIgnore struct {
	Identifier string `yaml:"identifier"`
	Path       string `yaml:"path,omitempty"`
	Message    string `yaml:"message,omitempty"`
}

ToolConfigIgnore represents a configuration item to ignore during validation

func (ToolConfigIgnore) JSONSchema

func (c ToolConfigIgnore) JSONSchema() *jsonschema.Schema

JSONSchema generates the JSON schema for ToolConfigIgnore

func (*ToolConfigIgnore) UnmarshalYAML

func (c *ToolConfigIgnore) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements custom YAML unmarshaling for ToolConfigIgnore

Jump to

Keyboard shortcuts

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