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

Upgrade to viper v1.13 caused regression in Revive rule configuration #3293

Closed
4 tasks done
pks-t opened this issue Oct 14, 2022 · 2 comments
Closed
4 tasks done

Upgrade to viper v1.13 caused regression in Revive rule configuration #3293

pks-t opened this issue Oct 14, 2022 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@pks-t
Copy link

pks-t commented Oct 14, 2022

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).
  • Yes, I've tried with the standalone linter if available. (https://golangci-lint.run/usage/linters/)

Description of the problem

The upgrade of Viper to v1.13 is causing issues with the configuration of Revive if the rules array contains certain keys like allowTypesBefore with upper-case-characters. This is because starting with spf13/viper@5247643 Viper recurses into arrays and lower-cases all keys, but Revive has a strict comparison that compares the case of options.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version v1.50.0 built from (unknown, mod sum: "h1:+Xmyt8rKLauNLp2gzcxKMN8VNGqGc5Avc2ZLTwIOpEA=") on (unknown)

Configuration file

$ cat .golangci.yml
linters:
  disable-all: true
  enable:
    - revive

linters-settings:
  revive:
    rules:
      - name: context-as-argument
        arguments:
          allowTypesBefore: "*testing.T,*testing.B,testing.TB"

Go environment

$ go version && go env
go version go1.19.2 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/pks/Development/gitlab/.cache/go-build"
GOENV="/home/pks/Development/gitlab/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/pks/Development/gitlab/.go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/pks/Development/gitlab/.go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.2"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="x86_64-gentoo-linux-musl-gcc"
CXX="x86_64-gentoo-linux-musl-g++"
CGO_ENABLED="1"
GOMOD="/home/pks/Development/gitlab/gdk/gitaly/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build227433220=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run
panic: Invalid argument to the context-as-argument rule. Unrecognized key allowtypesbefore

goroutine 60 [running]:
github.com/mgechev/revive/rule.getAllowTypesFromArguments({0xc00183d3a0?, 0x0?, 0x0?})
	/home/pks/Development/gitlab/.go/pkg/mod/github.com/mgechev/revive@v1.2.4/rule/context-as-argument.go:98 +0x379
github.com/mgechev/revive/rule.(*ContextAsArgumentRule).Apply(0x222c850, 0xc000180f80, {0xc00183d3a0?, 0x13?, 0xcdb100?})
	/home/pks/Development/gitlab/.go/pkg/mod/github.com/mgechev/revive@v1.2.4/rule/context-as-argument.go:22 +0xa5
github.com/mgechev/revive/lint.(*File).lint(0xc000180f80, {0xc00183d460, 0x1, 0x1}, {0x0, 0x3fe999999999999a, {0x16a58d7, 0x7}, 0x0, 0xc001a90b40, ...}, ...)
	/home/pks/Development/gitlab/.go/pkg/mod/github.com/mgechev/revive@v1.2.4/lint/file.go:105 +0x19b
github.com/mgechev/revive/lint.(*Package).lint.func1(0xc000a66630?)
	/home/pks/Development/gitlab/.go/pkg/mod/github.com/mgechev/revive@v1.2.4/lint/package.go:185 +0x85
created by github.com/mgechev/revive/lint.(*Package).lint
	/home/pks/Development/gitlab/.go/pkg/mod/github.com/mgechev/revive@v1.2.4/lint/package.go:184 +0xac
make: *** [Makefile:429: lint] Error 2

Code example or link to a public repository

Not applicable.

@pks-t pks-t added the bug Something isn't working label Oct 14, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Oct 14, 2022

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@ldez
Copy link
Member

ldez commented Oct 14, 2022

duplicate of #3280

#3280 (comment)

Fixed by #3284

@ldez ldez closed this as completed Oct 14, 2022
@ldez ldez added duplicate This issue or pull request already exists and removed bug Something isn't working labels Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants