-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
pkg/golinters: add noreplace #1812
Conversation
Hey, thank you for opening your first Pull Request ! |
596a91f
to
d49a358
Compare
Hello, I don't think that calling the go CLI is the right way to do that. (https://git.sr.ht/~urandom/noreplace/tree/master/item/noreplace.go#L22) The following implementation seems better: https://github.com/gostaticanalysis/noreplace |
oh, it is super gross, but I did not know about your noreplace, so I followed what gomodguard does. (a merged linter.) I would rather not support this one off package, let me see if I can drop in the gostaticanalysis package. EDIT: also, heads up they do the same thing just one level deeper. this is a fundamental limitation of the stdlib, since this is not exported at runtime and hidden behind |
ok but it seems weird, I will try to find how the do that without the go command. FYI, I was not a maintainer when |
Another idea, maybe this can be added to |
Add support for enforcing that go.mod should not contain replace clauses.
I looked at that first, but Also, the implementation of noreplace is not optimal. Notice that my package actually returns cc @ryancurrah |
Yes in fact the noreplace implementation seems worse than the The code inside the Go command to find the module path: |
Edit: I have my answer: it's with patch by mail 😹 ( |
Are you sure to want to use SourceHut instead of Github/Gitlab/Bitbucket for this kind of project? SourceHut uses an old way for community contributions, for me it's more a way to limit contributions because the contribution cost is high. |
it is my default, so yes; plus the code should be pretty stable, with the exception of needing to pass more data to golangci-lint, or an eventual if you would like |
So maybe you can split your code into two parts:
Like that it will be possible to get the mod path only one time. Edit: in fact, I'm not sure what is the best way 🤔 |
can you elaborate? (suggestions are welcome) I am not familiar with the inner workings of the I am just unclear why |
My suggestion ldez@11f852d I tested it on golangci-lint with: go run ./cmd/golangci-lint/ run --no-config --disable-all --enable=noreplace |
More I watch your linter more I think there is a problem with the current implementation of |
left some comments inline; though I was suggesting you use the ```suggestion interface (ctrl+g), as it would keep everything in the pr.
yeah, I think that anything doing |
I know "github suggestions" but my suggestions are too large. |
I tested the PR on a sandbox project and in fact it doesn't work. |
We could add |
Edit: it works as expected |
@carnott-snap Have you tried your PR (not your noreplace binary but a golangci-lint binary) on a real project? |
If everybody prefers that, I have some sample code I was messing around with, but it was not working. Probably speaks to @ldez's comment. I will wait for confirmation before opening that pr. |
I have been using it where I work for a while, no issues so far. What were you expecting it to do? Maybe I can help clear any confusion up.
It should be pretty easy to identify replace directives with the As per the module documentation.
So we look for |
I edited my message, it works.
I see 2 use-cases for a
|
I can see a third case:
|
So there are 3 options:
|
Yeah, those are definitely valid cases. The |
I agree, the |
@carnott-snap I'm not sure we understand each other, I was talking about creating a dedicated linter for this. |
EDIT: I created the |
I will close this PR in favor of #1817 |
Add support for enforcing that go.mod should not contain replace clauses.
https://git.sr.ht/~urandom/noreplace