Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

Some vet tools fixes #688

Merged
merged 2 commits into from
Apr 24, 2019
Merged

Some vet tools fixes #688

merged 2 commits into from
Apr 24, 2019

Conversation

juanjux
Copy link
Contributor

@juanjux juanjux commented Apr 23, 2019

Fixes #686 except for a false positive (bug?) in the nilness tool.

db, err := dsql.Open("mysql", connString(c.user, ""))
req.NoError(err)
_, err = db.Query(c.query)
db, e := dsql.Open("mysql", connString(c.user, ""))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why e?

Copy link
Contributor Author

@juanjux juanjux Apr 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To shut up go vet about shadowing err in the enclosing context.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then you can do

var db *sql.DB
db, err = dsql.Open(yada yada)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var db *dsql.DB actually. It's one line more, but ok, err is certainly more easy to human-parse than just e.

Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
Copy link
Contributor

@ajnavarro ajnavarro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juanjux could you review again all the error variable names?

Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
@juanjux
Copy link
Contributor Author

juanjux commented Apr 24, 2019

@ajnavarro check the last commit (I'll rebase it later), I've renamed most of the es but for a couple cases in catalog.go and resolved_table.go where the enclosing error variable is being used later with a value from in the current context and thus we either keep the e or the warning (and the danger of somebody not typing := and overwriting the enclosing one on a refactor).

@ajnavarro ajnavarro merged commit edd578f into src-d:master Apr 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vet tool
5 participants