kisielk / errcheck

errcheck checks that you checked errors.
MIT License
2.36k stars 137 forks source link

test and fix check blanks in var declarations #219

Closed gburt closed 1 year ago

gburt commented 1 year ago

I noticed that var foo, _ = bar() blanks weren't getting checked because ast.GenDecl statements (a subset of which are var declarations) weren't being handled/visited. Fix that, and add back the analyzer tests for blank (and assert) flags.

To handle them, I refactored the existing assignment check. It's completely unchanged except it now takes LHS and RHS args that we feed it from both the GenDecl and AssignStmt nodes' values.

gburt commented 1 year ago

btw thanks for this work, we're very glad to have it helping make our code better!

kisielk commented 1 year ago

Thanks very much for the thorough PR. Looks good to me but it seems there are some failing tests. Could you please take a look?

gburt commented 1 year ago

doh I'd just been running go test -run TestAnalyzer/check_blanks and hadn't noticed the other test failures

gburt commented 1 year ago

now we just need to make a "you visited AssignStmt but not GenDecl" linter :)

kisielk commented 1 year ago

Waiting for #221 to merge before merging this.