config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: 0BSD Imports: 19 Imported by: 0

Documentation

Overview

Package config owns typed Glippy configuration defaults and decoding.

Index

Constants

View Source
const (
	// Filename is the canonical project configuration filename.
	Filename = ".glippy.toml"
	// LegacyFilename is accepted as a deprecated fallback for the v0.2 compatibility window.
	LegacyFilename = ".gox.toml"
	// MaxAnalysisTargets bounds explicit CI build-matrix work from configuration.
	MaxAnalysisTargets = 32
)
View Source
const (
	// DefaultLineWidth is the formatter's default print width.
	DefaultLineWidth = 100
	// DefaultTabWidth is the formatter's default visual tab width.
	DefaultTabWidth = 8
	// DefaultCacheMaxEntries bounds retained persistent analysis results.
	DefaultCacheMaxEntries = 4096
	// DefaultCacheMaxBytes bounds retained persistent analysis storage.
	DefaultCacheMaxBytes int64 = 512 << 20
)
View Source
const (
	PresetCorrectness = rules.PresetCorrectness
	PresetSuspicious  = rules.PresetSuspicious
	PresetPerformance = rules.PresetPerformance
	PresetComplexity  = rules.PresetComplexity
	PresetStyle       = rules.PresetStyle
	PresetPedantic    = rules.PresetPedantic
	PresetNursery     = rules.PresetNursery
	PresetRestriction = rules.PresetRestriction
	PresetMigration   = rules.PresetMigration
)
View Source
const (
	SeverityOff   = rules.SeverityOff
	SeverityWarn  = rules.SeverityWarn
	SeverityError = rules.SeverityError
)
View Source
const Version = 1

Version is the only accepted configuration schema version.

Variables

This section is empty.

Functions

func ValidProfile

func ValidProfile(value Profile) bool

ValidProfile reports whether value names one built-in profile.

Types

type Analysis

type Analysis struct {
	BuildTags     []string
	GOOS          string
	GOARCH        string
	CGOEnabled    bool
	Targets       []AnalysisTarget
	ContractFiles []string
	Contracts     contracts.Set
}

Analysis contains the resolved build selection for package-aware rules.

type AnalysisTarget

type AnalysisTarget struct {
	BuildTags  []string
	GOOS       string
	GOARCH     string
	CGOEnabled bool
}

AnalysisTarget is one explicit CI-oriented Go build selection.

func (AnalysisTarget) ID

func (t AnalysisTarget) ID() string

ID returns the stable machine and human identity of one target.

type Baseline

type Baseline struct {
	Path         string
	ReportStale  bool
	ExpiryCutoff string
}

Baseline contains deterministic progressive-adoption policy.

type Cache

type Cache struct {
	Enabled    bool
	MaxEntries int
	MaxBytes   int64
}

Cache contains the opt-in persistent analysis-cache lifecycle policy.

type Config

type Config struct {
	Version  int
	Format   Format
	Analysis Analysis
	Lint     Lint
	Cache    Cache
}

Config is one fully defaulted and validated project configuration.

func Defaults

func Defaults() Config

Defaults returns an independent configuration containing built-in policy.

func Load

func Load(selection Selection, options ParseOptions) (Config, error)

Load returns defaults or reads and parses one selected configuration.

func Parse

func Parse(path string, input []byte, options ParseOptions) (Config, error)

Parse strictly decodes, defaults, and validates one configuration source.

func (Config) CanonicalBytes

func (c Config) CanonicalBytes() []byte

CanonicalBytes returns the deterministic identity of one fully resolved configuration. It excludes source spelling, comments, and cache lifecycle policy while retaining every value that can affect formatting or analysis.

func (Config) LintForExecution

func (c Config) LintForExecution() Lint

LintForExecution enables every rule that can be selected by a path override. Per-path filtering restores the exact severity after shared analysis runs.

func (Config) LintForPath

func (c Config) LintForPath(projectRelativePath string) (Lint, []int, error)

LintForPath returns an independent lint policy after ordered path overrides. Match indexes are one-based so they correspond to configuration declarations.

type Error

type Error struct {
	Path    string
	Line    int
	Column  int
	Message string
	// contains filtered or unexported fields
}

Error is one path-aware configuration diagnostic.

func (*Error) Error

func (e *Error) Error() string

Error renders a source-located diagnostic when line information is known.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the underlying TOML decoder failure when one exists.

type Format

type Format struct {
	LineWidth int
	TabWidth  int
}

Format contains formatter policy that materially affects adoption.

type Lint

type Lint struct {
	Profile          Profile
	ProfileRules     map[string]Severity
	Presets          []Preset
	WarningsAsErrors bool
	Rules            map[string]Severity
	RuleOptions      map[string]rules.OptionSet
	Overrides        []LintOverride
	Suppressions     Suppressions
	Baseline         Baseline
}

Lint contains the selected preset groups and explicit rule policy.

func (Lint) EffectiveRules

func (l Lint) EffectiveRules() map[string]Severity

EffectiveRules returns profile policy followed by explicit rule overrides.

type LintOverride

type LintOverride struct {
	Paths []string
	Rules map[string]Severity
}

LintOverride applies exact rule severities to matching project-relative paths. Overrides retain declaration order because later matches replace earlier ones.

type ParseOptions

type ParseOptions struct {
	KnownRules  []string
	RuleOptions map[string][]rules.OptionMetadata
}

ParseOptions supplies registry state needed to validate rule identifiers.

type Preset

type Preset = rules.Preset

Preset identifies one coherent lint-rule selection.

type Profile

type Profile string

Profile identifies one curated, versioned lint policy.

const (
	ProfileDefault     Profile = "default"
	ProfileRecommended Profile = "recommended"
	ProfileStrict      Profile = "strict"
	ProfilePedantic    Profile = "pedantic"
)

func Profiles

func Profiles() []Profile

Profiles returns the canonical profile names in increasing strictness.

type Selection

type Selection struct {
	Root     string
	Path     string
	Explicit bool
}

Selection identifies the project boundary and configuration for one input.

func Discover

func Discover(inputPath, explicitPath string) (Selection, error)

Discover selects one project configuration for an input path.

func DiscoverFileContext

func DiscoverFileContext(inputPath, explicitPath string) (Selection, error)

DiscoverFileContext selects configuration for an editor file path that may not exist yet.

type Severity

type Severity = rules.Severity

Severity controls whether and how a lint rule reports.

type Suppressions

type Suppressions struct {
	RequireReason bool
	ExpiryCutoff  string
}

Suppressions contains project policy for auditable lint waivers.

Jump to

Keyboard shortcuts

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