forbidigo

package
v0.0.0-...-55b87b1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

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

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

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

type Option

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

func OptionAnalyzeTypes

func OptionAnalyzeTypes(o bool) Option

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

func OptionExcludeGodocExamples

func OptionExcludeGodocExamples(o bool) Option

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

func OptionIgnorePermitDirectives

func OptionIgnorePermitDirectives(o bool) Option

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

type RunConfig

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

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