-
Notifications
You must be signed in to change notification settings - Fork 42
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
Should not recommend to use ignore
build tag
#408
Comments
For the benefit of people running into this problem, this is the actual error you see when using gocritic or golangci-lint:
that's caused by not being able to load the rules. gocritic/golangci-lint eats up the error and reports the above instead. |
Ideally, I would like to make Basically it boils down to how |
Oh, sure, @quasilyte, I understand that, that's why I said this is related but not the same as the other issue. My "problem" right now is that the existing documentation tells you to do something that won't work (given some conditions). Would you like me to open a PR to change the recommendation to use |
@mem sure. At the very least it would be helpful to describe the issues that can show up in that case. |
This section explains two common problems found when trying to run ruleguard: - the dsl package not being available - the dsl package not being included as a dependency of the module Fixes quasilyte#408 Signed-off-by: Marcelo E. Magallon <marcelo.magallon@gmail.com>
OK, I have created a PR (#411) where I added a troubleshooting section to README.md (to try to make it visible). There I show some of the output I have seen when running into this isuse. Hopefully that's clear enough to help others running into this. |
This section explains two common problems found when trying to run ruleguard: - the dsl package not being available - the dsl package not being included as a dependency of the module Fixes #408 Signed-off-by: Marcelo E. Magallon <marcelo.magallon@gmail.com>
This is related but not the same as #253
I was getting a very weird error from golangci-lint about an empty ruleset and forgetting to call
Load()
.In short, I was in a similar situation that described by #253: in order to avoid my main module from depending on the dsl, I created another module that contains the rules and other tools. When trying to run ruleguard, it fails to load the rules because the dsl is not imported by the main module (the one being checked).
After much confusion, I ended up moving the rules to the main module. After running
ruleguard worked!
My CI process runs
go mod tidy
to make sure thatgo.mod
andgo.sum
are up to date. This was failing becausego mod tidy
was removinggithub.com/quasilyte/go-ruleguard/dsl
fromgo.mod
.I was able to easily reproduce this behavior locally:
After digging around, it turns out that while
go mod tidy
does not care about build constraints (it behaves as if every possible build constraint is in effect, so that it loads all the packages and all the files in the module), it will ignore anything usingignore
as a tag.That's documented here:
https://go.dev/ref/mod#go-mod-tidy
and it's implemented here:
https://github.com/golang/go/blob/master/src/cmd/go/internal/imports/build.go#L188
I opened an issue in the go repo: golang/go#54993
And also a CL: https://go.dev/cl/430136
The behavior around
ignore
is not going to change, so until #253 is addressed, I propose that ruleguard stops recommending the use of theignore
tag, as that makes the rules invisible togo mod tidy
and therefore it removes the dsl fromgo.mod
.The text was updated successfully, but these errors were encountered: