Debian Codegraph @

website/content/changes/2023.1.md

raw
1 ---
2 title: Staticcheck 2023.1 release notes
3 linkTitle: "2023.1 (v0.4.0)"
4 weight: -8
5 ---
6
7 Staticcheck 2023.1 adds support for Go 1.20, brings minor improvements to various checks, and replaces U1000
8 with a new implementation.
9
10 ## Checks {#checks}
11
12 ### Changed checks {#checks-changed}
13
14 The following checks have been improved:
15
16 - The wording of {{< check "S1001" >}} has been made clearer for cases involving arrays. Furthermore, it no longer
17 suggests using `copy` when the function has been shadowed.
18 - {{< check "S1011" >}} now recognizes index-based loops ({{< issue "881" >}}).
19 - {{< check "SA1019" >}} no longer flags tests (internal or external) that use deprecated API from the package under
20 test ({{< issue "1285" >}}). Furthermore, entire declaration groups (such as groups of constants) can now be marked as
21 deprecated ({{< issue "1313" >}}).
22 - {{< check "SA4017" >}} now detects more functions, including those in the `time` package ({{< issue "1353" >}}).
23 Additionally, its wording has been made clearer.
24 - {{< check "SA5010" >}} no longer gets confused by type assertions involving generic types ({{< issue "1354" >}}).
25 - {{< check "ST1005" >}} no longer flags errors that start with alpha-numeric acronyms such as `P384`.
26 - Improvements to our intermediate representation may allow various checks to find more problems.
27
28 Staticcheck now knows about version 2 of the `k8s.io/klog` package, in particular which functions abort control flow
29 ({{< issue "1307" >}}).
30
31 In addition to these minor improvements, U1000 has been rewritten from the ground up, operating on a
32 program representation more suited to the task. In practice this means that there will be fewer false positives and more
33 true positives.
34
35 Overall, the rewrite fixes at least eight known bugs, both ones that have been a nuisance for a while,
36 as well as ones newly introduced by generics
37 ({{< issue "507" >}}, {{< issue "633" >}}, {{< issue "810" >}}, {{< issue "812" >}}, {{< issue "1199" >}}, {{< issue
38 "1249" >}}, {{< issue "1282" >}}, {{< issue "1333" >}}).
39
40 ## Staticcheck 2023.1.1 release notes {#2023.1.1}
41
42 This release fixes a crash, a false positive in U1000 ({{< issue "1360" >}}) and improves the way deprecated API is
43 flagged ({{< issue "1318" >}}).
44
45 When targeting a Go version that is older than the version that deprecated an API, {{< check "SA1019" >}} will no longer
46 flag the use even if there is already an alternative available in the targeted Go version.
47
48 For example, `math/rand.Seed` has been deprecated in Go 1.20, but an alternative has existed since Go 1.0. In the past,
49 we would flag uses of `Seed` even if targeting e.g. Go 1.19, to encourage better forwards compatibility. This can lead
50 to unnecessary churn, however, because the correct change may depend on the Go version in use. For example, for `Seed`
51 before Go 1.20, the alternative is to use a separate instance of `math/rand.Rand`, whereas in Go 1.20, a possible
52 alternative is to simply drop the call to `Seed`.
53
54 ## Staticcheck 2023.1.2 release notes {#2023.1.2}
55
56 This release fixes a bug that prevented the `binary` formatter from working ({{< issue "1370" >}}).
57
58 ## Staticcheck 2023.1.3 release notes {#2023.1.3}
59
60 This release fixes the following bugs:
61
62 - A crash when embedding type aliases of unnamed types ({{< issue "1361" >}})
63 - A false positive in U1000, claiming that type aliases are unused ({{< issue "1365" >}})
64 - A bug in the `binary` formatter that prevented correct merging behavior for some checks ({{< issue "1372" >}})
65
66 ## Staticcheck 2023.1.4 release notes {#2023.1.4}
67
68 This release **adds support for Go 1.21** and fixes the following bugs:
69
70 - Three crashes when encountering unnecessarily parenthesized statements ({{< issue "1393" >}}, {{< issue "1400" >}})
71 - Unnecessarily high memory usage when analyzing composite literals such as `[]int{1<<31: 1}` ({{< issue "1393" >}})
72 - A false positive in {{< check "S1011" >}} when appending to a dynamic left-hand side ({{< issue "1399" >}})
73 - A crash involving generics ({{< issue "1410" >}})
74 - A false positive in {{< check "SA9001" >}} involving control flow statements ({{< issue "488" >}})
75 - A false positive in {{< check "ST1003" >}}, complaining about the names of fuzz functions ({{< issue "1420" >}}))
76
77 ## Staticcheck 2023.1.5 release notes {#2023.1.5}
78
79 This release fixes the following bug:
80
81 - A crash involving methods named `_`
82
83 ## Staticcheck 2023.1.6 release notes {#2023.1.6}
84
85 This release fixes the following bugs:
86
87 - A crash when using the upcoming Go 1.22 ({{< issue "1442" >}})
88 - A false positive in {{< check "SA9005" >}} when embedding basic types ({{< issue "1443" >}})
89
90 ## Staticcheck 2023.1.7 release notes {#2023.1.7}
91
92 This release fixes some minor issues in Staticcheck's intermediate representation. Furthermore, it improves the way {{<
93 check "QF1003" >}} generates suggested fixes, working around constraints in the language server protocol.
94
95 The released binaries for this version have been built with Go 1.22 and should no longer panic when checking code
96 targeting Go 1.22.