Documentation
¶
Overview ¶
Package linter provides Go code quality rules for wetwire pipeline definitions.
Index ¶
- Constants
- type Config
- type Context
- type Fix
- type FixResult
- type Fixer
- type Issue
- type JobLocation
- type Linter
- func (l *Linter) DisableRule(id string)
- func (l *Linter) EnableRule(id string)
- func (l *Linter) Fix(filePath string) (*FixResult, error)
- func (l *Linter) FixDir(dir string) (*FixResult, error)
- func (l *Linter) IsRuleEnabled(id string) bool
- func (l *Linter) LintDir(dir string) (*Result, error)
- func (l *Linter) LintFile(filePath string) (*Result, error)
- func (l *Linter) Rules() []Rule
- func (l *Linter) SetApprovedRegistries(registries []string)
- func (l *Linter) SetMaxJobsPerFile(n int)
- type Result
- type Rule
- type Severity
- type VarLocation
Constants ¶
const ( SeverityError = corelint.SeverityError SeverityWarning = corelint.SeverityWarning SeverityInfo = corelint.SeverityInfo )
Severity level constants from wetwire-core-go/lint.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
// JobNames tracks discovered job names across files
JobNames map[string][]JobLocation
// JobCount tracks jobs per file
JobCount map[string]int
// MaxJobsPerFile is the threshold for WGL008
MaxJobsPerFile int
// PackageVars tracks all declared variable names across files (for cross-file references)
PackageVars map[string]VarLocation
// JobVars tracks specifically job variable names for Needs validation
JobVars map[string]VarLocation
}
Context provides shared context for rules during linting.
type Fix ¶
type Fix struct {
RuleID string `json:"rule_id"`
Message string `json:"message"`
Start token.Pos `json:"-"`
End token.Pos `json:"-"`
Replacement string `json:"replacement"`
StartOffset int `json:"start_offset"`
EndOffset int `json:"end_offset"`
}
Fix represents a single auto-fix that can be applied to source code.
type FixResult ¶
type FixResult struct {
FilePath string `json:"file_path"`
Modified bool `json:"modified"`
FixedCount int `json:"fixed_count"`
Errors []string `json:"errors,omitempty"`
}
FixResult represents the result of applying fixes to a file.
type Fixer ¶
type Fixer interface {
// Fix returns a list of fixes for the given file. Each fix contains the position
// and replacement text needed to fix the issue.
Fix(fset *token.FileSet, file *ast.File, filePath string, ctx *Context) []Fix
}
Fixer is an optional interface that rules can implement to provide auto-fix capability.
type Issue ¶
Issue is a type alias for corelint.Issue. Field mapping from previous local type:
- Rule (was RuleID) -> rule identifier
- File (was FilePath) -> file path
- Message, Line, Column, Severity, Fixable, Suggestion unchanged
type JobLocation ¶
JobLocation tracks where a job name was defined.
type Linter ¶
type Linter struct {
// contains filtered or unexported fields
}
Linter provides Go code linting for wetwire pipeline definitions.
func (*Linter) DisableRule ¶
DisableRule disables a rule by ID.
func (*Linter) IsRuleEnabled ¶
IsRuleEnabled returns whether a rule is enabled.
func (*Linter) SetApprovedRegistries ¶
SetApprovedRegistries sets the list of approved container registries for WGL039. When set, WGL039 will flag images from registries not in this list. If empty, WGL039 will not check registries.
func (*Linter) SetMaxJobsPerFile ¶
SetMaxJobsPerFile sets the threshold for WGL008.
type Rule ¶
type Rule interface {
ID() string
Description() string
Check(fset *token.FileSet, file *ast.File, filePath string, ctx *Context) []Issue
}
Rule represents a lint rule for wetwire-gitlab pipelines. This extends the core lint.Rule interface with context-aware checking.
type VarLocation ¶
VarLocation tracks where a variable was declared.