linter

package
v1.62.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: GPL-3.0 Imports: 10 Imported by: 50

Documentation

Index

Constants

View Source
const (
	PresetBugs        = "bugs"        // Related to bugs detection.
	PresetComment     = "comment"     // Related to comments analysis.
	PresetComplexity  = "complexity"  // Related to code complexity analysis.
	PresetError       = "error"       // Related to error handling analysis.
	PresetFormatting  = "format"      // Related to code formatting.
	PresetImport      = "import"      // Related to imports analysis.
	PresetMetaLinter  = "metalinter"  // Related to linter that contains multiple rules or multiple linters.
	PresetModule      = "module"      // Related to Go modules analysis.
	PresetPerformance = "performance" // Related to performance.
	PresetSQL         = "sql"         // Related to SQL.
	PresetStyle       = "style"       // Related to coding style.
	PresetTest        = "test"        // Related to the analysis of the code of the tests.
	PresetUnused      = "unused"      // Related to the detection of unused code.
)
View Source
const LastLinter = "nolintlint"

LastLinter nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives.

Variables

This section is empty.

Functions

func IsGoLowerThanGo122 added in v1.57.0

func IsGoLowerThanGo122() func(cfg *config.Config) error

Types

type Config

type Config struct {
	Linter           Linter
	EnabledByDefault bool

	LoadMode packages.LoadMode

	InPresets        []string
	AlternativeNames []string

	OriginalURL     string // URL of original (not forked) repo, needed for autogenerated README
	Internal        bool   // Internal linters cannot be disabled (ex: typecheck).
	CanAutoFix      bool
	IsSlow          bool
	DoesChangeTypes bool

	Since       string
	Deprecation *Deprecation
}

func NewConfig

func NewConfig(linter Linter) *Config

func (*Config) AllNames added in v1.10.2

func (lc *Config) AllNames() []string

func (*Config) ConsiderSlow added in v1.19.0

func (lc *Config) ConsiderSlow() *Config

func (*Config) Deprecated added in v1.38.0

func (lc *Config) Deprecated(message, version, replacement string, level DeprecationLevel) *Config

func (*Config) DeprecatedError added in v1.58.0

func (lc *Config) DeprecatedError(message, version, replacement string) *Config

func (*Config) DeprecatedWarning added in v1.58.0

func (lc *Config) DeprecatedWarning(message, version, replacement string) *Config

func (*Config) IsDeprecated added in v1.38.0

func (lc *Config) IsDeprecated() bool

func (*Config) IsSlowLinter added in v1.19.0

func (lc *Config) IsSlowLinter() bool

func (*Config) Name added in v1.10.2

func (lc *Config) Name() string

func (*Config) WithAlternativeNames added in v1.10.2

func (lc *Config) WithAlternativeNames(names ...string) *Config

func (*Config) WithAutoFix added in v1.15.0

func (lc *Config) WithAutoFix() *Config

func (*Config) WithChangeTypes added in v1.27.0

func (lc *Config) WithChangeTypes() *Config

func (*Config) WithEnabledByDefault added in v1.53.3

func (lc *Config) WithEnabledByDefault() *Config

func (*Config) WithInternal added in v1.54.0

func (lc *Config) WithInternal() *Config

func (*Config) WithLoadFiles added in v1.19.0

func (lc *Config) WithLoadFiles() *Config

func (*Config) WithLoadForGoAnalysis added in v1.19.0

func (lc *Config) WithLoadForGoAnalysis() *Config

func (*Config) WithNoopFallback added in v1.45.0

func (lc *Config) WithNoopFallback(cfg *config.Config, cond func(cfg *config.Config) error) *Config

func (*Config) WithPresets

func (lc *Config) WithPresets(presets ...string) *Config

func (*Config) WithSince added in v1.39.0

func (lc *Config) WithSince(version string) *Config

func (*Config) WithURL

func (lc *Config) WithURL(url string) *Config

type Context

type Context struct {
	// Packages are deduplicated (test and normal packages) packages
	Packages []*packages.Package

	// OriginalPackages aren't deduplicated: they contain both normal and test
	// version for each of packages
	OriginalPackages []*packages.Package

	Cfg       *config.Config
	FileCache *fsutils.FileCache
	Log       logutils.Log

	PkgCache  *cache.Cache
	LoadGuard *load.Guard
}

func (*Context) ClearTypesInPackages added in v1.23.2

func (c *Context) ClearTypesInPackages()

func (*Context) Settings

func (c *Context) Settings() *config.LintersSettings

type Deprecation added in v1.39.0

type Deprecation struct {
	Since       string
	Message     string
	Replacement string
	Level       DeprecationLevel
}

type DeprecationLevel added in v1.58.0

type DeprecationLevel int
const (
	DeprecationNone DeprecationLevel = iota
	DeprecationWarning
	DeprecationError
)

type Linter

type Linter interface {
	Run(ctx context.Context, lintCtx *Context) ([]result.Issue, error)
	Name() string
	Desc() string
}

type Noop added in v1.45.0

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

func NewNoop added in v1.57.0

func NewNoop(l Linter, reason string) Noop

func NewNoopDeprecated added in v1.57.0

func NewNoopDeprecated(name string, cfg *config.Config, level DeprecationLevel) Noop

func (Noop) Desc added in v1.45.0

func (n Noop) Desc() string

func (Noop) Name added in v1.45.0

func (n Noop) Name() string

func (Noop) Run added in v1.45.0

func (n Noop) Run(_ context.Context, lintCtx *Context) ([]result.Issue, error)

Jump to

Keyboard shortcuts

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