Skip to content

Commit 0e0d6ad

Browse files
committed
refactor: use constants for default exclusions
1 parent a96fcf4 commit 0e0d6ad

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

pkg/config/linters_exclusions.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
package config
22

3+
const (
4+
DefaultExclusionComments = "comments"
5+
DefaultExclusionStdErrorHandling = "stdErrorHandling"
6+
DefaultExclusionCommonFalsePositives = "commonFalsePositives"
7+
DefaultExclusionLegacy = "legacy"
8+
)
9+
310
type LinterExclusions struct {
411
Generated string `mapstructure:"generated"`
512
WarnUnused bool `mapstructure:"warn-unused"`

pkg/config/loader.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ func (l *Loader) Load(opts LoadOptions) error {
7878
}
7979

8080
if l.cfg.Issues.UseDefaultExcludes {
81-
l.cfg.Linters.LinterExclusions.Default = []string{"comments", "stdErrorHandling", "commonFalsePositives", "legacy"}
81+
l.cfg.Linters.LinterExclusions.Default = []string{
82+
DefaultExclusionComments,
83+
DefaultExclusionStdErrorHandling,
84+
DefaultExclusionCommonFalsePositives,
85+
DefaultExclusionLegacy,
86+
}
8287
}
8388

8489
if len(l.cfg.Issues.ExcludeRules) > 0 {

pkg/result/processors/exclusion_default.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package processors
33
import "github.com/golangci/golangci-lint/pkg/config"
44

55
var defaultLintersExclusions = map[string][]config.ExcludeRule{
6-
"comments": {
6+
config.DefaultExclusionComments: {
77
{
88
// Annoying issue about not having a comment. The rare codebase has such comments.
99
// CheckPackageComment, CheckExportedFunctionDocs, CheckExportedTypeDocs, CheckExportedVarDocs
@@ -50,7 +50,7 @@ var defaultLintersExclusions = map[string][]config.ExcludeRule{
5050
},
5151
},
5252
},
53-
"stdErrorHandling": {
53+
config.DefaultExclusionStdErrorHandling: {
5454
{
5555
// Almost all programs ignore errors on these functions and in most cases it's ok.
5656
BaseRule: config.BaseRule{
@@ -61,7 +61,7 @@ var defaultLintersExclusions = map[string][]config.ExcludeRule{
6161
},
6262
},
6363
},
64-
"commonFalsePositives": {
64+
config.DefaultExclusionCommonFalsePositives: {
6565
{
6666
// Too many false-positives on 'unsafe' usage.
6767
BaseRule: config.BaseRule{
@@ -87,7 +87,7 @@ var defaultLintersExclusions = map[string][]config.ExcludeRule{
8787
},
8888
},
8989
},
90-
"legacy": {
90+
config.DefaultExclusionLegacy: {
9191
{
9292
// Common false positives.
9393
BaseRule: config.BaseRule{

0 commit comments

Comments
 (0)