Skip to content

golangci-lint -> gocritic -> ruleguard fails with no indication #2190

Closed
@thockin

Description

@thockin

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

It seems that ruleguard demands github.com/quasilyte/go-ruleguard/dsl be available locally but when it's not, there's no error from golangci-lint. Running gocritic itself tells me:

$ gocritic
panic: load embedded ruleguard rules: typechecker error: rules/rules.go:4:2: could not import github.com/quasilyte/go-ruleguard/dsl (can't find import: "github.com/quasilyte/go-ruleguard/dsl")

golangci-lint (either by hand or run under docker) says nothing at all, making me BELIEVE my rules all pass.

Version of golangci-lint

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

Configuration file

$ cat .golangci.yml
run:
  timeout: 30m
  skip-files:
    - "^zz_generated.*"

issues:
  max-same-issues: 0

linters:
  disable-all: true
  enable: # please keep this alphabetized
    - deadcode
    - gocritic
    - ineffassign
    - staticcheck
    - unused
    - varcheck
linters-settings: # please keep this alphabetized
  gocritic:
    enabled-checks:
      - ruleguard
    settings:
      ruleguard:
        rules: "ruleguard_rules.go"
  staticcheck:
    go: "1.16"
    checks: [ "all" ]
  unused:
    go: "1.16"

Go environment

$ go version && go env
go version go1.16 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/thockin/.cache/go-build"
GOENV="/home/thockin/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/thockin/src/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/thockin/src/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/thockin/src/go/src/k8s.io/kubernetes/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-build2389944306=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /home/thockin/src/go/src/k8s.io/kubernetes /home/thockin/src/go/src/k8s.io /home/thockin/src/go/src /home/thockin/src/go /home/thockin/src /home/thockin /home /] 
INFO [config_reader] Used config file .golangci.yaml 
INFO [lintersdb] Active 6 linters: [deadcode gocritic ineffassign staticcheck unused varcheck] 
INFO [loader] Go packages loading at mode 575 (compiled_files|exports_file|name|types_sizes|deps|files|imports) took 393.318901ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 7.458204ms 
INFO [linters context/goanalysis] analyzers took 0s with no stages 
INFO [runner] processing took 3.273µs with stages: max_same_issues: 750ns, skip_dirs: 348ns, nolint: 275ns, filename_unadjuster: 218ns, max_from_linter: 210ns, skip_files: 206ns, cgo: 147ns, path_prettifier: 139ns, diff: 137ns, exclude: 135ns, uniq_by_line: 129ns, autogenerated_exclude: 128ns, identifier_marker: 127ns, source_code: 57ns, exclude-rules: 48ns, path_shortener: 46ns, max_per_file_from_linter: 44ns, path_prefixer: 43ns, sort_results: 43ns, severity-rules: 43ns 
INFO [runner] linters took 137.727999ms with stages: goanalysis_metalinter: 137.685261ms 
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 7 samples, avg is 71.9MB, max is 72.1MB 
INFO Execution took 543.696902ms                  

Code example or link to a public repository

// add your code here

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions