From 362b43103ed66890fd676f50baf057fc6c92418b Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 28 Mar 2024 17:58:52 +0100 Subject: [PATCH] fix: hide useless warning --- .golangci.yml | 4 ++++ pkg/commands/config.go | 2 +- pkg/commands/linters.go | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index c6190a00a99d..b5488ad81305 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -160,7 +160,11 @@ issues: linters: [staticcheck] text: "SA1019: c.cfg.Run.ShowStats is deprecated: use Output.ShowStats instead." - path: pkg/commands/config.go + linters: [staticcheck] text: "SA1019: cfg.Run.UseDefaultSkipDirs is deprecated: use Issues.UseDefaultExcludeDirs instead." + - path: pkg/commands/linters.go + linters: [staticcheck] + text: "SA1019: c.cfg.Run.UseDefaultSkipDirs is deprecated: use Issues.UseDefaultExcludeDirs instead." # Deprecated linter options. - path: pkg/golinters/errcheck.go diff --git a/pkg/commands/config.go b/pkg/commands/config.go index cfb7d67ac3c8..98935ab892bb 100644 --- a/pkg/commands/config.go +++ b/pkg/commands/config.go @@ -84,7 +84,7 @@ func (c *configCommand) preRunE(cmd *cobra.Command, _ []string) error { // Hack to hide deprecation messages related to `--skip-dirs-use-default`: // Flags are not bound then the default values, defined only through flags, are not applied. - // In this command, file path and file information are the only requirements, i.e. it don't need flag values. + // In this command, linters information are the only requirements, i.e. it don't need flag values. // // TODO(ldez) add an option (check deprecation) to `Loader.Load()` but this require a dedicated PR. cfg.Run.UseDefaultSkipDirs = true diff --git a/pkg/commands/linters.go b/pkg/commands/linters.go index 61ed0f22f27b..02df90ce903b 100644 --- a/pkg/commands/linters.go +++ b/pkg/commands/linters.go @@ -59,6 +59,13 @@ func newLintersCommand(logger logutils.Log) *lintersCommand { } func (c *lintersCommand) preRunE(cmd *cobra.Command, _ []string) error { + // Hack to hide deprecation messages related to `--skip-dirs-use-default`: + // Flags are not bound then the default values, defined only through flags, are not applied. + // In this command, file path and file information are the only requirements, i.e. it don't need flag values. + // + // TODO(ldez) add an option (check deprecation) to `Loader.Load()` but this require a dedicated PR. + c.cfg.Run.UseDefaultSkipDirs = true + loader := config.NewLoader(c.log.Child(logutils.DebugKeyConfigReader), c.viper, cmd.Flags(), c.opts.LoaderOptions, c.cfg) if err := loader.Load(); err != nil {