From be59a0363f9cf9c254288dd2732e4e72fd286860 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 27 Nov 2022 11:33:00 +0000 Subject: [PATCH 1/3] build(deps): bump github.com/nishanths/exhaustive from 0.8.3 to 0.9.2 Bumps [github.com/nishanths/exhaustive](https://github.com/nishanths/exhaustive) from 0.8.3 to 0.9.2. - [Release notes](https://github.com/nishanths/exhaustive/releases) - [Commits](https://github.com/nishanths/exhaustive/compare/v0.8.3...v0.9.2) --- updated-dependencies: - dependency-name: github.com/nishanths/exhaustive dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9d5396f43f57..82597c3b24a9 100644 --- a/go.mod +++ b/go.mod @@ -70,7 +70,7 @@ require ( github.com/mitchellh/go-ps v1.0.0 github.com/moricho/tparallel v0.2.1 github.com/nakabonne/nestif v0.3.1 - github.com/nishanths/exhaustive v0.8.3 + github.com/nishanths/exhaustive v0.9.2 github.com/nishanths/predeclared v0.2.2 github.com/pkg/errors v0.9.1 github.com/polyfloyd/go-errorlint v1.0.6 diff --git a/go.sum b/go.sum index bde374e9ada6..32df7ffb09c2 100644 --- a/go.sum +++ b/go.sum @@ -391,8 +391,8 @@ github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 h1:4kuARK6Y6Fx github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354/go.mod h1:KSVJerMDfblTH7p5MZaTt+8zaT2iEk3AkVb9PQdZuE8= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/nishanths/exhaustive v0.8.3 h1:pw5O09vwg8ZaditDp/nQRqVnrMczSJDxRDJMowvhsrM= -github.com/nishanths/exhaustive v0.8.3/go.mod h1:qj+zJJUgJ76tR92+25+03oYUhzF4R7/2Wk7fGTfCHmg= +github.com/nishanths/exhaustive v0.9.2 h1:PyEzIQZ4lpGBXsKc83syhC18JQPtsEMh2aAUG6pZfLo= +github.com/nishanths/exhaustive v0.9.2/go.mod h1:VjHsn6MdEX4ydfLwt658YcdPxSDKOlqSjpkeGJPCamo= github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk= github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= From 2d6f3b6ea6745b8646dc5c6a87048904a8bca368 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sun, 27 Nov 2022 12:40:16 +0100 Subject: [PATCH 2/3] chore: update linter --- .golangci.reference.yml | 4 ++++ pkg/config/linters_settings.go | 1 + pkg/golinters/exhaustive.go | 1 + 3 files changed, 6 insertions(+) diff --git a/.golangci.reference.yml b/.golangci.reference.yml index d96efc003001..3dded806666a 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -318,6 +318,10 @@ linters-settings: # switch statements to satisfy exhaustiveness. # Default: "" ignore-enum-members: "Example.+" + # Enum types matching the supplied regex do not have to be listed in + # switch statements to satisfy exhaustiveness. + # Default: "" + ignore-enum-types: "Example.+" # Consider enums only in package scopes, not in inner scopes. # Default: false package-scope-only: true diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index d932c9cdf6b2..22293abe7f79 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -289,6 +289,7 @@ type ExhaustiveSettings struct { CheckGenerated bool `mapstructure:"check-generated"` DefaultSignifiesExhaustive bool `mapstructure:"default-signifies-exhaustive"` IgnoreEnumMembers string `mapstructure:"ignore-enum-members"` + IgnoreEnumTypes string `mapstructure:"ignore-enum-types"` PackageScopeOnly bool `mapstructure:"package-scope-only"` ExplicitExhaustiveMap bool `mapstructure:"explicit-exhaustive-map"` ExplicitExhaustiveSwitch bool `mapstructure:"explicit-exhaustive-switch"` diff --git a/pkg/golinters/exhaustive.go b/pkg/golinters/exhaustive.go index e6f983bada54..a66f95190aff 100644 --- a/pkg/golinters/exhaustive.go +++ b/pkg/golinters/exhaustive.go @@ -19,6 +19,7 @@ func NewExhaustive(settings *config.ExhaustiveSettings) *goanalysis.Linter { exhaustive.CheckGeneratedFlag: settings.CheckGenerated, exhaustive.DefaultSignifiesExhaustiveFlag: settings.DefaultSignifiesExhaustive, exhaustive.IgnoreEnumMembersFlag: settings.IgnoreEnumMembers, + exhaustive.IgnoreEnumTypesFlag: settings.IgnoreEnumTypes, exhaustive.PackageScopeOnlyFlag: settings.PackageScopeOnly, exhaustive.ExplicitExhaustiveMapFlag: settings.ExplicitExhaustiveMap, exhaustive.ExplicitExhaustiveSwitchFlag: settings.ExplicitExhaustiveSwitch, From 1aa8d2bf824564e3719a82161f9c4c6f48957474 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sun, 27 Nov 2022 12:55:14 +0100 Subject: [PATCH 3/3] chore: update tests --- test/testdata/exhaustive.go | 2 +- test/testdata/exhaustive_ignore_enum_members.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/testdata/exhaustive.go b/test/testdata/exhaustive.go index ace3f81d19e7..3aba491cfec4 100644 --- a/test/testdata/exhaustive.go +++ b/test/testdata/exhaustive.go @@ -11,7 +11,7 @@ const ( ) func processDirection(d Direction) { - switch d { // want "missing cases in switch of type Direction: East, West" + switch d { // want "missing cases in switch of type testdata.Direction: testdata.East, testdata.West" case North, South: } } diff --git a/test/testdata/exhaustive_ignore_enum_members.go b/test/testdata/exhaustive_ignore_enum_members.go index e1a810ee140e..0ad9798cbcb9 100644 --- a/test/testdata/exhaustive_ignore_enum_members.go +++ b/test/testdata/exhaustive_ignore_enum_members.go @@ -15,7 +15,7 @@ const ( // using the ignore-enum-members setting. func processDirectionIgnoreEnumMembers(d Direction) { - switch d { // want "missing cases in switch of type Direction: East" + switch d { // want "missing cases in switch of type testdata.Direction: testdata.East" case North, South: } }