Documentation
¶
Index ¶
- type Analyzer
- func (a *Analyzer) Analyze(ctx *core.AnalysisContext) []core.Finding
- func (a *Analyzer) Category() core.Category
- func (a *Analyzer) Description() string
- func (a *Analyzer) ID() string
- func (a *Analyzer) Name() string
- func (a *Analyzer) Needs() core.Requirements
- func (a *Analyzer) Stage() core.StageID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Analyzer ¶
type Analyzer struct{}
Analyzer detects variable and builtin shadowing in Go functions. It walks each function body with a scope stack and flags any declaration whose name is already visible from an enclosing scope. It also reports the narrower case Go allows silently: a `:=` that reassigns a name bound by the function signature rather than declaring a new one.
Known limit: function literals are not descended into, so a closure that re-binds an outer name is not reported. Walking them is a one-line change (a FuncLit branch in walkStmt) but it surfaces the idiomatic `if err := f(); err != nil` inside a closure, which is not worth reporting until `err` in an if-init is allowlisted.
func (*Analyzer) Description ¶
func (*Analyzer) Needs ¶
func (a *Analyzer) Needs() core.Requirements