-
Notifications
You must be signed in to change notification settings - Fork 112
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
chore(lint): disable shadowing checks with govet
#1940
Conversation
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 like it. When I first joined I was having this happen to me with "err" specifically but we wanted to have consistent error variable names (which makes sense), so I'm a fan of this change
Codecov Report
@@ Coverage Diff @@
## development #1940 +/- ##
============================================
Coverage 60.26% 60.26%
============================================
Files 180 180
Lines 18189 18189
============================================
Hits 10962 10962
Misses 5415 5415
Partials 1812 1812
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
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 was having this happen to me with "err" specifically but we wanted to have consistent error variable names (which makes sense).
I think, generally, the shadowing check appears when you are doing something like k, err :=
, where err is an old variable. (Is that right, or am I confusing with some other check)
Personally, it isn't a big pain for me to declare the variable separately to avoid this warning.
The check is, however, helpful, because it ensures that you are not using a different copy of some variable (err is getting re-initialized in above example). I have faced at least one bug because of this, and this check could prevent stuff like that.
you can't have locally-scoped variables in an if or for block for example if the variable name is already used in the upper scope.
Using a different variable name is less confusing for reader.
I agree with Kishan, I don't see this check as bad, it's helped catch bugs in the past. sure it can be annoying, but I'd rather have to declare a variable separately than have some bug |
Definitely. Although my problem is more about To illustrate a, err := f()
// ...
var b int
b, err = g()
// above you cannot do b, err := g() 😢 EDIT: I'll check you might be able to disable it for errors using the exclude rules |
4cc5616
to
4d7afb9
Compare
Shadowing detection is re-enabled, but shadow detection of errors ( |
586cb03
to
b372ed4
Compare
🎉 This PR is included in version 0.6.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Changes
govet
Feel free to comment & close it if you disagree with the change 😉
Tests
Issues
Primary Reviewer