shadowing

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

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 NewAnalyzer

func NewAnalyzer() *Analyzer

NewAnalyzer creates a shadowing analyzer.

func (*Analyzer) Analyze

func (a *Analyzer) Analyze(ctx *core.AnalysisContext) []core.Finding

func (*Analyzer) Category

func (a *Analyzer) Category() core.Category

func (*Analyzer) Description

func (a *Analyzer) Description() string

func (*Analyzer) ID

func (a *Analyzer) ID() string

func (*Analyzer) Name

func (a *Analyzer) Name() string

func (*Analyzer) Needs

func (a *Analyzer) Needs() core.Requirements

func (*Analyzer) Stage

func (a *Analyzer) Stage() core.StageID

Jump to

Keyboard shortcuts

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