Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update exhaustive to latest; use version in go.mod #1449

Merged
merged 11 commits into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a new flag in exhaustive.

# 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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing because this is just the default value. As @bombsimon said, no need to mention defaults in this file.

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
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.