linter

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package linter provides Go code quality rules for wetwire workflow declarations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FixDirResult

type FixDirResult struct {
	Files      []string `json:"files"`
	TotalFixed int      `json:"total_fixed"`
}

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 NewLinter

func NewLinter(rules ...Rule) *Linter

NewLinter creates a new Linter with the specified rules.

func (*Linter) AddRule

func (l *Linter) AddRule(rule Rule)

AddRule adds a rule to the linter.

func (*Linter) Fix

func (l *Linter) Fix(path string, content []byte) (*FixResult, error)

Fix applies fixes to Go source code from memory.

func (*Linter) FixDir

func (l *Linter) FixDir(dir string) (*FixDirResult, error)

FixDir applies fixes to all Go files in a directory.

func (*Linter) FixFile

func (l *Linter) FixFile(path string) (*FixResult, error)

FixFile applies fixes to a Go file and writes the result back.

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.

func (*Linter) LintFile

func (l *Linter) LintFile(path string) (*LintResult, error)

LintFile lints a single Go file.

func (*Linter) Rules

func (l *Linter) Rules() []Rule

Rules returns the list of rules configured in the linter.

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) Check

func (r *WAG001) Check(fset *token.FileSet, file *ast.File, path string) []LintIssue

func (*WAG001) Description

func (r *WAG001) Description() string

func (*WAG001) Fix

func (r *WAG001) Fix(fset *token.FileSet, file *ast.File, path string, src []byte, issue LintIssue) ([]byte, error)

Fix implements the Fixer interface for WAG001.

func (*WAG001) ID

func (r *WAG001) ID() string

type WAG002

type WAG002 struct{}

WAG002 checks for raw expression strings instead of condition builders.

func (*WAG002) Check

func (r *WAG002) Check(fset *token.FileSet, file *ast.File, path string) []LintIssue

func (*WAG002) Description

func (r *WAG002) Description() string

func (*WAG002) ID

func (r *WAG002) ID() string

type WAG003

type WAG003 struct{}

WAG003 checks for hardcoded secrets instead of using the secrets context.

func (*WAG003) Check

func (r *WAG003) Check(fset *token.FileSet, file *ast.File, path string) []LintIssue

func (*WAG003) Description

func (r *WAG003) Description() string

func (*WAG003) ID

func (r *WAG003) ID() string

type WAG004

type WAG004 struct{}

WAG004 checks for inline matrix maps instead of using the matrix builder.

func (*WAG004) Check

func (r *WAG004) Check(fset *token.FileSet, file *ast.File, path string) []LintIssue

func (*WAG004) Description

func (r *WAG004) Description() string

func (*WAG004) ID

func (r *WAG004) ID() string

type WAG005

type WAG005 struct{}

WAG005 checks for inline struct definitions that should be extracted.

func (*WAG005) Check

func (r *WAG005) Check(fset *token.FileSet, file *ast.File, path string) []LintIssue

func (*WAG005) Description

func (r *WAG005) Description() string

func (*WAG005) ID

func (r *WAG005) ID() string

type WAG006

type WAG006 struct{}

WAG006 checks for duplicate workflow names.

func (*WAG006) Check

func (r *WAG006) Check(fset *token.FileSet, file *ast.File, path string) []LintIssue

func (*WAG006) Description

func (r *WAG006) Description() string

func (*WAG006) ID

func (r *WAG006) ID() string

type WAG007

type WAG007 struct {
	MaxJobs int
}

WAG007 checks for files with too many jobs.

func (*WAG007) Check

func (r *WAG007) Check(fset *token.FileSet, file *ast.File, path string) []LintIssue

func (*WAG007) Description

func (r *WAG007) Description() string

func (*WAG007) ID

func (r *WAG007) ID() string

type WAG008

type WAG008 struct{}

WAG008 checks for hardcoded expression strings.

func (*WAG008) Check

func (r *WAG008) Check(fset *token.FileSet, file *ast.File, path string) []LintIssue

func (*WAG008) Description

func (r *WAG008) Description() string

func (*WAG008) ID

func (r *WAG008) ID() string

type WAG009

type WAG009 struct{}

WAG009 validates matrix dimension values are not empty.

func (*WAG009) Check

func (r *WAG009) Check(fset *token.FileSet, file *ast.File, path string) []LintIssue

func (*WAG009) Description

func (r *WAG009) Description() string

func (*WAG009) ID

func (r *WAG009) ID() string

type WAG010

type WAG010 struct{}

WAG010 flags missing recommended action inputs.

func (*WAG010) Check

func (r *WAG010) Check(fset *token.FileSet, file *ast.File, path string) []LintIssue

func (*WAG010) Description

func (r *WAG010) Description() string

func (*WAG010) ID

func (r *WAG010) ID() string

type WAG011

type WAG011 struct{}

WAG011 detects potential unreachable jobs.

func (*WAG011) Check

func (r *WAG011) Check(fset *token.FileSet, file *ast.File, path string) []LintIssue

func (*WAG011) Description

func (r *WAG011) Description() string

func (*WAG011) ID

func (r *WAG011) ID() string

type WAG012

type WAG012 struct{}

WAG012 warns about deprecated action versions.

func (*WAG012) Check

func (r *WAG012) Check(fset *token.FileSet, file *ast.File, path string) []LintIssue

func (*WAG012) Description

func (r *WAG012) Description() string

func (*WAG012) ID

func (r *WAG012) ID() string

type WAG013

type WAG013 struct{}

WAG013 checks for pointer assignments (&Type{}) in workflow declarations.

func (*WAG013) Check

func (r *WAG013) Check(fset *token.FileSet, file *ast.File, path string) []LintIssue

func (*WAG013) Description

func (r *WAG013) Description() string

func (*WAG013) ID

func (r *WAG013) ID() string

type WAG014

type WAG014 struct{}

WAG014 checks for jobs without TimeoutMinutes set.

func (*WAG014) Check

func (r *WAG014) Check(fset *token.FileSet, file *ast.File, path string) []LintIssue

func (*WAG014) Description

func (r *WAG014) Description() string

func (*WAG014) ID

func (r *WAG014) ID() string

type WAG015

type WAG015 struct{}

WAG015 suggests caching for setup actions.

func (*WAG015) Check

func (r *WAG015) Check(fset *token.FileSet, file *ast.File, path string) []LintIssue

func (*WAG015) Description

func (r *WAG015) Description() string

func (*WAG015) ID

func (r *WAG015) ID() string

type WAG016

type WAG016 struct{}

WAG016 validates concurrency settings.

func (*WAG016) Check

func (r *WAG016) Check(fset *token.FileSet, file *ast.File, path string) []LintIssue

func (*WAG016) Description

func (r *WAG016) Description() string

func (*WAG016) ID

func (r *WAG016) ID() string

type WAG017

type WAG017 struct{}

WAG017 suggests adding explicit permissions scope to workflows.

func (*WAG017) Check

func (r *WAG017) Check(fset *token.FileSet, file *ast.File, path string) []LintIssue

func (*WAG017) Description

func (r *WAG017) Description() string

func (*WAG017) ID

func (r *WAG017) ID() string

type WAG018

type WAG018 struct{}

WAG018 detects dangerous pull_request_target patterns.

func (*WAG018) Check

func (r *WAG018) Check(fset *token.FileSet, file *ast.File, path string) []LintIssue

func (*WAG018) Description

func (r *WAG018) Description() string

func (*WAG018) ID

func (r *WAG018) ID() string

type WAG019

type WAG019 struct{}

WAG019 detects circular dependencies in job dependency graphs.

func (*WAG019) Check

func (r *WAG019) Check(fset *token.FileSet, file *ast.File, path string) []LintIssue

func (*WAG019) Description

func (r *WAG019) Description() string

func (*WAG019) ID

func (r *WAG019) ID() string

type WAG020

type WAG020 struct{}

WAG020 detects hardcoded secrets and credentials in code.

func (*WAG020) Check

func (r *WAG020) Check(fset *token.FileSet, file *ast.File, path string) []LintIssue

func (*WAG020) Description

func (r *WAG020) Description() string

func (*WAG020) ID

func (r *WAG020) ID() string

Jump to

Keyboard shortcuts

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