You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At work, we are working on updating all our linting, and one of the problems we have hit with wastedassign is that code like this gets flagged:
isFoo:=false// ...isFoo, err:=bar.Baz()
Now, I know that you should probably write var isFoo bool ... but it's not technically incorrect, and almost assuredly does not indicate an error, just someone who is used to other languages. It would be great if there were a way to avoid flagging that kind of a line so that we can use it for the other cases when it is much more likely to indicate a bug.
The text was updated successfully, but these errors were encountered:
I agree, and the error returned makes it a bit confusing to understand what the issue is exactly. Especially if someone isn't familiar with relying on a primitive's zero value.
This really would be great to fix. I personally use name := defaultValue over var name type because it makes it exceptionally clear what the start value is. If nothing else, I'd love a configuration flag for this.
Agreed with @drshriveer.
Declaration err := error(nil) is similar to var err error and I personally prefer first option but linter tells that is wasted assign.
At work, we are working on updating all our linting, and one of the problems we have hit with wastedassign is that code like this gets flagged:
Now, I know that you should probably write
var isFoo bool
... but it's not technically incorrect, and almost assuredly does not indicate an error, just someone who is used to other languages. It would be great if there were a way to avoid flagging that kind of a line so that we can use it for the other cases when it is much more likely to indicate a bug.The text was updated successfully, but these errors were encountered: