rulepack

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package rulepack configures built-in and customer analyzers through one registry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdaptRule

func AdaptRule(rule linter.Rule) linter.Analyzer

AdaptRule exposes the public OpenAPI visitor contract as a pack analyzer.

func AdaptSchemaRule

func AdaptSchemaRule(rule linter.SchemaRule) linter.Analyzer

AdaptSchemaRule gives standalone-schema checks the same rule-pack handling.

func DecodeOptions

func DecodeOptions(node yaml.Node, target any) error

DecodeOptions gives third-party checks the same strict option validation as stock checks.

func RegisterStock

func RegisterStock(registry *Registry) error

Types

type Factory

type Factory func(yaml.Node) (interfaces.Analyzer, error)

Factory constructs a check using validated customer options.

type Pack

type Pack struct {
	Version      int           `yaml:"version"`
	Rules        []Rule        `yaml:"rules"`
	Suppressions []Suppression `yaml:"suppressions,omitempty"`
}

Pack is the versioned customer rule configuration.

func Decode

func Decode(reader io.Reader) (Pack, error)

Decode rejects unknown fields and multiple YAML documents.

func DefaultPack

func DefaultPack() Pack

type Program

type Program struct {
	// contains filtered or unexported fields
}

Program is a validated rule pack ready to run on parsed documents.

func (*Program) Run

func (p *Program) Run(ctx context.Context, root string, documents []*interfaces.Document) ([]interfaces.Diagnostic, error)

Run executes checks with identical scoping, identity, severity and suppression handling.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry holds factories registered by either the application or its extensions.

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Compile

func (r *Registry) Compile(pack Pack) (*Program, error)

Compile validates the complete pack, including rules not selected by a later CLI filter.

func (*Registry) Register

func (r *Registry) Register(name string, factory Factory) error

Register rejects conflicting check names instead of replacing built-in behavior.

type Rule

type Rule struct {
	ID          string              `yaml:"id"`
	Check       string              `yaml:"check"`
	Description string              `yaml:"description,omitempty"`
	Severity    interfaces.Severity `yaml:"severity,omitempty"`
	Include     []string            `yaml:"include,omitempty"`
	Exclude     []string            `yaml:"exclude,omitempty"`
	Options     yaml.Node           `yaml:"options,omitempty"`
}

Rule assigns an identity, severity, scope and options to a registered check.

type Suppression

type Suppression struct {
	Rule   string `yaml:"rule"`
	Path   string `yaml:"path"`
	Line   int    `yaml:"line,omitempty"`
	Reason string `yaml:"reason"`
}

Suppression explicitly silences a configured rule at a file and optional line.

Jump to

Keyboard shortcuts

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