-
Notifications
You must be signed in to change notification settings - Fork 143
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
Add linting rules for replace
directives in go.mod
#2638
Add linting rules for replace
directives in go.mod
#2638
Conversation
This pull request does not have a backport label. Could you fix it @ycombinator? 🙏
NOTE: |
🌐 Coverage report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree with this change, the whole point of the linter is to catch things like this.
Why is it a problem to have the linter issue reported in a PR made for development?
The linter does not block the CI or merging, this is only a notification and a reviewer decides whether to approve a PR with a linter issue or not. We should not hide issues only because they don't look nice on PRs.
@rdner I'm not following what you're suggesting. The changes to the linter rules in this PR make things stricter. My intention was to have the linter complain on PRs for the following use case:
With the linter changes in this PR, the replace directive will get flagged in CI. I think this is a good thing as it serves as reminder not to check in that change. It's not foolproof, yes, but it's better than nothing IMO. Can you explain why having such an automated check/reminder on the PR is a bad thing? |
@ycombinator wait, this check was enabled before. That's why I thought you disabled it. Seems like @cmacknz removed it in #1478 not sure why, there is no explanation. Of course I'm for having this and not against, sorry, I misunderstood the change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given I left a comment for every removed linter in https://github.com/elastic/elastic-agent/pull/1478/files except this one, I am quite sure I simply removed gomoddirectives
unintentionally.
It is also possible I didn't read the linter configuration closely enough to see that |
* Add linting rules for `replace` directives in go.mod * Adding test replace dependencies * Commenting out local replace * Run go mod tidy * Enable the linter * Add back both test examples * Removing local example * Trying out nolint * Trying again * Trying another way * Removing test replace directive (cherry picked from commit 3aeb206)
* Add linting rules for `replace` directives in go.mod * Adding test replace dependencies * Commenting out local replace * Run go mod tidy * Enable the linter * Add back both test examples * Removing local example * Trying out nolint * Trying again * Trying another way * Removing test replace directive (cherry picked from commit 3aeb206) Co-authored-by: Shaunak Kashyap <[email protected]>
What does this PR do?
This PR adds a
golangci-lint
linter rule for monitoring the use ofreplace
directives ingo.mod
.Why is it important?
Developers will sometimes use temporary
replace
directives ingo.mod
while developing a feature or fixing a bug that requires changes in dependencies as well. The linter rule introduced in this PR will ensure such temporaryreplace
directives do not get checked in by accident, by complaining on the PR like so: