Skip to content

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

Closed
@pks-t

Description

@pks-t

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions