errcheck - Check unchecked errors in Go code. These unchecked errors can be critical bugs in some cases.
goimports - Check import statements are formatted according to the 'goimport' command. Reformat imports in autofix
mode.
revive - Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of
golint. what can do
govet - Vet examines Go source code and reports suspicious constructs. It is roughly the same as 'go vet' and uses its
passes.
staticcheck - It's a set of rules from staticcheck.
Checks:
Custom PA
Variable usage with mutex check - possible with tags ad CFG. Highlighting: WARNING (cause of accuracy?)
Null interface call check - possible with CFG. Highlighting: WARNING (cause of accuracy?)
Cast interface to type check - possible with AST (golang-linter should check that first var is interface).
Highlighting: WARNING (cause of accuracy?). !ATTENTION! res = a.(b) valid for checker if b implement a. Need
TypeCheck? UPD: Detected by existing linters
StrConv instead fmt - possible with
AST. Highlighting: ERROR.
Grade: π.
Status: test
String to byte repeating avoid -
possible with AST (we just want to find "str to byte" in cycle)?
Highlighting: WARNING (cause of accuracy?).
Status: test
Map capacity -
possible with AST.
Highlighting: WARNING (cause of "try")
Grade: π.
Status: not implemented
Guidelines
Pointers to Interfaces - possible
with AST (pointer variable decl + assignment with new(...) or we need a TypeCheck info for resolve expressions?)?
Highlighting: WARNING (cause of "usually").
Status: not implemented
Verify Interface Compliance -
possible with AST (just find custom interface and decl with casting it to null)?
Highlighting: ERROR (or it is not important?).
Status: not implemented
Receivers and Interfaces - possible
with TypeCheck info (we should resolve expression type?)?.
Highlighting: ERROR.
Status: not implemented
Copy Slices and Maps at Boundaries -
possible with ??? (I think with AST we can check fact that input and output variables was copied or not, but if we
create
copies in some call - AST useless, it should be CFG analysis).
Highlighting: WARNING (cause of accuracy?)
Status: not implemented
Defer to Clean Up -
possible with AST? We can just find usages of Unlock and Close operation outside defer.
Highlighting: WARNING (cause of accuracy?).
Grade: π.
Status: draft
Channel Size is One or None -
possible with AST. Highlighting: WARNING (cause of "usually").
Grade: π.
Status: test
Start Enums at One -
possible with AST. Highlighting: WARNING (cause of "usually").
Grade: π.
Status: test
Use "time" to handle time -
impossible. We can't detect places where Int/Float... use like Time. We can try to detect write Time.time to
Json without specific tag, but it is doubtful.
Errors - possible with AST. Highlighting:
WARNING (cause of accuracy). We can check error.New() outside VarDecl and fmt.Errorf outside Struct, but it may
be useless. Grade: π
Error wrapping - I don't understand
example. I think they mean just apply context to error if possible. It looks like impossible for detection.
Error naming - Possible with AST.
Highlighting:
Error (because we can?).
Grade: π.
Handle Errors Once - Possible with AST
but better with CFG. All we want is check log error with return in one scope? Highlighting: WARNING (cause of
accuracy).
Grade: π.
Handle Type Assertion Failures -
possible with AST. Highlighting: WARNING (cause of optional?).
Grade: π.
Status: test
Don't Panic - possible with AST. Highlighting:
Error.
Grade: π.
Status: test
Use go.uber.org/atomic - possible with
AST. We need detect types from this and suggest to use uber atomic.
Highlighting:
WARNING (cause of optional?).
Grade: π-π.
Avoid Mutable Globals - possible with
AST? Detect global var declaration is enough. Highlighting: WARNING (cause of "usually").
Grade: π.
Status: test
Avoid Embedding Types in Public Structs -
Possible with AST but a more complex than other AST tasks. We need to find structures that use other structures from
our project and check that property declared? I think I'm wrong.
Highlighting: WARNING (cause of accuracy).
Grade: π
Avoid Using Built-In Names -
possible with AST? I don't know how look go parser rules, but it may be very easy.
Highlighting: Error.
Grade: π.
Status: may be ready in default linters.
Avoid init() -
possible with AST. Highlighting: WARNING (cause of optional?).
Grade: π.
Exit in Main -
possible with AST. Highlighting: Error.
Grade: π.
Exit Main Once
possible with AST. Highlighting: WARNING (cause of "if possible").
Grade: π.
Use field tags in marshaled structs -
for this task we need to get types (struct) of variables and find these structs. Go ast/cfg hold this data?
Highlighting: WARNING (cause of accuracy).
Grade: π.
Don't fire-and-forget goroutines -
may be possible with AST, but I think it is confusing task.
Highlighting: WARNING (cause of accuracy).
Grade: π.
Import Group Ordering -
possible with AST. Already in golangci-lint?
Grade: π.
Status: need to check default linter!
Package Names -
possible with AST. Already in golangci-lint (partly).
Grade: π.
Status: need to check default linter!
Function Names -
possible with AST. Already in golangci-lint?
Grade: π.
Status: need to check default linter!
Import Aliasing -
possible with AST, but we need to library sources.
Grade: π.
Function Grouping and Ordering -
I think it is possible with AST, because we need only approximate order
of intra-procedure execution, but CFG more correct.
Grade: π.
Top-level Variable Declarations -
potential possible with AST, but I think we can't support this right now - for stable work we should check type of
any expression or identifier.
Grade: βΉοΈ.