Skip to content

golangci-lint cache does not detect changes in ruleguard rules #1999

Open
@dottedmag

Description

@dottedmag
  • 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/)
golangci-lint cache does not detect changes in ruleguard rules
  • Clone https://github.com/ridge/golangci-cache-ruleguard
  • golangci-lint run
  • Note ruleguard: A found linter diagnostic
  • Change rules/rules.go: comment out A found, uncomment B found lines.
  • golangci-lint run
  • Note stale ruleguard: A found linter diagnostic
  • golangci-lint cache clean && golangci-lint run
  • Note fresh ruleguard: B found linter diagnostic

So the cache is not being discarded when ruleguard rules change.

This is problematic:

  • In CI it means caching must be disabled, so CI builds become slower than they should be
  • For local environment it means a local lint run will return stale results, especially after pulling in changed rules from the repository. This is extremely confusing.
Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.39.0 built from 9aea4aee on 2021-03-26T08:02:53Z
Config file
$ cat .golangci.yml
linters:
  enable:
    - gocritic
linters-settings:
  gocritic:
    enabled-checks:
      - ruleguard
    settings:
      ruleguard:
        rules: "rules/rules.go"
Go environment
$ go version && go env
go version go1.16.3 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/dottedmag/.cache/go-build"
GOENV="/home/dottedmag/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/dottedmag/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/dottedmag/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/dottedmag/tectonic/_deps.linux-amd64/go-1.16.3"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/dottedmag/tectonic/_deps.linux-amd64/go-1.16.3/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.3"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/dottedmag/w/golangci-cache-ruleguard/go.mod"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2596763710=/tmp/go-build -gno-record-gcc-switches"
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -v
# as explained above
Code example or link to a public repository

https://github.com/ridge/golangci-cache-ruleguard

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions