linter

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

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

This section is empty.

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
	CanAutoFix      bool
	IsSlow          bool
	DoesChangeTypes bool

	Since       string
	Deprecation *Deprecation
}

func NewConfig

func NewConfig(linter Linter) *Config

func (*Config) AllNames

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

func (*Config) ConsiderSlow

func (lc *Config) ConsiderSlow() *Config

func (*Config) Deprecated

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

func (*Config) IsDeprecated

func (lc *Config) IsDeprecated() bool

func (*Config) IsSlowLinter

func (lc *Config) IsSlowLinter() bool

func (*Config) Name

func (lc *Config) Name() string

func (*Config) WithAlternativeNames

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

func (*Config) WithAutoFix

func (lc *Config) WithAutoFix() *Config

func (*Config) WithChangeTypes

func (lc *Config) WithChangeTypes() *Config

func (*Config) WithLoadFiles

func (lc *Config) WithLoadFiles() *Config

func (*Config) WithLoadForGoAnalysis

func (lc *Config) WithLoadForGoAnalysis() *Config

func (*Config) WithNoopFallback

func (lc *Config) WithNoopFallback(cfg *config.Config) *Config

func (*Config) WithPresets

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

func (*Config) WithSince

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
	LineCache *fsutils.LineCache
	Log       logutils.Log

	PkgCache  *pkgcache.Cache
	LoadGuard *load.Guard
}

func (*Context) ClearTypesInPackages

func (c *Context) ClearTypesInPackages()

func (*Context) Settings

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

type Deprecation

type Deprecation struct {
	Since       string
	Message     string
	Replacement string
}

type Linter

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

type Noop

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

func (Noop) Desc

func (n Noop) Desc() string

func (Noop) Name

func (n Noop) Name() string

func (Noop) Run

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