Documentation
¶
Index ¶
- func All() []string
- func MatchGlob(pattern, path string) bool
- func Register(name string, constructor func() Module)
- func ResolveCacheDir(rootDir string, configDir string) string
- type Cache
- type CacheTTLModule
- type ConfigurableModule
- type Delta
- type Engine
- type FileInfo
- type Finding
- type Module
- type ModuleStats
- type Severity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatchGlob ¶
MatchGlob matches a glob pattern supporting ** against a forward-slash path. Patterns and paths should use "/" separators. Exported wrapper so modules can reuse the engine's glob semantics.
func Register ¶
Register adds a module constructor to the global registry. Called from init() in each module file.
func ResolveCacheDir ¶
ResolveCacheDir determines the cache directory using the following precedence:
- STAGEFREIGHT_CACHE_DIR env var (used as-is, caller controls the path)
- configDir from .stagefreight.yml cache_dir (resolved relative to rootDir)
- os.UserCacheDir()/stagefreight/<project-hash>/lint (XDG-aware default)
The project hash is a truncated SHA-256 of the absolute rootDir path, keeping per-project caches isolated without long nested directory names.
Types ¶
type Cache ¶
Cache provides content-addressed lint result caching. Dir is the resolved cache directory (call ResolveCacheDir to compute it).
func (*Cache) Get ¶
Get retrieves cached findings. Returns nil, false on cache miss. maxAge controls TTL: 0 means no expiry (content-only modules), >0 expires entries older than the duration (external-state modules).
type CacheTTLModule ¶
CacheTTLModule controls time-based cache expiry.
Modules that do not implement this interface are cached forever.
Semantics:
>0 → cache with expiry (e.g. 5*time.Minute) 0 → cache forever (content-hash only) <0 → never cache (always re-run)
type ConfigurableModule ¶
ConfigurableModule is implemented by modules that accept YAML options. The engine calls Configure after construction if the module's config section contains an options map.
type Delta ¶
Delta detects changed files relative to a baseline.
func (*Delta) ChangedFiles ¶
ChangedFiles returns the list of files changed relative to the baseline. In CI mode, it diffs against STAGEFREIGHT_TARGET_BRANCH (or auto-detects). Locally, it diffs against HEAD (uncommitted + staged changes) plus committed changes not in the default branch. Returns nil (scan everything) if git is unavailable or no baseline exists.
type Engine ¶
type Engine struct {
Config config.LintConfig
RootDir string
Modules []Module
Cache *Cache
Verbose bool
CacheHits atomic.Int64
CacheMisses atomic.Int64
}
Engine orchestrates lint modules across files.
func NewEngine ¶
func NewEngine(cfg config.LintConfig, rootDir string, moduleNames []string, skipNames []string, verbose bool, cache *Cache) (*Engine, error)
NewEngine creates a lint engine with the selected modules.
func (*Engine) CollectFiles ¶
CollectFiles walks the root directory and returns FileInfo for all regular files.
func (*Engine) ModuleNames ¶
ModuleNames returns the names of all active modules in this engine.
func (*Engine) RunWithStats ¶
func (e *Engine) RunWithStats(ctx context.Context, files []FileInfo) ([]Finding, []ModuleStats, error)
RunWithStats executes all modules and returns findings plus per-module statistics.
type FileInfo ¶
type FileInfo struct {
Path string // relative path from repo root
AbsPath string // absolute path on disk
Size int64
}
FileInfo is passed to each module for inspection.
type Finding ¶
type Finding struct {
File string
Line int
Column int
Module string
Severity Severity
Message string
}
Finding represents a single lint result.
type Module ¶
type Module interface {
Name() string
Check(ctx context.Context, file FileInfo) ([]Finding, error)
DefaultEnabled() bool
AutoDetect() []string // glob patterns that trigger auto-enable
}
Module is the interface every lint check implements.
type ModuleStats ¶
ModuleStats holds per-module scan statistics.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package modules contains all built-in lint modules.
|
Package modules contains all built-in lint modules. |
|
freshness
Package freshness checks for outdated dependencies across ecosystems: Dockerfile base images, pinned tool versions, Go modules, Rust crates, npm packages, Alpine APK, Debian/Ubuntu APT, and pip packages.
|
Package freshness checks for outdated dependencies across ecosystems: Dockerfile base images, pinned tool versions, Go modules, Rust crates, npm packages, Alpine APK, Debian/Ubuntu APT, and pip packages. |
|
osv
Package osv runs osv-scanner against lockfiles to detect known vulnerabilities from the OSV database.
|
Package osv runs osv-scanner against lockfiles to detect known vulnerabilities from the OSV database. |