exclude cobra functions from errcheck

This commit is contained in:
Denis Bilenko 2024-12-10 17:28:13 +01:00
parent ee67bb37e3
commit 09a2a408b9
4 changed files with 9 additions and 4 deletions

View File

@ -16,5 +16,10 @@ linters-settings:
replacement: 'a[b:]' replacement: 'a[b:]'
- pattern: 'interface{}' - pattern: 'interface{}'
replacement: 'any' replacement: 'any'
errcheck:
exclude-functions:
- (*github.com/spf13/pflag.FlagSet).MarkHidden
- (*github.com/spf13/pflag.FlagSet).MarkDeprecated
- (*github.com/spf13/cobra.Command).RegisterFlagCompletionFunc
issues: issues:
exclude-dirs-use-default: false # recommended by docs https://golangci-lint.run/usage/false-positives/ exclude-dirs-use-default: false # recommended by docs https://golangci-lint.run/usage/false-positives/

View File

@ -33,10 +33,10 @@ func newDeployCommand() *cobra.Command {
cmd.Flags().StringVar(&clusterId, "compute-id", "", "Override cluster in the deployment with the given compute ID.") cmd.Flags().StringVar(&clusterId, "compute-id", "", "Override cluster in the deployment with the given compute ID.")
cmd.Flags().StringVarP(&clusterId, "cluster-id", "c", "", "Override cluster in the deployment with the given cluster ID.") cmd.Flags().StringVarP(&clusterId, "cluster-id", "c", "", "Override cluster in the deployment with the given cluster ID.")
cmd.Flags().BoolVar(&autoApprove, "auto-approve", false, "Skip interactive approvals that might be required for deployment.") cmd.Flags().BoolVar(&autoApprove, "auto-approve", false, "Skip interactive approvals that might be required for deployment.")
_ = cmd.Flags().MarkDeprecated("compute-id", "use --cluster-id instead") cmd.Flags().MarkDeprecated("compute-id", "use --cluster-id instead")
cmd.Flags().BoolVar(&verbose, "verbose", false, "Enable verbose output.") cmd.Flags().BoolVar(&verbose, "verbose", false, "Enable verbose output.")
// Verbose flag currently only affects file sync output, it's used by the vscode extension // Verbose flag currently only affects file sync output, it's used by the vscode extension
_ = cmd.Flags().MarkHidden("verbose") cmd.Flags().MarkHidden("verbose")
cmd.RunE = func(cmd *cobra.Command, args []string) error { cmd.RunE = func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context() ctx := cmd.Context()

View File

@ -460,7 +460,7 @@ func NewGenerateDashboardCommand() *cobra.Command {
cmd.MarkFlagsMutuallyExclusive("watch", "existing-id") cmd.MarkFlagsMutuallyExclusive("watch", "existing-id")
// Completion for the resource flag. // Completion for the resource flag.
_ = cmd.RegisterFlagCompletionFunc("resource", dashboardResourceCompletion) cmd.RegisterFlagCompletionFunc("resource", dashboardResourceCompletion)
cmd.RunE = d.RunE cmd.RunE = d.RunE
return cmd return cmd

View File

@ -37,7 +37,7 @@ func (e ErrNoAccountProfiles) Error() string {
func initProfileFlag(cmd *cobra.Command) { func initProfileFlag(cmd *cobra.Command) {
cmd.PersistentFlags().StringP("profile", "p", "", "~/.databrickscfg profile") cmd.PersistentFlags().StringP("profile", "p", "", "~/.databrickscfg profile")
_ = cmd.RegisterFlagCompletionFunc("profile", profile.ProfileCompletion) cmd.RegisterFlagCompletionFunc("profile", profile.ProfileCompletion)
} }
func profileFlagValue(cmd *cobra.Command) (string, bool) { func profileFlagValue(cmd *cobra.Command) (string, bool) {