Skip to content

Commit

Permalink
Add staticcheck.conf to reduce unactionable noise in IDEs (hashicorp#…
Browse files Browse the repository at this point in the history
…34036)

Since we already specify a list of staticcheck rules to ignore in the
scripts/staticcheck.sh wrapper script, this hoists those preferences up to the
top of the package tree, so they also affect the staticcheck integration in
editors like VSCode. This avoids unnecessary yellow-squiggles for capitalized
error messages, and makes integrated linting much more useful.
  • Loading branch information
nfagerlund authored Oct 12, 2023
1 parent 24ac539 commit af441ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 3 additions & 6 deletions scripts/staticcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ skip=$skip"|internal/planproto|internal/tfplugin5|internal/tfplugin6"

packages=$(go list ./... | egrep -v ${skip})

# We are skipping style-related checks, since terraform intentionally breaks
# some of these. The goal here is to find issues that reduce code clarity, or
# may result in bugs. We also disable fucntion deprecation checks (SA1019)
# because our policy is to update deprecated calls locally while making other
# nearby changes, rather than to make cross-cutting changes to update them all.
go run honnef.co/go/tools/cmd/staticcheck -checks 'all,-SA1019,-ST*' ${packages}
# Note that we globally disable some checks. The list is controlled by the
# top-level staticcheck.conf file in this repo.
go run honnef.co/go/tools/cmd/staticcheck ${packages}
7 changes: 7 additions & 0 deletions staticcheck.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Our goal in using staticcheck is to find issues that reduce code clarity, or
# may result in bugs. We are skipping style-related checks, since terraform
# intentionally breaks some of these. We also disable function deprecation
# checks (SA1019) because our policy is to update deprecated calls locally while
# making other nearby changes, rather than to make cross-cutting changes to
# update them all.
checks = ["all", "-SA1019", "-ST*"]

0 comments on commit af441ab

Please sign in to comment.