Skip to content

Commit ca2769c

Browse files
committed
docs: add godoc for all processors
1 parent 6d29861 commit ca2769c

22 files changed

+72
-11
lines changed

pkg/result/processors/autogenerated_exclude.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ type fileSummary struct {
3939
generated bool
4040
}
4141

42+
// AutogeneratedExclude filters generated files.
43+
// - mode "lax": see [isGeneratedFileLax] documentation.
44+
// - mode "strict": see [isGeneratedFileStrict] documentation.
45+
// - mode "disable": skips this processor.
4246
type AutogeneratedExclude struct {
4347
debugf logutils.DebugFunc
4448

pkg/result/processors/cgo.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import (
1010

1111
var _ Processor = (*Cgo)(nil)
1212

13-
// Cgo some linters (e.g. gosec, deadcode) return incorrect filepaths for cgo issues,
14-
// also cgo files have strange issues looking like false positives.
13+
// Cgo filters cgo artifacts.
1514
//
16-
// Require absolute filepath.
15+
// Some linters (e.g. gosec, etc.) return incorrect file paths for cgo files.
16+
//
17+
// Require absolute file path.
1718
type Cgo struct {
1819
goCacheDir string
1920
}

pkg/result/processors/diff.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ const envGolangciDiffProcessorPatch = "GOLANGCI_DIFF_PROCESSOR_PATCH"
1818

1919
var _ Processor = (*Diff)(nil)
2020

21+
// Diff filters issues based on options `new`, `new-from-rev`, etc.
22+
//
23+
// Uses `git`.
24+
// The paths inside the patch are relative to the path where git/golangci-lint is run.
25+
//
26+
// Warning: it doesn't use `path-prefix` option.
2127
type Diff struct {
2228
onlyNew bool
2329
fromRev string

pkg/result/processors/exclude.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
var _ Processor = (*Exclude)(nil)
1313

14+
// Exclude filters reports only based on regular expressions applied to the report text.
1415
type Exclude struct {
1516
name string
1617

pkg/result/processors/exclude_rules.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ type excludeRule struct {
1515
baseRule
1616
}
1717

18+
// ExcludeRules filters reports based on multiple criteria:
19+
// - linter names (string)
20+
// - file path (regular expressions)
21+
// - text (regular expressions)
22+
// - code source (regular expressions)
23+
//
24+
// It uses the shortest relative paths and `path-prefix` option.
1825
type ExcludeRules struct {
1926
name string
2027

pkg/result/processors/filename_unadjuster.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ type adjustMap struct {
2222
m map[string]posMapper
2323
}
2424

25-
// FilenameUnadjuster is needed because a lot of linters use `fset.Position(f.Pos())` to get filename.
26-
// And they return adjusted filename (e.g.` *.qtpl`) for an issue.
25+
// FilenameUnadjuster fixes filename based on adjusted and unadjusted position (related to line directives and cgo).
26+
//
27+
// A lot of linters use `fset.Position(f.Pos())` to get filename,
28+
// and they return adjusted filename (e.g.` *.qtpl`) for an issue.
2729
// We need restore real `.go` filename to properly output it, parse it, etc.
2830
//
29-
// Require absolute filepath.
31+
// Require absolute file path.
3032
type FilenameUnadjuster struct {
3133
m map[string]posMapper // map from adjusted filename to position mapper: adjusted -> unadjusted position
3234
log logutils.Log

pkg/result/processors/fixer.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ var _ Processor = (*Fixer)(nil)
3131

3232
const filePerm = 0644
3333

34+
// Fixer fixes reports if possible.
35+
// The reports that are not fixed are passed to the next processor.
3436
type Fixer struct {
3537
cfg *config.Config
3638
log logutils.Log

pkg/result/processors/identifier_marker.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ type replacePattern struct {
1313
repl string
1414
}
1515

16+
// IdentifierMarker modifies report text.
17+
// It must be before [Exclude] and [ExcludeRules]:
18+
// users configure exclusions based on the modified text.
1619
type IdentifierMarker struct {
1720
patterns map[string][]replacePattern
1821
}

pkg/result/processors/invalid_issue.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import (
99

1010
var _ Processor = (*InvalidIssue)(nil)
1111

12+
// InvalidIssue filters invalid reports.
13+
// - non-go files (except `go.mod`)
14+
// - reports without file path
1215
type InvalidIssue struct {
1316
log logutils.Log
1417
}

pkg/result/processors/max_from_linter.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
var _ Processor = (*MaxFromLinter)(nil)
1010

11+
// MaxFromLinter limits the number of reports from the same linter.
1112
type MaxFromLinter struct {
1213
linterCounter map[string]int
1314
limit int

0 commit comments

Comments
 (0)