We’ve added 8 new Autofixes to our Go Analyzer to help you fix more issues in your Go code automatically. We have also updated our security issues with better descriptions, references, and examples.
Here’s the detailed changelog:
Issue Description Update
- Security issues updated with better descriptions and references.
- Security issues updated with examples of bad and recommended practices.
New Autofixes
- RVV-B0012: Unused parameter in function
Before Autofix:
func(x int) {
_ = 1
}
After Autofix:
func(_ int) {
_ = 1
}
- CRT-A0005: Hex literal with mixed case letters
Before Autofix:
x := 0XFF // X should not be capitalized for Hex Literal
y := 0xfF // Avoid mixed case for Hex Literal
After Autofix:
x := 0xFF
y := 0xFF
- CRT-A0007: Redundant conversion between
string
and[]byte
Before Autofix:
dst, src := []byte{}, []byte("src")
copy(dst, []byte(src))
After Autofix:
dst, src := []byte{}, []byte("src")
copy(dst, src)
- CRT-A0008: Unnecessary block
Before Autofix:
x := 1
{
x += 4
}
After Autofix:
x := 1
x += 4
- CRT-D0012: Flag name has suspicious characters
Before Autofix:
b := flag.Bool(" foo ", false, "description") // flagname has spaces
After Autofix:
b := flag.Bool("foo", false, "description")
- CRT-D0013: Return of
nil
value
Before Autofix:
if err == nil {
return err // not idiomatic
}
After Autofix:
if err == nil {
return nil
}
- CRT-D0015: Off-by-one error
Before Autofix:
slice[len(slice)] // panics
After Autofix:
slice[len(slice)-1]
- SCC-S1029: Range over the
string
directly
Before Autofix:
s := "string"
for _, r := range []rune(s) {
_ = r
}
After Autofix:
s := "string"
for _, r := range s {
_ = r
}