forbidigo

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: Apache-2.0 Imports: 12 Imported by: 10

Documentation

Overview

Package forbidigo provides a linter for forbidding the use of specific identifiers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPatterns

func DefaultPatterns() []string

Types

type ApplyOptionFunc added in v1.1.0

type ApplyOptionFunc func(c *config) error

type Issue

type Issue interface {
	Details() string
	Pos() token.Pos
	Position() token.Position
	String() string
}

type Linter

type Linter struct {
	// contains filtered or unexported fields
}

func NewLinter

func NewLinter(patterns []string, options ...Option) (*Linter, error)

func (*Linter) Run deprecated

func (l *Linter) Run(fset *token.FileSet, nodes ...ast.Node) ([]Issue, error)

Deprecated: Run was the original entrypoint before RunWithConfig was introduced to support additional match patterns that need additional information.

func (*Linter) RunWithConfig added in v1.4.0

func (l *Linter) RunWithConfig(config RunConfig, nodes ...ast.Node) ([]Issue, error)

type Option added in v1.1.0

type Option interface {
	// contains filtered or unexported methods
}

func OptionAnalyzeTypes added in v1.5.0

func OptionAnalyzeTypes(o bool) Option

OptionAnalyzeTypes enable to match canonical names for types and interfaces using type info

func OptionExcludeGodocExamples added in v1.1.0

func OptionExcludeGodocExamples(o bool) Option

OptionExcludeGodocExamples don't check inside Godoc examples (see https://blog.golang.org/examples)

func OptionIgnorePermitDirectives added in v1.1.0

func OptionIgnorePermitDirectives(o bool) Option

OptionIgnorePermitDirectives don't check for `permit` directives(for example, in favor of `nolint`)

type RunConfig added in v1.4.0

type RunConfig struct {
	// FSet is required.
	Fset *token.FileSet

	// TypesInfo is needed for expanding source code expressions.
	// Nil disables that step, i.e. patterns match the literal source code.
	TypesInfo *types.Info

	// DebugLog is used to print debug messages. May be nil.
	DebugLog func(format string, args ...interface{})
}

RunConfig provides information that the linter needs for different kinds of match patterns. Ideally, all fields should get set. More fields may get added in the future as needed.

type UsedIssue

type UsedIssue struct {
	// contains filtered or unexported fields
}

func (UsedIssue) Details

func (a UsedIssue) Details() string

func (UsedIssue) Pos added in v1.4.0

func (a UsedIssue) Pos() token.Pos

func (UsedIssue) Position

func (a UsedIssue) Position() token.Position

func (UsedIssue) String

func (a UsedIssue) String() string

Jump to

Keyboard shortcuts

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