Skip to content

Commit 58234f0

Browse files
authored
update exhaustive to latest; use version in go.mod (#1449)
* update exhaustive to latest * wip * update dep * update flag name * use versioned dep * add tests * unused file * no need config file * add vars to test * test comment * remove default settings
1 parent c57627b commit 58234f0

File tree

9 files changed

+40
-13
lines changed

9 files changed

+40
-13
lines changed

.golangci.example.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ linters-settings:
102102
# see https://github.com/kisielk/errcheck#excluding-functions for details
103103
exclude: /path/to/file.txt
104104
exhaustive:
105+
# check switch statements in generated files also
106+
check-generated: false
105107
# indicates that switch statements are to be considered exhaustive if a
106108
# 'default' case is present, even if all enum members aren't listed in the
107109
# switch
@@ -432,22 +434,22 @@ issues:
432434

433435
severity:
434436
# Default value is empty string.
435-
# Set the default severity for issues. If severity rules are defined and the issues
436-
# do not match or no severity is provided to the rule this will be the default
437-
# severity applied. Severities should match the supported severity names of the
437+
# Set the default severity for issues. If severity rules are defined and the issues
438+
# do not match or no severity is provided to the rule this will be the default
439+
# severity applied. Severities should match the supported severity names of the
438440
# selected out format.
439441
# - Code climate: https://docs.codeclimate.com/docs/issues#issue-severity
440442
# - Checkstyle: https://checkstyle.sourceforge.io/property_types.html#severity
441443
# - Github: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message
442444
default-severity: error
443445

444-
# The default value is false.
446+
# The default value is false.
445447
# If set to true severity-rules regular expressions become case sensitive.
446448
case-sensitive: false
447449

448450
# Default value is empty list.
449451
# When a list of severity rules are provided, severity information will be added to lint
450-
# issues. Severity rules have the same filtering capability as exclude rules except you
452+
# issues. Severity rules have the same filtering capability as exclude rules except you
451453
# are allowed to specify one matcher per severity rule.
452454
# Only affects out formats that support setting severity information.
453455
rules:

.golangci.yml

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ linters-settings:
99
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
1010
dupl:
1111
threshold: 100
12-
exhaustive:
13-
default-signifies-exhaustive: false
1412
funlen:
1513
lines: 100
1614
statements: 50

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ require (
3737
github.com/mitchellh/go-ps v1.0.0
3838
github.com/moricho/tparallel v0.2.1
3939
github.com/nakabonne/nestif v0.3.0
40-
github.com/nishanths/exhaustive v0.0.0-20200811152831-6cf413ae40e0
40+
github.com/nishanths/exhaustive v0.1.0
4141
github.com/pkg/errors v0.9.1
4242
github.com/polyfloyd/go-errorlint v0.0.0-20201006195004-351e25ade6e3
4343
github.com/ryancurrah/gomodguard v1.1.0
@@ -62,7 +62,7 @@ require (
6262
github.com/ultraware/whitespace v0.0.4
6363
github.com/uudashr/gocognit v1.0.1
6464
github.com/valyala/quicktemplate v1.6.3
65-
golang.org/x/tools v0.0.0-20201001104356-43ebab892c4c
65+
golang.org/x/tools v0.0.0-20201011145850-ed2f50202694
6666
gopkg.in/yaml.v2 v2.3.0
6767
honnef.co/go/tools v0.0.1-2020.1.6
6868
mvdan.cc/gofumpt v0.0.0-20200802201014-ab5a8192947d

go.sum

+4-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/config/config.go

+2
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ type NestifSettings struct {
354354
}
355355

356356
type ExhaustiveSettings struct {
357+
CheckGenerated bool `mapstructure:"check-generated"`
357358
DefaultSignifiesExhaustive bool `mapstructure:"default-signifies-exhaustive"`
358359
}
359360

@@ -416,6 +417,7 @@ var defaultLintersSettings = LintersSettings{
416417
MinComplexity: 5,
417418
},
418419
Exhaustive: ExhaustiveSettings{
420+
CheckGenerated: false,
419421
DefaultSignifiesExhaustive: false,
420422
},
421423
Gofumpt: GofumptSettings{

pkg/golinters/exhaustive.go

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ func NewExhaustive(settings *config.ExhaustiveSettings) *goanalysis.Linter {
1515
if settings != nil {
1616
cfg = map[string]map[string]interface{}{
1717
a.Name: {
18+
exhaustive.CheckGeneratedFlag: settings.CheckGenerated,
1819
exhaustive.DefaultSignifiesExhaustiveFlag: settings.DefaultSignifiesExhaustive,
1920
},
2021
}

test/testdata/exhaustive_default.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//args: -Eexhaustive
2-
//config_path: testdata/configs/exhaustive.yml
2+
//config_path: testdata/configs/exhaustive_default.yml
33
package testdata
44

55
type Direction int

test/testdata/exhaustive_generated.go

+23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)