From ad8f20fe8840f85e2248c57ba1a625c6136246d6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 11 Sep 2022 11:01:37 +0000 Subject: [PATCH 1/2] build(deps): bump github.com/nishanths/exhaustive from 0.8.1 to 0.8.3 Bumps [github.com/nishanths/exhaustive](https://github.com/nishanths/exhaustive) from 0.8.1 to 0.8.3. - [Release notes](https://github.com/nishanths/exhaustive/releases) - [Commits](https://github.com/nishanths/exhaustive/compare/v0.8.1...v0.8.3) --- updated-dependencies: - dependency-name: github.com/nishanths/exhaustive dependency-type: direct:production update-type: version-update:semver-patch ... 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 fbc5431af432..155d10b1e01d 100644 --- a/go.mod +++ b/go.mod @@ -69,7 +69,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.1 + github.com/nishanths/exhaustive v0.8.3 github.com/nishanths/predeclared v0.2.2 github.com/pkg/errors v0.9.1 github.com/polyfloyd/go-errorlint v1.0.2 diff --git a/go.sum b/go.sum index 1d2acb46edd6..f5dc0e5a4f71 100644 --- a/go.sum +++ b/go.sum @@ -388,8 +388,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.1 h1:0QKNascWv9qIHY7zRoZSxeRr6kuk5aAT3YXLTiDmjTo= -github.com/nishanths/exhaustive v0.8.1/go.mod h1:qj+zJJUgJ76tR92+25+03oYUhzF4R7/2Wk7fGTfCHmg= +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/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 e69bf9bb5eb9af89b9484d2f653ac6ec419ed595 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sun, 11 Sep 2022 13:27:04 +0200 Subject: [PATCH 2/2] update configuration --- .golangci.reference.yml | 6 ++++++ pkg/config/linters_settings.go | 2 ++ pkg/golinters/exhaustive.go | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.golangci.reference.yml b/.golangci.reference.yml index 19cd49ad6cad..0d4fc4a78772 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -307,6 +307,12 @@ linters-settings: # Consider enums only in package scopes, not in inner scopes. # Default: false package-scope-only: true + # only run exhaustive check on switches with "//exhaustive:enforce" comment + # Default: false + explicit-exhaustive-switch: true + # only run exhaustive check on map literals with "//exhaustive:enforce" comment. + # Default: false + explicit-exhaustive-map: true exhaustivestruct: # Struct Patterns is list of expressions to match struct packages and names. diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 0822862e90c4..70df4682274e 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -278,6 +278,8 @@ type ExhaustiveSettings struct { DefaultSignifiesExhaustive bool `mapstructure:"default-signifies-exhaustive"` IgnoreEnumMembers string `mapstructure:"ignore-enum-members"` PackageScopeOnly bool `mapstructure:"package-scope-only"` + ExplicitExhaustiveMap bool `mapstructure:"explicit-exhaustive-map"` + ExplicitExhaustiveSwitch bool `mapstructure:"explicit-exhaustive-switch"` } type ExhaustiveStructSettings struct { diff --git a/pkg/golinters/exhaustive.go b/pkg/golinters/exhaustive.go index 778dc004b29f..c2b2d29d2235 100644 --- a/pkg/golinters/exhaustive.go +++ b/pkg/golinters/exhaustive.go @@ -17,8 +17,9 @@ func NewExhaustive(settings *config.ExhaustiveSettings) *goanalysis.Linter { a.Name: { exhaustive.CheckGeneratedFlag: settings.CheckGenerated, exhaustive.DefaultSignifiesExhaustiveFlag: settings.DefaultSignifiesExhaustive, + exhaustive.ExplicitExhaustiveMapFlag: settings.ExplicitExhaustiveMap, + exhaustive.ExplicitExhaustiveSwitchFlag: settings.PackageScopeOnly, exhaustive.IgnoreEnumMembersFlag: settings.IgnoreEnumMembers, - exhaustive.PackageScopeOnlyFlag: settings.PackageScopeOnly, }, } }