Documentation
¶
Overview ¶
Package linter provides Go code quality rules for wetwire workflow declarations.
Index ¶
- type FixDirResult
- type FixResult
- type Fixer
- type LintIssue
- type LintResult
- type Linter
- func (l *Linter) AddRule(rule Rule)
- func (l *Linter) Fix(path string, content []byte) (*FixResult, error)
- func (l *Linter) FixDir(dir string) (*FixDirResult, error)
- func (l *Linter) FixFile(path string) (*FixResult, error)
- func (l *Linter) LintContent(path string, content []byte) (*LintResult, error)
- func (l *Linter) LintDir(dir string) (*LintResult, error)
- func (l *Linter) LintFile(path string) (*LintResult, error)
- func (l *Linter) Rules() []Rule
- type Rule
- type WAG001
- type WAG002
- type WAG003
- type WAG004
- type WAG005
- type WAG006
- type WAG007
- type WAG008
- type WAG009
- type WAG010
- type WAG011
- type WAG012
- type WAG013
- type WAG014
- type WAG015
- type WAG016
- type WAG017
- type WAG018
- type WAG019
- type WAG020
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FixDirResult ¶
FixDirResult contains the result of fixing a directory.
type FixResult ¶
type FixResult struct {
Content []byte `json:"-"`
FixedCount int `json:"fixed_count"`
Issues []LintIssue `json:"issues,omitempty"` // Remaining unfixed issues
}
FixResult contains the result of a fix operation.
type Fixer ¶
type Fixer interface {
// Fix attempts to fix an issue and returns the modified source code.
// The issue parameter contains information about what to fix.
// Returns the fixed source code, or nil if the fix could not be applied.
Fix(fset *token.FileSet, file *ast.File, path string, src []byte, issue LintIssue) ([]byte, error)
}
Fixer is an optional interface that rules can implement to provide auto-fix capability.
type LintIssue ¶
type LintIssue struct {
File string `json:"file"`
Line int `json:"line"`
Column int `json:"column"`
Severity string `json:"severity"` // "error", "warning", "info"
Message string `json:"message"`
Rule string `json:"rule"`
Fixable bool `json:"fixable"`
}
LintIssue represents a single lint issue found in Go code.
type LintResult ¶
type LintResult struct {
Success bool `json:"success"`
Issues []LintIssue `json:"issues,omitempty"`
}
LintResult contains the result of linting.
type Linter ¶
type Linter struct {
// contains filtered or unexported fields
}
Linter runs rules against Go source code.
func DefaultLinter ¶
func DefaultLinter() *Linter
DefaultLinter creates a linter with all default rules enabled.
func (*Linter) FixDir ¶
func (l *Linter) FixDir(dir string) (*FixDirResult, error)
FixDir applies fixes to all Go files in a directory.
func (*Linter) LintContent ¶
func (l *Linter) LintContent(path string, content []byte) (*LintResult, error)
LintContent lints Go source code from memory.
func (*Linter) LintDir ¶
func (l *Linter) LintDir(dir string) (*LintResult, error)
LintDir lints all Go files in a directory recursively.
type Rule ¶
type Rule interface {
// ID returns the unique identifier for this rule (e.g., "WAG001")
ID() string
// Description returns a human-readable description of the rule
Description() string
// Check analyzes the AST and returns any issues found
Check(fset *token.FileSet, file *ast.File, path string) []LintIssue
}
Rule is the interface that all linter rules must implement.
type WAG001 ¶
type WAG001 struct{}
WAG001 checks for raw uses: strings instead of typed action wrappers.
func (*WAG001) Description ¶
type WAG002 ¶
type WAG002 struct{}
WAG002 checks for raw expression strings instead of condition builders.
func (*WAG002) Description ¶
type WAG003 ¶
type WAG003 struct{}
WAG003 checks for hardcoded secrets instead of using the secrets context.
func (*WAG003) Description ¶
type WAG004 ¶
type WAG004 struct{}
WAG004 checks for inline matrix maps instead of using the matrix builder.
func (*WAG004) Description ¶
type WAG005 ¶
type WAG005 struct{}
WAG005 checks for inline struct definitions that should be extracted.
func (*WAG005) Description ¶
type WAG006 ¶
type WAG006 struct{}
WAG006 checks for duplicate workflow names.
func (*WAG006) Description ¶
type WAG007 ¶
type WAG007 struct {
MaxJobs int
}
WAG007 checks for files with too many jobs.
func (*WAG007) Description ¶
type WAG008 ¶
type WAG008 struct{}
WAG008 checks for hardcoded expression strings.
func (*WAG008) Description ¶
type WAG009 ¶
type WAG009 struct{}
WAG009 validates matrix dimension values are not empty.
func (*WAG009) Description ¶
type WAG010 ¶
type WAG010 struct{}
WAG010 flags missing recommended action inputs.
func (*WAG010) Description ¶
type WAG011 ¶
type WAG011 struct{}
WAG011 detects potential unreachable jobs.
func (*WAG011) Description ¶
type WAG012 ¶
type WAG012 struct{}
WAG012 warns about deprecated action versions.
func (*WAG012) Description ¶
type WAG013 ¶
type WAG013 struct{}
WAG013 checks for pointer assignments (&Type{}) in workflow declarations.
func (*WAG013) Description ¶
type WAG014 ¶
type WAG014 struct{}
WAG014 checks for jobs without TimeoutMinutes set.
func (*WAG014) Description ¶
type WAG015 ¶
type WAG015 struct{}
WAG015 suggests caching for setup actions.
func (*WAG015) Description ¶
type WAG016 ¶
type WAG016 struct{}
WAG016 validates concurrency settings.
func (*WAG016) Description ¶
type WAG017 ¶
type WAG017 struct{}
WAG017 suggests adding explicit permissions scope to workflows.
func (*WAG017) Description ¶
type WAG018 ¶
type WAG018 struct{}
WAG018 detects dangerous pull_request_target patterns.
func (*WAG018) Description ¶
type WAG019 ¶
type WAG019 struct{}
WAG019 detects circular dependencies in job dependency graphs.