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

golangci-lint config verify prints help on verification failure #4596

Closed
5 tasks done
matthewhughes934 opened this issue Mar 29, 2024 · 1 comment · Fixed by #4597
Closed
5 tasks done

golangci-lint config verify prints help on verification failure #4596

matthewhughes934 opened this issue Mar 29, 2024 · 1 comment · Fixed by #4597
Labels

Comments

@matthewhughes934
Copy link
Contributor

Welcome

Description of the problem

Upon failing verification on a config, the verification error is printed and so is the command's help:

$ golangci-lint config verify
jsonschema: "linters-settings.govet" does not validate with "/properties/linters-settings/properties/govet/additionalProperties": additionalProperties 'check-shadowing' not allowed
Error: the configuration contains invalid elements
Usage:
  golangci-lint config verify [flags]

Global Flags:
      --color string   Use color when printing; can be 'always', 'auto', or 'never' (default "auto")
  -c, --config PATH    Read config from file path PATH
  -h, --help           Help for a command
      --no-config      Don't read config file
  -v, --verbose        Verbose output

Failed executing command with error: the configuration contains invalid elements

Expectation: help is only printed if I passed invalid flags/had some invalid setup.
I find printing the help clutters the output and makes it hard to read the reason for the failure

Thanks for adding the config verify command, I was recently looking for exactly this behaviour and was happy to see it included

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.57.2 built with go1.22.1 from 77a8601a on 2024-03-28T19:01:11Z

Configuration

  tests: true

linters-settings:
  errcheck:
    check-type-assertions: true
    check-blank: true
  govet:
    check-shadowing: false
  revive:
    rules:
      - name: exported
        disabled: true
      - name: context-as-argument
        disabled: false
  nolintlint:
    require-specific: true

linters:
  enable:
    - revive
    - misspell
    - nakedret
    - gas
    - unconvert
    - unparam
    - prealloc
    - goimports
    - gofumpt
    - gci

Go environment

$ go version && go env
go version go1.22.1 linux/amd64
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/me/.cache/go-build'
GOENV='/home/me/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/me/.local/share/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/me/.local/share/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.1'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/me/src/personal/go-cov/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1418383092=/tmp/go-build -gno-record-gcc-switches'

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
# paste output here

A minimal reproducible example or link to a public repository

You just need any invalid config (the one shared above will do) then run golangci-lint config verify.

I see cobra.Command has a SilenceUsage attribute but I'm not sure we can set this from within the verify command because of spf13/cobra#564. Maybe executeVerify could run as a command.Run (instead of a command.RunE) and just log its errors?

Validation

  • Yes, I've included all information above (version, config, etc.).
@matthewhughes934 matthewhughes934 added the bug Something isn't working label Mar 29, 2024
@ldez ldez added area: config Related to .golangci.yml and/or cli options area: CLI Related to CLI area: JSON schema and removed bug Something isn't working area: config Related to .golangci.yml and/or cli options labels Mar 29, 2024
@ldez
Copy link
Member

ldez commented Mar 29, 2024

Hello,

it was originally inside the PR content but it was removed by error during review.

It will be fixed by #4597.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants