|
| 1 | +--- |
| 2 | +title: Staticcheck 2022.1 release notes |
| 3 | +linkTitle: "2022.1 (v0.3.0)" |
| 4 | +weight: -7 |
| 5 | +--- |
| 6 | + |
| 7 | +## Improvements {#improvements} |
| 8 | + |
| 9 | +This release adds support for Go 1.18 and type parameters (generics). |
| 10 | + |
| 11 | +Furthermore, it adds two new flags for handling build tags, `-matrix` and `-merge`. Their use is extensively documented |
| 12 | +on the new [Build tags]({{< relref "/docs/running-staticcheck/cli/build-tags" >}}) page. Their intended use is for |
| 13 | +avoiding false positives when dealing with different build tags. |
| 14 | + |
| 15 | +Not tied directly to this release, but worth mentioning regardless: Staticcheck has an [official GitHub |
| 16 | +Action](https://github.com/dominikh/staticcheck-action) now, which may simplify your CI pipeline. |
| 17 | + |
| 18 | +Minor changes include slightly nicer output from `staticcheck -explain`, better error messages, and allowing whitespace in flags like `-checks`. |
| 19 | + |
| 20 | +## Checks {#checks} |
| 21 | + |
| 22 | +### New checks {#checks-new} |
| 23 | + |
| 24 | +The following new checks have been added: |
| 25 | + |
| 26 | +- {{< check "SA4028" >}} flags `x % 1`, which always yields zero, and is sometimes accidentally used instead of `x % 2` |
| 27 | +- {{< check "SA4029" >}} flags misuses of `sort.IntSlice` and related types |
| 28 | +- {{< check "SA4030" >}} flags misuses of `math/rand` that always generate zeros |
| 29 | +- {{< check "SA4031" >}} flags comparisons of never-nil values against nil |
| 30 | +- {{< check "SA9007" >}} flags attempts at deleting system directories |
| 31 | +- {{< check "SA9008" >}} flags accidental shadowing in the else branches of type assertions |
| 32 | + |
| 33 | +### Changed checks {#checks-changed} |
| 34 | + |
| 35 | +The following checks have been improved: |
| 36 | + |
| 37 | +- {{< check "S1001" >}} now simplifies more loops |
| 38 | +- {{< check "S1038" >}} now simplifies formatted printing in `log` and `testing`, in addition to `fmt` |
| 39 | +- {{< check "SA1019" >}} no longer flags deprecated API in the Go standard library if it doesn't know when the API was |
| 40 | + deprecated. This is to avoid false positives when using older versions of Staticcheck on newer versions of Go, in |
| 41 | + particular Go's `master` branch. |
| 42 | +- {{< check "SA1020" >}} no longer flags `net/http.ListenAndServe` with a completely empty address |
| 43 | +- {{< check "ST1001" >}} various packages of `github.com/mmcloughlin/avo` have been whitelisted by default |
| 44 | +- {{< check "ST1008" >}} no longer flags functions that return `(..., error, bool)` |
| 45 | +- {{< check "ST1018" >}} no longer flags emoji sequences |
| 46 | +- {{< check "ST1023" >}} no longer makes erroneous suggestions |
| 47 | +- Numerous checks have a better understanding of integer literals and can detect mistakes involving unconventional |
| 48 | + literals such as `---1` instead of `-1` |
| 49 | +- Some runtime crashes have been fixed |
0 commit comments