Skip to content

Commit

Permalink
update exhaustive to latest; use version in go.mod (#1449)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nishanths committed Oct 14, 2020
1 parent c57627b commit 58234f0
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 13 deletions.
12 changes: 7 additions & 5 deletions .golangci.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ linters-settings:
# see https://github.com/kisielk/errcheck#excluding-functions for details
exclude: /path/to/file.txt
exhaustive:
# check switch statements in generated files also
check-generated: false
# indicates that switch statements are to be considered exhaustive if a
# 'default' case is present, even if all enum members aren't listed in the
# switch
Expand Down Expand Up @@ -432,22 +434,22 @@ issues:

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

# The default value is false.
# The default value is false.
# If set to true severity-rules regular expressions become case sensitive.
case-sensitive: false

# Default value is empty list.
# When a list of severity rules are provided, severity information will be added to lint
# issues. Severity rules have the same filtering capability as exclude rules except you
# issues. Severity rules have the same filtering capability as exclude rules except you
# are allowed to specify one matcher per severity rule.
# Only affects out formats that support setting severity information.
rules:
Expand Down
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ linters-settings:
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
dupl:
threshold: 100
exhaustive:
default-signifies-exhaustive: false
funlen:
lines: 100
statements: 50
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ require (
github.com/mitchellh/go-ps v1.0.0
github.com/moricho/tparallel v0.2.1
github.com/nakabonne/nestif v0.3.0
github.com/nishanths/exhaustive v0.0.0-20200811152831-6cf413ae40e0
github.com/nishanths/exhaustive v0.1.0
github.com/pkg/errors v0.9.1
github.com/polyfloyd/go-errorlint v0.0.0-20201006195004-351e25ade6e3
github.com/ryancurrah/gomodguard v1.1.0
Expand All @@ -62,7 +62,7 @@ require (
github.com/ultraware/whitespace v0.0.4
github.com/uudashr/gocognit v1.0.1
github.com/valyala/quicktemplate v1.6.3
golang.org/x/tools v0.0.0-20201001104356-43ebab892c4c
golang.org/x/tools v0.0.0-20201011145850-ed2f50202694
gopkg.in/yaml.v2 v2.3.0
honnef.co/go/tools v0.0.1-2020.1.6
mvdan.cc/gofumpt v0.0.0-20200802201014-ab5a8192947d
Expand Down
7 changes: 4 additions & 3 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ type NestifSettings struct {
}

type ExhaustiveSettings struct {
CheckGenerated bool `mapstructure:"check-generated"`
DefaultSignifiesExhaustive bool `mapstructure:"default-signifies-exhaustive"`
}

Expand Down Expand Up @@ -416,6 +417,7 @@ var defaultLintersSettings = LintersSettings{
MinComplexity: 5,
},
Exhaustive: ExhaustiveSettings{
CheckGenerated: false,
DefaultSignifiesExhaustive: false,
},
Gofumpt: GofumptSettings{
Expand Down
1 change: 1 addition & 0 deletions pkg/golinters/exhaustive.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func NewExhaustive(settings *config.ExhaustiveSettings) *goanalysis.Linter {
if settings != nil {
cfg = map[string]map[string]interface{}{
a.Name: {
exhaustive.CheckGeneratedFlag: settings.CheckGenerated,
exhaustive.DefaultSignifiesExhaustiveFlag: settings.DefaultSignifiesExhaustive,
},
}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/testdata/exhaustive_default.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//args: -Eexhaustive
//config_path: testdata/configs/exhaustive.yml
//config_path: testdata/configs/exhaustive_default.yml
package testdata

type Direction int
Expand Down
23 changes: 23 additions & 0 deletions test/testdata/exhaustive_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 58234f0

Please sign in to comment.