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
Traditionally we've refused to add checks that are already present in go vet, to avoid duplicated efforts. At one point, we even documented that we'd remove checks should they be added to vet.
This, however, has several negative consequences:
go vet has stricter performance goals and fewer dependencies to work with. We may provide improved versions of checks in vet
We're moving beyond just a simple CLI utility that behaves identically to vet. We have check IDs and an ignore feature. We have detailed documentation for each check. In the future, we will have cached type information, language server integration and JSON output. All of vet's checks could benefit from this.
It causes an unnatural split between two tools, requiring users to run both. Furthermore, people regularly forget which tool catches which bugs.
Hence, going forward, we should aim to catch all issues found by vet. We will not simply copy its code, but reimplement checks using our framework, to ensure that they can benefit from it.
List of go vet checks we may want to copy:
self-assignment
discarding pure function results (we already do this, just had extend our list of functions)
using HTTP response before checking error (we already do this for all io.Closers, which tends to be good enough)
check for incorrect format strings in printf-like functions
flag format strings that do not contain any format (for gosimple)
check for incorrectly defined tests and examples
check for invalid struct tags. definitely do the checks for known tags like json and xml. maybe don't do generic validation, as clients aren't required to follow the convention
flag useless/wrong bit shifts
detect copying of locks
detect failure to call cancellation function of context.WithCancel
flag impossible boolean expressions, a la x == 1 && x == 2. This is only the beginning, we can do much more analysis on boolean expressions later, especially once we have reliable value ranges.
flag common misuses of the atomic package
List of go vet checks that are not suitable:
Check that canonically named methods are canonically defined. This has the occasional false positive
Check that composite literals use keyed elements. This will likely be too noisy.
Detect shadowing. I'm not aware of a good heuristic.
Flagging misuses of unsafe.Pointer. Has a number of edge cases that trigger false positives.
assembly checks. Assembly is not our focus.
List of checks go vet refused to add or hasn't added yet:
Traditionally we've refused to add checks that are already present in go vet, to avoid duplicated efforts. At one point, we even documented that we'd remove checks should they be added to vet.
This, however, has several negative consequences:
Hence, going forward, we should aim to catch all issues found by vet. We will not simply copy its code, but reimplement checks using our framework, to ensure that they can benefit from it.
List of go vet checks we may want to copy:
x == 1 && x == 2
. This is only the beginning, we can do much more analysis on boolean expressions later, especially once we have reliable value ranges.List of go vet checks that are not suitable:
List of checks go vet refused to add or hasn't added yet:
The text was updated successfully, but these errors were encountered: