Go

Go

Made by DeepSource
Function with cyclomatic complexity higher than threshold GO-R1005
Anti-pattern
Minor

A function with high cyclomatic complexity can be hard to understand and maintain. Cyclomatic complexity is a software metric that measures the number of independent paths through a function. A higher cyclomatic complexity indicates that the function has more decision points and is more complex.

Using a deprecated function, variable, constant or field GO-W1009
Anti-pattern
Major

Sometimes a function, variable, constant, field, or whole package becomes redundant or unnecessary but must be kept for compatibility with existing programs. These should not be used except for compatibility with legacy systems.

true is implicit in switch statements CRT-A0015
Anti-pattern
Minor
Autofix

If no tag is given with switch, it assumes true.

Simplify if statement for single bool judgment GO-R1004
Anti-pattern
Minor
Autofix

if statement can be simplified where only a single bool judgment is happening. It is more idiomatic not to store the result of a function returning a bool and compare that in if statement's conditional. It is better to skip the initialization expression.

Use any instead of interface{} GO-R3001
Anti-pattern
Critical
Autofix

In Go 1.18+, empty interface (interface {}) is recommended to be replaced by any.

Use time.Sleep instead of single case select SCC-S1037
Anti-pattern
Major
Autofix

Instead of using a single case in a select statement that receives results from time.After is preferable to simply use time.Sleep.

Self-assignment of variables SCC-SA4018
Anti-pattern
Minor
Autofix

Self-assignment of variables is pointless and should be avoided.

Only the first constant has an explicit type SCC-SA9004
Anti-pattern
Major
Autofix

Every constant in a constant declaration block needs to have a type unless the iota construct is used

Empty fallthrough in switch statement can be avoided CRT-A0003
Anti-pattern
Major
Autofix

Empty fallthrough can be avoided by clubbing together consecutive cases, using multi-case values.

Empty string test can be improved CRT-A0004
Anti-pattern
Major
Autofix

It is not recommended to use len for empty string test.

Method expression can be replaced with method call CRT-A0006
Anti-pattern
Major

It is not recommended to use method expression instead of method call.

Redundant conversion between string and []byte CRT-A0007
Anti-pattern
Major
Autofix

Conversion between string and []byte is not required here, and it is better to pass the string as copy's argument as it is without type conversing it to []byte.

Unnecessary block CRT-A0008
Anti-pattern
Minor
Autofix

It is not recommended to use unnecessary blocks.

Swapping can be done using parallel assignment CRT-A0009
Anti-pattern
Major
Autofix

It is legal and idiomatic to swap values of two variables using "tuple assignment" instead of swapping them in multiple statements.

Function call can be replaced with helper function CRT-A0010
Anti-pattern
Major
Autofix

Certain functions, for a particular set of arguments, have shorthands (helpers) that can be used instead.

Nested if can be replaced with else if CRT-A0011
Anti-pattern
Major
Autofix

A single nested if inside an else block can be replaced with an else if.

switch with single case can be rewritten as if or if-else CRT-A0014
Anti-pattern
Minor

switch statements with a single case can be rewritten as if-else or if.

Simplify slice expression to sliced value itself CRT-A0016
Anti-pattern
Major
Autofix

If a value is of type slice already, it need not be converted to slice again.

Function literal can be simplified CRT-A0018
Anti-pattern
Major
Autofix

Function literals that only call a single function, without making any other changes to the value of the inner function, can be removed, as they are redundant. Instead, the inner function, that is being called inside the outer function should be called.

Deprecated io/ioutil package usage GO-C4001
Anti-pattern
Minor
Autofix

io/ioutil package, like most things with util in the name, has turned out to be a poorly defined and complex to understand the collection of things.