Documentation
¶
Overview ¶
Package rules defines native lint-rule contracts and canonical metadata.
Index ¶
- func NodePrototype(kind NodeKind) (ast.Node, bool)
- type Category
- type Context
- func (c *Context) BooleanOption(name string) (bool, bool)
- func (c *Context) File() *source.File
- func (c *Context) IntegerOption(name string) (int64, bool)
- func (c *Context) PositionRange(start, end token.Pos) (source.Range, error)
- func (c *Context) PreviousSignificantToken(position token.Pos) (source.Token, bool)
- func (c *Context) Range(node ast.Node) (source.Range, error)
- func (c *Context) StringOption(name string) (string, bool)
- func (c *Context) StringsOption(name string) ([]string, bool)
- type ControlFlowContext
- func (c *ControlFlowContext) Body() *ast.BlockStmt
- func (c *ControlFlowContext) BooleanOption(name string) (bool, bool)
- func (c *ControlFlowContext) File() *source.File
- func (c *ControlFlowContext) Function() ast.Node
- func (c *ControlFlowContext) Graph() *cfg.CFG
- func (c *ControlFlowContext) IllTyped() bool
- func (c *ControlFlowContext) Info() *types.Info
- func (c *ControlFlowContext) IntegerOption(name string) (int64, bool)
- func (c *ControlFlowContext) Package() *types.Package
- func (c *ControlFlowContext) PackageID() string
- func (c *ControlFlowContext) PositionRange(start, end token.Pos) (source.Range, error)
- func (c *ControlFlowContext) Range(node ast.Node) (source.Range, error)
- func (c *ControlFlowContext) StringOption(name string) (string, bool)
- func (c *ControlFlowContext) StringsOption(name string) ([]string, bool)
- type ControlFlowRule
- type Deprecation
- type Diagnostic
- type Edit
- type Example
- type Finding
- type Fix
- type FixMetadata
- type FixSafety
- type Metadata
- type NodeKind
- type OptionKind
- type OptionMetadata
- type OptionSet
- type OptionValue
- type PackageContext
- func (c *PackageContext) BooleanOption(name string) (bool, bool)
- func (c *PackageContext) Dependencies() []PackageDependency
- func (c *PackageContext) FileSet() *token.FileSet
- func (c *PackageContext) Files() []PackageFile
- func (c *PackageContext) IllTyped() bool
- func (c *PackageContext) Info() *types.Info
- func (c *PackageContext) IntegerOption(name string) (int64, bool)
- func (c *PackageContext) OwnsTarget(file PackageFile) bool
- func (c *PackageContext) Package() *types.Package
- func (c *PackageContext) PackageID() string
- func (c *PackageContext) Sizes() types.Sizes
- func (c *PackageContext) StringOption(name string) (string, bool)
- func (c *PackageContext) StringsOption(name string) ([]string, bool)
- type PackageDependency
- func (d PackageDependency) FileSet() *token.FileSet
- func (d PackageDependency) Files() []PackageFile
- func (d PackageDependency) IllTyped() bool
- func (d PackageDependency) Info() *types.Info
- func (d PackageDependency) Package() *types.Package
- func (d PackageDependency) PackageID() string
- func (d PackageDependency) Sizes() types.Sizes
- type PackageFile
- func (f PackageFile) PositionRange(start, end token.Pos) (source.Range, error)
- func (f PackageFile) Range(node ast.Node) (source.Range, error)
- func (f PackageFile) Source() *source.File
- func (f PackageFile) Syntax() *ast.File
- func (f PackageFile) Target() bool
- func (f PackageFile) TokenRange(position token.Pos) (source.Range, error)
- type PackageFinding
- type PackageRule
- type Preset
- type Registry
- func (r *Registry) IDs() []string
- func (r *Registry) Lookup(id string) (Rule, bool)
- func (r *Registry) Metadata(id string) (Metadata, bool)
- func (r *Registry) OptionSchemas() map[string][]OptionMetadata
- func (r *Registry) Resolve(preset Preset, overrides map[string]Severity) ([]Selection, error)
- func (r *Registry) ResolveConfigured(preset Preset, overrides map[string]Severity, options map[string]OptionSet) ([]Selection, error)
- func (r *Registry) ResolveConfiguredForGoVersion(preset Preset, overrides map[string]Severity, options map[string]OptionSet, ...) ([]Selection, error)
- type Related
- type Requirement
- type Rule
- type SSAContext
- func (c *SSAContext) BooleanOption(name string) (bool, bool)
- func (c *SSAContext) File() *source.File
- func (c *SSAContext) FileSet() *token.FileSet
- func (c *SSAContext) Function() *ssa.Function
- func (c *SSAContext) IllTyped() bool
- func (c *SSAContext) Info() *types.Info
- func (c *SSAContext) IntegerOption(name string) (int64, bool)
- func (c *SSAContext) Package() *types.Package
- func (c *SSAContext) PackageID() string
- func (c *SSAContext) PositionRange(start, end token.Pos) (source.Range, error)
- func (c *SSAContext) Program() *ssa.Program
- func (c *SSAContext) Range(node ast.Node) (source.Range, error)
- func (c *SSAContext) SSAPackage() *ssa.Package
- func (c *SSAContext) StringOption(name string) (string, bool)
- func (c *SSAContext) StringsOption(name string) ([]string, bool)
- func (c *SSAContext) Syntax() ast.Node
- func (c *SSAContext) TokenRange(position token.Pos) (source.Range, error)
- type SSARule
- type Selection
- type Severity
- type SyntaxFileRule
- type SyntaxRule
- type TypesContext
- func (c *TypesContext) BooleanOption(name string) (bool, bool)
- func (c *TypesContext) File() *source.File
- func (c *TypesContext) IllTyped() bool
- func (c *TypesContext) Info() *types.Info
- func (c *TypesContext) IntegerOption(name string) (int64, bool)
- func (c *TypesContext) Package() *types.Package
- func (c *TypesContext) PackageID() string
- func (c *TypesContext) PositionRange(start, end token.Pos) (source.Range, error)
- func (c *TypesContext) Range(node ast.Node) (source.Range, error)
- func (c *TypesContext) StringOption(name string) (string, bool)
- func (c *TypesContext) StringsOption(name string) ([]string, bool)
- func (c *TypesContext) TokenRange(position token.Pos) (source.Range, error)
- type TypesRule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Category ¶
type Category string
Category classifies the observable concern reported by a rule.
const ( CategoryCorrectness Category = "correctness" CategorySafety Category = "safety" CategorySuspicious Category = "suspicious" CategoryPerformance Category = "performance" CategoryComplexity Category = "complexity" CategoryStyle Category = "style" CategoryMigration Category = "migration" CategoryMaintainability Category = "maintainability" )
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context is the immutable per-file syntax rule context.
func NewContext ¶
NewContext creates an immutable per-file rule context.
func (*Context) BooleanOption ¶
BooleanOption returns one configured boolean rule option.
func (*Context) IntegerOption ¶
IntegerOption returns one configured integer rule option.
func (*Context) PositionRange ¶
PositionRange converts a token range when a caller already owns positions.
func (*Context) PreviousSignificantToken ¶
PreviousSignificantToken returns the lexical token before a parsed position, ignoring comments and automatically inserted semicolons.
func (*Context) StringOption ¶
StringOption returns one configured string rule option.
type ControlFlowContext ¶
type ControlFlowContext struct {
// contains filtered or unexported fields
}
ControlFlowContext binds one function graph to its shared typed package and exact immutable physical source.
func NewControlFlowContext ¶
func NewControlFlowContext( typesContext *TypesContext, function ast.Node, body *ast.BlockStmt, graph *cfg.CFG, ) *ControlFlowContext
NewControlFlowContext constructs one read-only control-flow rule context.
func (*ControlFlowContext) Body ¶
func (c *ControlFlowContext) Body() *ast.BlockStmt
Body returns the function body used to construct the graph.
func (*ControlFlowContext) BooleanOption ¶
func (c *ControlFlowContext) BooleanOption(name string) (bool, bool)
BooleanOption returns one configured boolean rule option.
func (*ControlFlowContext) File ¶
func (c *ControlFlowContext) File() *source.File
File returns the exact immutable source version for the current package AST.
func (*ControlFlowContext) Function ¶
func (c *ControlFlowContext) Function() ast.Node
Function returns the function declaration or literal that owns the graph.
func (*ControlFlowContext) Graph ¶
func (c *ControlFlowContext) Graph() *cfg.CFG
Graph returns the shared read-only control-flow graph for the function.
func (*ControlFlowContext) IllTyped ¶
func (c *ControlFlowContext) IllTyped() bool
IllTyped reports whether package loading encountered type errors.
func (*ControlFlowContext) Info ¶
func (c *ControlFlowContext) Info() *types.Info
Info returns the shared read-only type information for package AST nodes.
func (*ControlFlowContext) IntegerOption ¶
func (c *ControlFlowContext) IntegerOption(name string) (int64, bool)
IntegerOption returns one configured integer rule option.
func (*ControlFlowContext) Package ¶
func (c *ControlFlowContext) Package() *types.Package
Package returns the shared read-only go/types package.
func (*ControlFlowContext) PackageID ¶
func (c *ControlFlowContext) PackageID() string
PackageID returns the opaque go/packages identity for the current package.
func (*ControlFlowContext) PositionRange ¶
PositionRange maps package positions to the exact current physical source.
func (*ControlFlowContext) Range ¶
Range maps a package AST node to its current physical source range.
func (*ControlFlowContext) StringOption ¶
func (c *ControlFlowContext) StringOption(name string) (string, bool)
StringOption returns one configured string rule option.
func (*ControlFlowContext) StringsOption ¶
func (c *ControlFlowContext) StringsOption(name string) ([]string, bool)
StringsOption returns one independently owned string-list rule option.
type ControlFlowRule ¶
type ControlFlowRule interface {
Rule
RunControlFlow(*ControlFlowContext) ([]Finding, error)
}
ControlFlowRule runs once for each function declaration and function literal through a graph shared with every enabled control-flow rule.
type Deprecation ¶
Deprecation records a rule replacement without silently changing its ID.
type Diagnostic ¶
type Diagnostic struct {
RuleID string
Severity Severity
MessageKey string
Message string
Path string
Digest source.Digest
Range source.Range
Related []Related
Notes []string
Help string
Fixes []Fix
}
Diagnostic is one source-versioned, reporter-ready lint diagnostic.
type Finding ¶
type Finding struct {
MessageKey string
Message string
Range source.Range
Related []Related
Notes []string
Help string
Fixes []Fix
}
Finding is the rule-owned portion of a diagnostic.
type FixMetadata ¶
FixMetadata describes one named transformation a rule may offer.
type FixSafety ¶
type FixSafety string
FixSafety controls whether a fix may run without an explicit opt-in.
type Metadata ¶
type Metadata struct {
ID string
Summary string
Documentation string
DefaultSeverity Severity
Presets []Preset
MinimumGoVersion string
Requirement Requirement
NodeInterests []NodeKind
RequiresDependencySyntax bool
RunOnGenerated bool
RunDespiteTypeErrors bool
Categories []Category
Fixes []FixMetadata
Options []OptionMetadata
Deprecation *Deprecation
KnownLimitations []string
Examples []Example
}
Metadata is the canonical rule documentation and scheduling contract.
func CloneMetadata ¶
CloneMetadata returns an independent copy of rule metadata.
type NodeKind ¶
type NodeKind string
NodeKind is a stable native interest in one Go syntax node type.
const ( NodeFile NodeKind = "file" NodeComment NodeKind = "comment" NodeCommentGroup NodeKind = "comment-group" NodeField NodeKind = "field" NodeFieldList NodeKind = "field-list" NodeBadExpr NodeKind = "bad-expr" NodeIdent NodeKind = "ident" NodeEllipsis NodeKind = "ellipsis" NodeBasicLit NodeKind = "basic-lit" NodeFuncLit NodeKind = "func-lit" NodeCompositeLit NodeKind = "composite-lit" NodeParenExpr NodeKind = "paren-expr" NodeSelectorExpr NodeKind = "selector-expr" NodeIndexExpr NodeKind = "index-expr" NodeIndexListExpr NodeKind = "index-list-expr" NodeSliceExpr NodeKind = "slice-expr" NodeTypeAssertExpr NodeKind = "type-assert-expr" NodeCallExpr NodeKind = "call-expr" NodeStarExpr NodeKind = "star-expr" NodeUnaryExpr NodeKind = "unary-expr" NodeBinaryExpr NodeKind = "binary-expr" NodeKeyValueExpr NodeKind = "key-value-expr" NodeArrayType NodeKind = "array-type" NodeStructType NodeKind = "struct-type" NodeFuncType NodeKind = "func-type" NodeInterfaceType NodeKind = "interface-type" NodeMapType NodeKind = "map-type" NodeChanType NodeKind = "chan-type" NodeBadStmt NodeKind = "bad-stmt" NodeDeclStmt NodeKind = "decl-stmt" NodeEmptyStmt NodeKind = "empty-stmt" NodeLabeledStmt NodeKind = "labeled-stmt" NodeExprStmt NodeKind = "expr-stmt" NodeSendStmt NodeKind = "send-stmt" NodeIncDecStmt NodeKind = "inc-dec-stmt" NodeAssignStmt NodeKind = "assign-stmt" NodeGoStmt NodeKind = "go-stmt" NodeDeferStmt NodeKind = "defer-stmt" NodeReturnStmt NodeKind = "return-stmt" NodeBranchStmt NodeKind = "branch-stmt" NodeBlockStmt NodeKind = "block-stmt" NodeIfStmt NodeKind = "if-stmt" NodeCaseClause NodeKind = "case-clause" NodeSwitchStmt NodeKind = "switch-stmt" NodeTypeSwitchStmt NodeKind = "type-switch-stmt" NodeCommClause NodeKind = "comm-clause" NodeSelectStmt NodeKind = "select-stmt" NodeForStmt NodeKind = "for-stmt" NodeRangeStmt NodeKind = "range-stmt" NodeBadDecl NodeKind = "bad-decl" NodeGenDecl NodeKind = "gen-decl" NodeFuncDecl NodeKind = "func-decl" NodeImportSpec NodeKind = "import-spec" NodeValueSpec NodeKind = "value-spec" NodeTypeSpec NodeKind = "type-spec" )
type OptionKind ¶
type OptionKind string
OptionKind is the scalar type accepted by one rule option.
const ( OptionBoolean OptionKind = "boolean" OptionInteger OptionKind = "integer" OptionString OptionKind = "string" OptionStrings OptionKind = "strings" )
type OptionMetadata ¶
type OptionMetadata struct {
Name string
Summary string
Kind OptionKind
Required bool
Default *OptionValue
}
OptionMetadata is one typed configuration field owned by a rule.
type OptionSet ¶
type OptionSet struct {
// contains filtered or unexported fields
}
OptionSet is one immutable name-indexed rule configuration snapshot.
func NewOptionSet ¶
func NewOptionSet(values map[string]OptionValue) OptionSet
NewOptionSet snapshots independently owned rule option values.
func (OptionSet) CanonicalBytes ¶
CanonicalBytes returns one deterministic cache identity for this option set.
type OptionValue ¶
type OptionValue struct {
// contains filtered or unexported fields
}
OptionValue is one immutable typed rule configuration value.
func BooleanOption ¶
func BooleanOption(value bool) OptionValue
BooleanOption constructs one boolean rule option value.
func IntegerOption ¶
func IntegerOption(value int64) OptionValue
IntegerOption constructs one integer rule option value.
func StringOption ¶
func StringOption(value string) OptionValue
StringOption constructs one string rule option value.
func StringsOption ¶
func StringsOption(value []string) OptionValue
StringsOption constructs one independently owned string-list rule option.
func (OptionValue) Kind ¶
func (v OptionValue) Kind() OptionKind
Kind returns the declared scalar kind of this value.
func (OptionValue) String ¶
func (v OptionValue) String() string
String renders one deterministic human-readable option value.
type PackageContext ¶
type PackageContext struct {
// contains filtered or unexported fields
}
PackageContext exposes one shared typed package and its canonical physical source mapping to a package-wide native rule.
func NewPackageContext ¶
func NewPackageContext( fileSet *token.FileSet, packageID string, package_ *types.Package, info *types.Info, sizes types.Sizes, illTyped bool, files []PackageFile, dependencies []PackageDependency, options OptionSet, ) *PackageContext
NewPackageContext constructs one read-only package-wide rule context.
func (*PackageContext) BooleanOption ¶
func (c *PackageContext) BooleanOption(name string) (bool, bool)
BooleanOption returns one configured boolean rule option.
func (*PackageContext) Dependencies ¶
func (c *PackageContext) Dependencies() []PackageDependency
Dependencies returns dependency packages in deterministic dependency-first order. Rules without a declared dependency-syntax requirement receive none.
func (*PackageContext) FileSet ¶
func (c *PackageContext) FileSet() *token.FileSet
FileSet returns the shared read-only package position mapping.
func (*PackageContext) Files ¶
func (c *PackageContext) Files() []PackageFile
Files returns independent descriptors in canonical physical path order.
func (*PackageContext) IllTyped ¶
func (c *PackageContext) IllTyped() bool
IllTyped reports whether package loading encountered type errors.
func (*PackageContext) Info ¶
func (c *PackageContext) Info() *types.Info
Info returns the shared read-only type information for package AST nodes.
func (*PackageContext) IntegerOption ¶
func (c *PackageContext) IntegerOption(name string) (int64, bool)
IntegerOption returns one configured integer rule option.
func (*PackageContext) OwnsTarget ¶
func (c *PackageContext) OwnsTarget(file PackageFile) bool
OwnsTarget reports whether a descriptor came from this exact callback and is eligible for reporter-visible output.
func (*PackageContext) Package ¶
func (c *PackageContext) Package() *types.Package
Package returns the shared read-only go/types package.
func (*PackageContext) PackageID ¶
func (c *PackageContext) PackageID() string
PackageID returns the opaque go/packages identity for this package.
func (*PackageContext) Sizes ¶
func (c *PackageContext) Sizes() types.Sizes
Sizes returns the shared architecture-specific type-size implementation.
func (*PackageContext) StringOption ¶
func (c *PackageContext) StringOption(name string) (string, bool)
StringOption returns one configured string rule option.
func (*PackageContext) StringsOption ¶
func (c *PackageContext) StringsOption(name string) ([]string, bool)
StringsOption returns one independently owned string-list rule option.
type PackageDependency ¶
type PackageDependency struct {
// contains filtered or unexported fields
}
PackageDependency is one immutable dependency package view exposed only to package-wide rules that declare dependency syntax in canonical metadata.
func NewPackageDependency ¶
func NewPackageDependency( fileSet *token.FileSet, packageID string, package_ *types.Package, info *types.Info, sizes types.Sizes, illTyped bool, files []PackageFile, ) PackageDependency
NewPackageDependency constructs one read-only dependency-package view.
func (PackageDependency) FileSet ¶
func (d PackageDependency) FileSet() *token.FileSet
FileSet returns the dependency's shared read-only position mapping.
func (PackageDependency) Files ¶
func (d PackageDependency) Files() []PackageFile
Files returns independent, non-target dependency file descriptors in canonical physical path order.
func (PackageDependency) IllTyped ¶
func (d PackageDependency) IllTyped() bool
IllTyped reports whether dependency loading encountered type errors.
func (PackageDependency) Info ¶
func (d PackageDependency) Info() *types.Info
Info returns the shared read-only type information for dependency AST nodes.
func (PackageDependency) Package ¶
func (d PackageDependency) Package() *types.Package
Package returns the shared read-only go/types package for this dependency.
func (PackageDependency) PackageID ¶
func (d PackageDependency) PackageID() string
PackageID returns the opaque go/packages identity for this dependency.
func (PackageDependency) Sizes ¶
func (d PackageDependency) Sizes() types.Sizes
Sizes returns the dependency's architecture-specific type sizes.
type PackageFile ¶
type PackageFile struct {
// contains filtered or unexported fields
}
PackageFile binds one package AST to its exact immutable physical source and records whether the current package invocation owns reporter-visible output for that file.
func NewPackageFile ¶
func NewPackageFile( file *source.File, syntax *ast.File, fileSet *token.FileSet, target bool, ) PackageFile
NewPackageFile constructs one read-only package-file view.
func (PackageFile) PositionRange ¶
PositionRange maps package positions to this exact physical source.
func (PackageFile) Source ¶
func (f PackageFile) Source() *source.File
Source returns the exact immutable source captured for this package file.
func (PackageFile) Syntax ¶
func (f PackageFile) Syntax() *ast.File
Syntax returns the shared package AST for this physical file.
func (PackageFile) Target ¶
func (f PackageFile) Target() bool
Target reports whether this package invocation owns diagnostics for the file.
func (PackageFile) TokenRange ¶
TokenRange maps a package position to this file's exact lexical token.
type PackageFinding ¶
type PackageFinding struct {
File PackageFile
Finding Finding
}
PackageFinding binds one ordinary finding to the owned physical file it targets.
type PackageRule ¶
type PackageRule interface {
Rule
RunPackage(*PackageContext) ([]PackageFinding, error)
}
PackageRule runs once for each selected typed package and may report against the package's canonically owned physical source files.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is an immutable, ID-ordered native rule set.
func NewDefaultRegistry ¶
NewDefaultRegistry constructs the canonical built-in rule registry.
func NewRegistry ¶
NewRegistry validates and snapshots native rules.
func (*Registry) OptionSchemas ¶
func (r *Registry) OptionSchemas() map[string][]OptionMetadata
OptionSchemas returns independent typed option metadata by rule ID.
func (*Registry) Resolve ¶
Resolve applies one preset and explicit overrides into an ordered selection.
func (*Registry) ResolveConfigured ¶
func (r *Registry) ResolveConfigured( preset Preset, overrides map[string]Severity, options map[string]OptionSet, ) ([]Selection, error)
ResolveConfigured applies severity and typed option configuration into an ordered immutable selection.
func (*Registry) ResolveConfiguredForGoVersion ¶
func (r *Registry) ResolveConfiguredForGoVersion( preset Preset, overrides map[string]Severity, options map[string]OptionSet, sourceGoVersion string, ) ([]Selection, error)
ResolveConfiguredForGoVersion applies configuration and omits rules whose declared minimum exceeds the selected normalized source language version. An empty source version retains the version-independent registry contract.
type Requirement ¶
type Requirement uint8
Requirement is the most expensive representation a rule requires.
const ( RequireLexical Requirement = iota RequireSyntax RequireTypes RequireControlFlow RequireSSA )
func MaximumRequirement ¶
func MaximumRequirement(selection []Selection) Requirement
MaximumRequirement returns the most expensive selected representation.
func (Requirement) String ¶
func (r Requirement) String() string
type Rule ¶
type Rule interface {
Metadata() Metadata
}
Rule is the common metadata boundary implemented by every native rule.
type SSAContext ¶
type SSAContext struct {
// contains filtered or unexported fields
}
SSAContext binds one source function to its shared SSA program, typed package, and exact immutable physical source.
func NewSSAContext ¶
func NewSSAContext( typesContext *TypesContext, program *ssa.Program, ssaPackage *ssa.Package, function *ssa.Function, syntax ast.Node, ) *SSAContext
NewSSAContext constructs one read-only SSA rule context.
func (*SSAContext) BooleanOption ¶
func (c *SSAContext) BooleanOption(name string) (bool, bool)
BooleanOption returns one configured boolean rule option.
func (*SSAContext) File ¶
func (c *SSAContext) File() *source.File
File returns the exact immutable source version for the current package AST.
func (*SSAContext) FileSet ¶
func (c *SSAContext) FileSet() *token.FileSet
FileSet returns the shared read-only package position mapping.
func (*SSAContext) Function ¶
func (c *SSAContext) Function() *ssa.Function
Function returns the shared read-only SSA function.
func (*SSAContext) IllTyped ¶
func (c *SSAContext) IllTyped() bool
IllTyped reports whether package loading encountered type errors.
func (*SSAContext) Info ¶
func (c *SSAContext) Info() *types.Info
Info returns the shared read-only type information for package AST nodes.
func (*SSAContext) IntegerOption ¶
func (c *SSAContext) IntegerOption(name string) (int64, bool)
IntegerOption returns one configured integer rule option.
func (*SSAContext) Package ¶
func (c *SSAContext) Package() *types.Package
Package returns the shared read-only go/types package.
func (*SSAContext) PackageID ¶
func (c *SSAContext) PackageID() string
PackageID returns the opaque go/packages identity for the current package.
func (*SSAContext) PositionRange ¶
PositionRange maps package positions to the exact current physical source.
func (*SSAContext) Program ¶
func (c *SSAContext) Program() *ssa.Program
Program returns the shared read-only SSA program for the package load.
func (*SSAContext) SSAPackage ¶
func (c *SSAContext) SSAPackage() *ssa.Package
SSAPackage returns the shared read-only SSA package for the function.
func (*SSAContext) StringOption ¶
func (c *SSAContext) StringOption(name string) (string, bool)
StringOption returns one configured string rule option.
func (*SSAContext) StringsOption ¶
func (c *SSAContext) StringsOption(name string) ([]string, bool)
StringsOption returns one independently owned string-list rule option.
func (*SSAContext) Syntax ¶
func (c *SSAContext) Syntax() ast.Node
Syntax returns the function declaration or literal represented by Function.
func (*SSAContext) TokenRange ¶
TokenRange maps a package position to the exact physical lexical token.
type SSARule ¶
type SSARule interface {
Rule
RunSSA(*SSAContext) ([]Finding, error)
}
SSARule runs once for each source function through a program shared with every enabled SSA rule.
type Selection ¶
type Selection struct {
ID string
Severity Severity
Requirement Requirement
Options OptionSet
}
Selection is one enabled rule with its resolved severity and cost.
type SyntaxFileRule ¶
SyntaxFileRule runs once over one immutable source-backed syntax view.
type SyntaxRule ¶
SyntaxRule receives only nodes matching its declared interests.
type TypesContext ¶
type TypesContext struct {
// contains filtered or unexported fields
}
TypesContext binds one package AST to its exact immutable physical source.
func NewTypesContext ¶
func NewTypesContext( file *source.File, fileSet *token.FileSet, packageID string, package_ *types.Package, info *types.Info, illTyped bool, options OptionSet, ) *TypesContext
NewTypesContext constructs one read-only typed rule context.
func (*TypesContext) BooleanOption ¶
func (c *TypesContext) BooleanOption(name string) (bool, bool)
BooleanOption returns one configured boolean rule option.
func (*TypesContext) File ¶
func (c *TypesContext) File() *source.File
File returns the exact immutable source version for the current package AST.
func (*TypesContext) IllTyped ¶
func (c *TypesContext) IllTyped() bool
IllTyped reports whether package loading encountered type errors.
func (*TypesContext) Info ¶
func (c *TypesContext) Info() *types.Info
Info returns the shared read-only type information for package AST nodes.
func (*TypesContext) IntegerOption ¶
func (c *TypesContext) IntegerOption(name string) (int64, bool)
IntegerOption returns one configured integer rule option.
func (*TypesContext) Package ¶
func (c *TypesContext) Package() *types.Package
Package returns the shared read-only go/types package.
func (*TypesContext) PackageID ¶
func (c *TypesContext) PackageID() string
PackageID returns the opaque go/packages identity for the current package.
func (*TypesContext) PositionRange ¶
PositionRange maps package positions to the exact current physical source.
func (*TypesContext) StringOption ¶
func (c *TypesContext) StringOption(name string) (string, bool)
StringOption returns one configured string rule option.
func (*TypesContext) StringsOption ¶
func (c *TypesContext) StringsOption(name string) ([]string, bool)
StringsOption returns one independently owned string-list rule option.
func (*TypesContext) TokenRange ¶
TokenRange maps a package position to the exact physical lexical token.