Documentation
¶
Index ¶
- Constants
- Variables
- type Cgo
- type Diff
- type ExclusionPaths
- type ExclusionRules
- type FilenameUnadjuster
- type Fixer
- type GeneratedFileFilter
- type IdentifierMarker
- type InvalidIssue
- type MaxFromLinter
- type MaxPerFileFromLinter
- type MaxSameIssues
- type NolintFilter
- type PathAbsoluter
- type PathPrettifier
- type PathRelativity
- type PathShortener
- type Processor
- type Severity
- type SkipDirs
- type SkipFiles
- type SortResults
- type SourceCode
- type UniqByLine
Constants ¶
const ( AutogeneratedModeLax = "lax" AutogeneratedModeStrict = "strict" AutogeneratedModeDisable = "disable" )
Variables ¶
var StdExcludeDirRegexps = []string{
normalizePathRegex("vendor"),
normalizePathRegex("third_party"),
normalizePathRegex("testdata"),
normalizePathRegex("examples"),
normalizePathRegex("Godeps"),
normalizePathRegex("builtin"),
}
Functions ¶
This section is empty.
Types ¶
type Cgo ¶
type Cgo struct {
// contains filtered or unexported fields
}
Cgo filters cgo artifacts.
Some linters (e.g. gosec, etc.) return incorrect file paths for cgo files.
Require absolute file path.
type Diff ¶
type Diff struct {
// contains filtered or unexported fields
}
Diff filters issues based on options `new`, `new-from-rev`, etc.
Uses `git`. The paths inside the patch are relative to the path where git is run (the same location where golangci-lint is run).
Warning: it doesn't use `path-prefix` option.
type ExclusionPaths ¶ added in v1.64.0
type ExclusionPaths struct {
// contains filtered or unexported fields
}
func NewExclusionPaths ¶ added in v1.64.0
func NewExclusionPaths(log logutils.Log, cfg *config.LinterExclusions) (*ExclusionPaths, error)
func (*ExclusionPaths) Finish ¶ added in v1.64.0
func (p *ExclusionPaths) Finish()
func (*ExclusionPaths) Name ¶ added in v1.64.0
func (*ExclusionPaths) Name() string
type ExclusionRules ¶ added in v1.64.0
type ExclusionRules struct {
// contains filtered or unexported fields
}
func NewExclusionRules ¶ added in v1.64.0
func NewExclusionRules(log logutils.Log, files *fsutils.Files, cfg *config.LinterExclusions, oldCfg *config.Issues) *ExclusionRules
func (*ExclusionRules) Finish ¶ added in v1.64.0
func (p *ExclusionRules) Finish()
func (*ExclusionRules) Name ¶ added in v1.64.0
func (*ExclusionRules) Name() string
type FilenameUnadjuster ¶ added in v1.17.0
type FilenameUnadjuster struct {
// contains filtered or unexported fields
}
FilenameUnadjuster fixes filename based on adjusted and unadjusted position (related to line directives and cgo).
A lot of linters use `fset.Position(f.Pos())` to get filename, and they return adjusted filename (e.g.` *.qtpl`) for an issue. We need restore real `.go` filename to properly output it, parse it, etc.
Require absolute file path.
func NewFilenameUnadjuster ¶ added in v1.17.0
func NewFilenameUnadjuster(pkgs []*packages.Package, log logutils.Log) *FilenameUnadjuster
func (*FilenameUnadjuster) Finish ¶ added in v1.17.0
func (*FilenameUnadjuster) Finish()
func (*FilenameUnadjuster) Name ¶ added in v1.17.0
func (*FilenameUnadjuster) Name() string
type Fixer ¶ added in v1.15.0
type Fixer struct {
// contains filtered or unexported fields
}
Fixer fixes reports if possible. The reports that are not fixed are passed to the next processor.
type GeneratedFileFilter ¶ added in v1.64.0
type GeneratedFileFilter struct {
// contains filtered or unexported fields
}
GeneratedFileFilter filters generated files.
- mode "lax": see `isGeneratedFileLax` documentation.
- mode "strict": see `isGeneratedFileStrict` documentation.
- mode "disable": skips this processor.
func NewGeneratedFileFilter ¶ added in v1.64.0
func NewGeneratedFileFilter(mode string) *GeneratedFileFilter
func (*GeneratedFileFilter) Finish ¶ added in v1.64.0
func (*GeneratedFileFilter) Finish()
func (*GeneratedFileFilter) Name ¶ added in v1.64.0
func (*GeneratedFileFilter) Name() string
type IdentifierMarker ¶ added in v1.15.0
type IdentifierMarker struct {
// contains filtered or unexported fields
}
IdentifierMarker modifies report text. It must be before [Exclude] and [ExcludeRules]: users configure exclusions based on the modified text.
func NewIdentifierMarker ¶ added in v1.15.0
func NewIdentifierMarker() *IdentifierMarker
func (*IdentifierMarker) Finish ¶ added in v1.15.0
func (*IdentifierMarker) Finish()
func (*IdentifierMarker) Name ¶ added in v1.15.0
func (*IdentifierMarker) Name() string
type InvalidIssue ¶ added in v1.57.1
type InvalidIssue struct {
// contains filtered or unexported fields
}
InvalidIssue filters invalid reports.
- non-go files (except `go.mod`)
- reports without file path
func NewInvalidIssue ¶ added in v1.57.1
func NewInvalidIssue(log logutils.Log) *InvalidIssue
func (InvalidIssue) Finish ¶ added in v1.57.1
func (InvalidIssue) Finish()
func (InvalidIssue) Name ¶ added in v1.57.1
func (InvalidIssue) Name() string
type MaxFromLinter ¶
type MaxFromLinter struct {
// contains filtered or unexported fields
}
MaxFromLinter limits the number of reports from the same linter.
func NewMaxFromLinter ¶
func (*MaxFromLinter) Finish ¶
func (p *MaxFromLinter) Finish()
func (*MaxFromLinter) Name ¶
func (*MaxFromLinter) Name() string
type MaxPerFileFromLinter ¶
type MaxPerFileFromLinter struct {
// contains filtered or unexported fields
}
MaxPerFileFromLinter limits the number of reports by file and by linter.
func NewMaxPerFileFromLinter ¶
func NewMaxPerFileFromLinter(cfg *config.Config) *MaxPerFileFromLinter
func (*MaxPerFileFromLinter) Finish ¶
func (*MaxPerFileFromLinter) Finish()
func (*MaxPerFileFromLinter) Name ¶
func (*MaxPerFileFromLinter) Name() string
type MaxSameIssues ¶
type MaxSameIssues struct {
// contains filtered or unexported fields
}
MaxSameIssues limits the number of reports with the same text.
func NewMaxSameIssues ¶
func (*MaxSameIssues) Finish ¶
func (p *MaxSameIssues) Finish()
func (*MaxSameIssues) Name ¶
func (*MaxSameIssues) Name() string
type NolintFilter ¶ added in v1.64.0
type NolintFilter struct {
// contains filtered or unexported fields
}
NolintFilter filters and sorts reports related to `nolint` directives.
func NewNolintFilter ¶ added in v1.64.0
func (*NolintFilter) Finish ¶ added in v1.64.0
func (p *NolintFilter) Finish()
func (*NolintFilter) Name ¶ added in v1.64.0
func (*NolintFilter) Name() string
type PathAbsoluter ¶ added in v1.64.0
type PathAbsoluter struct {
// contains filtered or unexported fields
}
PathAbsoluter ensures that representation of path are absolute.
func NewPathAbsoluter ¶ added in v1.64.0
func NewPathAbsoluter(log logutils.Log) *PathAbsoluter
func (*PathAbsoluter) Finish ¶ added in v1.64.0
func (*PathAbsoluter) Finish()
func (*PathAbsoluter) Name ¶ added in v1.64.0
func (*PathAbsoluter) Name() string
type PathPrettifier ¶
type PathPrettifier struct {
// contains filtered or unexported fields
}
PathPrettifier modifies report file path to be relative to the base path. Also handles the `output.path-prefix` option.
func NewPathPrettifier ¶
func NewPathPrettifier(log logutils.Log, prefix string) *PathPrettifier
func (*PathPrettifier) Finish ¶
func (*PathPrettifier) Finish()
func (*PathPrettifier) Name ¶
func (*PathPrettifier) Name() string
type PathRelativity ¶ added in v1.64.0
type PathRelativity struct {
// contains filtered or unexported fields
}
PathRelativity computes result.Issue.RelativePath and result.Issue.WorkingDirectoryRelativePath, based on the base path.
func NewPathRelativity ¶ added in v1.64.0
func NewPathRelativity(log logutils.Log, basePath string) (*PathRelativity, error)
func (*PathRelativity) Finish ¶ added in v1.64.0
func (*PathRelativity) Finish()
func (*PathRelativity) Name ¶ added in v1.64.0
func (*PathRelativity) Name() string
type PathShortener ¶ added in v1.11.1
type PathShortener struct {
// contains filtered or unexported fields
}
PathShortener modifies text of the reports to reduce file path inside the text. It uses the rooted path name corresponding to the current directory (`wd`).
func NewPathShortener ¶ added in v1.11.1
func NewPathShortener() *PathShortener
func (PathShortener) Finish ¶ added in v1.11.1
func (PathShortener) Finish()
func (PathShortener) Name ¶ added in v1.11.1
func (PathShortener) Name() string
type Severity ¶ added in v1.57.0
type Severity struct {
// contains filtered or unexported fields
}
Severity modifies report severity. It uses the same `baseRule` structure as [ExcludeRules] processor.
Warning: it doesn't use `path-prefix` option.
func NewSeverity ¶ added in v1.57.0
type SkipDirs ¶ added in v1.11.1
type SkipDirs struct {
// contains filtered or unexported fields
}
SkipDirs filters reports based on directory names. It uses the shortest relative paths and `path-prefix` option. TODO(ldez): should be removed in v2.
func NewSkipDirs ¶ added in v1.11.1
type SkipFiles ¶ added in v1.6.1
type SkipFiles struct {
// contains filtered or unexported fields
}
SkipFiles filters reports based on filename.
It uses the shortest relative paths and `path-prefix` option. TODO(ldez): should be removed in v2.
func NewSkipFiles ¶ added in v1.6.1
type SortResults ¶ added in v1.29.0
type SortResults struct {
// contains filtered or unexported fields
}
SortResults sorts reports based on criteria:
- file names, line numbers, positions
- linter names
- severity names
func NewSortResults ¶ added in v1.29.0
func NewSortResults(cfg *config.Output) *SortResults
func (SortResults) Finish ¶ added in v1.29.0
func (SortResults) Finish()
func (SortResults) Name ¶ added in v1.29.0
func (SortResults) Name() string
type SourceCode ¶ added in v1.10.1
type SourceCode struct {
// contains filtered or unexported fields
}
SourceCode modifies displayed information based on [result.Issue.GetLineRange()].
This is used:
- to display the "UnderLinePointer".
- in some rare cases to display multiple lines instead of one (ex: `dupl`)
It requires to use fsutils.LineCache (fsutils.FileCache) to get the file information before the fixes.
func NewSourceCode ¶ added in v1.10.1
func NewSourceCode(lc *fsutils.LineCache, log logutils.Log) *SourceCode
func (SourceCode) Finish ¶ added in v1.10.1
func (SourceCode) Finish()
func (SourceCode) Name ¶ added in v1.10.1
func (SourceCode) Name() string
type UniqByLine ¶
type UniqByLine struct {
// contains filtered or unexported fields
}
UniqByLine filters reports to keep only one report by line of code.
func NewUniqByLine ¶
func NewUniqByLine(enable bool) *UniqByLine
func (*UniqByLine) Finish ¶
func (*UniqByLine) Finish()
func (*UniqByLine) Name ¶
func (*UniqByLine) Name() string
Source Files
¶
- base_rule.go
- cgo.go
- diff.go
- exclusion_generated_file_filter.go
- exclusion_paths.go
- exclusion_presets.go
- exclusion_rules.go
- filename_unadjuster.go
- fixer.go
- identifier_marker.go
- invalid_issue.go
- issues.go
- max_from_linter.go
- max_per_file_from_linter.go
- max_same_issues.go
- nolint_filter.go
- path_absoluter.go
- path_prettifier.go
- path_relativity.go
- path_shortener.go
- processor.go
- severity.go
- skip_dirs.go
- skip_files.go
- sort_results.go
- source_code.go
- uniq_by_line.go