-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Vet and improve source code using NilAway
Add NilAway (<https://github.com/uber-go/nilaway>) as a new vet check in order to detect and address potential runtime errors due to nil values. All 4 violations it detected have been addressed. In `analyze.go` this simply constitutes checking that received pointers aren't nil. In `main.go` this constites, first, explicitly relying on the `ok` check of a map lookup when trying to use said key (instead of implicitly relying on the control flow being such that said key is injected if it isn't there already), and second, rewriting to avoid using `strings.Split` and instead using index lookup - in this case the finding by NilAway was a false positive (`nil` can never be returned by `strings.Split`, even if the internal function used may return `nil` in some cases) but rewriting reduces memory usage. The modifications are partially tested, covering only `analyze.go` because `main.go` isn't covered by unit tests. Signed-off-by: Eric Cornelissen <ericornelissen@gmail.com>
- Loading branch information
1 parent
fa28274
commit 3c008e6
Showing
4 changed files
with
33 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters