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

go-ruleguard doesn't work since release 1.37.0, last working release is 1.36.0 #2172

Closed
4 tasks done
aojea opened this issue Aug 15, 2021 · 8 comments
Closed
4 tasks done
Labels
question Further information is requested

Comments

@aojea
Copy link

aojea commented Aug 15, 2021

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

Using the example described here to use go-ruleguard rules with golangci-lint

#912 (comment)

If I use version 1.36.0 or older, it works:

~/Downloads/golangci-lint-1.36.0-linux-amd64/golangci-lint run example.go 
example.go:6:9: ruleguard: can rewrite as xs[0] == ys[0] (gocritic)
	return !(xs[0] != ys[0])

If I use version 1.37.0 or newer, it does not work, no output:

~/Downloads/golangci-lint-1.37.0-linux-amd64/golangci-lint run example.go
echo $?
0
~/Downloads/golangci-lint-1.38.0-linux-amd64/golangci-lint run example.go
echo $?
0
golangci-lint run example.go #latest stable
echo $?
0

Version of golangci-lint

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

and all the published releases until 1.36.0

Configuration file

$ cat .golangci.yml
linters:
  enable:
    - gocritic
linters-settings:
  gocritic:
    enabled-checks:
      - ruleguard
    settings:
      ruleguard:
        rules: "rules.go"

Go environment

$ go version && go env
go version go1.16 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/aojea/.cache/go-build"
GOENV="/home/aojea/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/aojea/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/aojea/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="/dev/null"
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-build3018424698=/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/aojea/tmp /home/aojea /home /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 11 linters: [deadcode errcheck gocritic gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck] 
INFO [loader] Go packages loading at mode 575 (deps|name|types_sizes|compiled_files|exports_file|files|imports) took 8.463355ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 141.868µs 
INFO [linters context/goanalysis] analyzers took 9.111915ms with top 10 stages: gocritic: 4.91406ms, buildir: 390.344µs, ctrlflow: 358.986µs, fact_deprecated: 240.528µs, nilness: 196.467µs, printf: 196.288µs, typedness: 175.247µs, fact_purity: 154.578µs, deadcode: 148.82µs, ineffassign: 96.892µs 
INFO [runner] processing took 7.873µs with stages: max_same_issues: 1.326µs, skip_dirs: 687ns, max_from_linter: 662ns, nolint: 591ns, cgo: 500ns, skip_files: 448ns, autogenerated_exclude: 350ns, filename_unadjuster: 337ns, uniq_by_line: 334ns, exclude-rules: 333ns, identifier_marker: 328ns, path_prettifier: 324ns, exclude: 243ns, max_per_file_from_linter: 219ns, source_code: 216ns, path_shortener: 210ns, sort_results: 198ns, diff: 193ns, severity-rules: 191ns, path_prefixer: 183ns 
INFO [runner] linters took 47.704004ms with stages: goanalysis_metalinter: 47.556197ms 
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 2 samples, avg is 72.8MB, max is 73.3MB 
INFO Execution took 60.35258ms    

Code example or link to a public repository

// add your code here

Example here #912 (comment)

@aojea aojea added the bug Something isn't working label Aug 15, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented Aug 15, 2021

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

@aojea aojea changed the title go-ruleguard doesn't work since release 1.37.0 go-ruleguard doesn't work since release 1.37.0, last working release is 1.36.0 Aug 15, 2021
@aojea
Copy link
Author

aojea commented Aug 15, 2021

/cc @quasilyte

@aojea
Copy link
Author

aojea commented Aug 15, 2021

hmm, I don't know if I'm doing something wrong, this works if I use dsl/fluent instead dsl

-import "github.com/quasilyte/go-ruleguard/dsl"
+import "github.com/quasilyte/go-ruleguard/dsl/fluent"

@aojea
Copy link
Author

aojea commented Aug 15, 2021

ok, if I rewrite the rules to use dsl only it never works

// +build ignore

package gorules

import "github.com/quasilyte/go-ruleguard/dsl"

func _(m dsl.Matcher) {
	m.Match(`!($x != $y)`).Report(`can rewrite as $x == $y`)
}

if I use use dsl/fluent it works for 1.36 and older
can this dsl/fluent to dsl transition causing some issue in golangci-lint? or am I doing something wrong?

@ldez ldez added question Further information is requested and removed bug Something isn't working labels Aug 15, 2021
@aojea
Copy link
Author

aojea commented Aug 15, 2021

this seems related #2041
@ldez do you know if ruleguard is working in newer versions?
it is not working for me

@ldez
Copy link
Member

ldez commented Aug 16, 2021

Hello, it's not related to #2041, I think related to #1923.

ruleguard works as expected work me.

@quasilyte
Copy link
Contributor

I'm working on a fix that will make it possible to update the gocritic.
The underlying issue is quite complicated and can't be solved easily, so it takes time.
It's 80% done though.

@aojea
Copy link
Author

aojea commented Aug 17, 2021

I think is a problem with the modules in the project, however, the errors seems silently ignored in this case and that is why I was lost

@aojea aojea closed this as completed Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants