Skip to content

Staticcheck 2023.1 (v0.4.0)

Compare
Choose a tag to compare
@dominikh dominikh released this 03 Feb 02:18
· 116 commits to master since this release
2023.1

Staticcheck 2023.1 adds support for Go 1.20, brings minor improvements to various checks, and replaces U1000 with a new implementation.

The following checks have been improved:

  • The wording of S1001 has been made clearer for cases involving arrays. Furthermore, it no longer suggests using copy when the function has been shadowed.
  • S1011 now recognizes index-based loops (issue 881).
  • SA1019 no longer flags tests (internal or external) that use deprecated API from the package under test (issue 1285). Furthermore, entire declaration groups (such as groups of constants) can now be marked as deprecated (issue 1313).
  • SA4017 now detects more functions, including those in the time package (issue 1353). Additionally, its wording has been made clearer.
  • SA5010 no longer gets confused by type assertions involving generic types (issue 1354).
  • ST1005 no longer flags errors that start with alpha-numeric acronyms such as P384.
  • Improvements to our intermediate representation may allow various checks to find more problems.

Staticcheck now knows about version 2 of the k8s.io/klog package, in particular which functions abort control flow (issue 1307).

In addition to these minor improvements, U1000 has been rewritten from the ground up, operating on a program representation more suited to the task. In practice this means that there will be fewer false positives and more true positives.

Overall, the rewrite fixes at least eight known bugs, both ones that have been a nuisance for a while, as well as ones newly introduced by generics (issue 507, issue 633, issue 810, issue 812, issue 1199, issue 1249, issue 1282, issue 1333).