1
0
mirror of https://github.com/golang/go synced 2024-11-18 21:24:44 -07:00
go/cmd/vet/testdata
Josh Bleecher Snyder 7da5f193b7 go.tools/cmd/vet: detect stupid boolean conditions
This CL introduces two vet checks. Statistics and code below are from a recent 50mb corpus of public code.

1. Check for redundant conjunctions and disjunctions. This check caught 26 instances, of which 20 were clearly copy/paste bugs and 6 appeared to be mere duplication. A typical example:

if xResolution < 0 || xResolution < 0 {
        panic("SetSize(): width < 0 || height < 0")
}

2. Check for expressions of the form 'x != c1 || x != c2' or 'x == c1 && x == c2', with c1 and c2 constant expressions. This check caught 16 instances, of which all were bugs. A typical example:

if rf.uri.Scheme != "http" || rf.uri.Scheme != "ftp" {
        rf.uri.Scheme = "file"
}

Fixes golang/go#7622.

LGTM=rsc, r
R=golang-codereviews, jscrockett01, r, gri, rsc
CC=golang-codereviews
https://golang.org/cl/98120043
2014-07-02 10:39:57 -07:00
..
asm1.s go.tools/cmd/vet: don't panic on commented-out asm 2014-06-20 16:52:48 -07:00
asm2.s
asm3.s
asm4.s
asm.go
assign.go
atomic.go go.tools/cmd/vet: fix a panic on invalid AddInt 2014-05-14 12:16:58 -07:00
bool.go go.tools/cmd/vet: detect stupid boolean conditions 2014-07-02 10:39:57 -07:00
buildtag_bad.go go.tools/cmd/vet: improve error message for build tag problems 2013-12-18 16:06:56 -08:00
buildtag.go go.tools/cmd/vet: improve error message for build tag problems 2013-12-18 16:06:56 -08:00
composite.go
copylock.go
deadcode.go go.tools/cmd/vet: prevent panic on goto without label 2014-06-20 11:08:45 -07:00
method.go
nilfunc.go
print.go vet: Don't consider %T for recursive stringers. 2014-03-14 16:08:04 +11:00
rangeloop.go
shadow.go go.tools/cmd/vet: don't check for shadowing of blank identifier 2014-03-13 10:27:55 +11:00
structtag.go cmd/vet: check for use of json/xml struct tags with unexported fields 2014-06-13 18:44:31 -07:00
unsafeptr.go cmd/vet: diagnose use of unsafe.Pointer to convert integer to pointer 2014-05-15 15:32:51 -04:00