From 9f2f119520876d4c5e54468ec63e55ab6a6c04fa Mon Sep 17 00:00:00 2001 From: healthy-pod Date: Wed, 30 Nov 2022 17:19:10 -0800 Subject: [PATCH] nogo: detect deprecated go standard library packages In #87327, we patched `staticcheck` to detect deprecated "objects" from the standard library. This patch ensures that we also detect deprecated "packages". Closes #84877 Release note: None --- build/bazelutil/nogo_config.json | 9 ++++++++- build/patches/co_honnef_go_tools.patch | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/build/bazelutil/nogo_config.json b/build/bazelutil/nogo_config.json index 4f6f5b2f979a..34a2c9a23424 100644 --- a/build/bazelutil/nogo_config.json +++ b/build/bazelutil/nogo_config.json @@ -739,7 +739,14 @@ "pkg/sql/execinfra/processorsbase.go$": "temporary exclusion until deprecatedContext is removed from eval.Context", "pkg/sql/importer/import_table_creation.go$": "temporary exclusion until deprecatedContext is removed from eval.Context", "pkg/sql/row/expr_walker_test.go$": "temporary exclusion until deprecatedContext is removed from eval.Context", - "pkg/sql/schemachanger/scbuild/tree_context_builder.go$": "temporary exclusion until deprecatedContext is removed from eval.Context" + "pkg/sql/schemachanger/scbuild/tree_context_builder.go$": "temporary exclusion until deprecatedContext is removed from eval.Context", + "pkg/security/securityassets/security_assets.go$": "excluded until all uses of io/ioutil are replaced", + "pkg/roachprod/install/cluster_synced.go$": "excluded until all uses of io/ioutil are replaced", + "pkg/security/securitytest/securitytest.go$": "excluded until all uses of io/ioutil are replaced", + "pkg/server/dumpstore/dumpstore.go$": "excluded until all uses of io/ioutil are replaced", + "pkg/server/dumpstore/dumpstore_test.go$": "excluded until all uses of io/ioutil are replaced", + "pkg/server/heapprofiler/profilestore_test.go$": "excluded until all uses of io/ioutil are replaced", + "pkg/util/log/file_api.go$": "excluded until all uses of io/ioutil are replaced" }, "only_files": { "cockroach/pkg/.*$": "first-party code" diff --git a/build/patches/co_honnef_go_tools.patch b/build/patches/co_honnef_go_tools.patch index ea4e0b73946e..8dee2b6bb8cf 100644 --- a/build/patches/co_honnef_go_tools.patch +++ b/build/patches/co_honnef_go_tools.patch @@ -1,5 +1,5 @@ diff --git a/staticcheck/lint.go b/staticcheck/lint.go -index 85bcb21..e91e81c 100644 +index 85bcb21..9fb4cc0 100644 --- a/staticcheck/lint.go +++ b/staticcheck/lint.go @@ -3080,6 +3080,9 @@ func CheckDeprecated(pass *analysis.Pass) (interface{}, error) { @@ -44,3 +44,12 @@ index 85bcb21..e91e81c 100644 } return true } +@@ -3209,6 +3214,8 @@ func CheckDeprecated(pass *analysis.Pass) (interface{}, error) { + } + + handleDeprecation(depr, spec.Path, path, path, nil) ++ } else if _, ok := knowledge.StdlibDeprecations[path]; ok { ++ handleDeprecation(nil, spec.Path, path, path, nil) + } + } + pass.ResultOf[inspect.Analyzer].(*inspector.Inspector).Nodes(nil, fn)