Commit abe7238
authored
Upgrade golangci-lint to v2 (#2169)
Summary: Upgrade golangci-lint to v2
This upgrades golangci-lint to v2 and remediates the golangci-lint
crashes seen in other PRs (#2167). The vast majority of the new
violations have been resolved with the exception of some more stylistic
staticcheck cases.
Rather than ignoring these cases, they should be easy to handle if/when
the offending code is modified. The specific violations can be seen in
the Test plan below.
The pr-genfile-checker issues related to go generate will be fixed in
#2167. I opted to split these changes into two PRs despite them both
needing to be available for a successful build.
Relevant Issues: N/A
Type of change: /kind dependency
Test Plan: Existing build and the following checks
- [x] `CGO_ENABLED=0 golangci-lint run` succeeds for the majority of
checks
<details><summary>command output</summary>
```
root@px-dev-docker-dev-vm:/px/src/px.dev/pixie# CGO_ENABLED=0 golangci-lint run
src/cloud/api/controllers/session_middleware.go:173:2: QF1007: could merge conditional assignment into variable declaration (staticcheck)
forceBearer := false
^
src/cloud/artifact_tracker/controllers/server.go:176:5: QF1001: could apply De Morgan's law (staticcheck)
if !(at == vpb.AT_DARWIN_AMD64 || at == vpb.AT_LINUX_AMD64 || at == vpb.AT_CONTAINER_SET_YAMLS || at == vpb.AT_CONTAINER_SET_TEMPLATE_YAMLS) {
^
src/cloud/autocomplete/suggester.go:176:5: QF1003: could use tagged switch on a.Type (staticcheck)
if a.Type == vispb.PX_POD {
^
src/cloud/autocomplete/suggester.go:276:23: QF1001: could apply De Morgan's law (staticcheck)
if res.NS != "" && !(md.EsMDType(res.Kind) == md.EsMDTypeNamespace || md.EsMDType(res.Kind) == md.EsMDTypeNode) {
^
src/cloud/plugin/controllers/server.go:563:5: S1009: should omit nil check; len() for nil maps is defined as zero (staticcheck)
if req.Configurations != nil && len(req.Configurations) > 0 {
^
src/cloud/profile/controllers/server.go:170:2: QF1003: could use tagged switch on err (staticcheck)
if err == datastore.ErrOrgNotFound {
^
src/cloud/project_manager/datastore/datastore_test.go:27:2: ST1019: package "github.com/golang-migrate/migrate/source/go_bindata" is being imported more than once (staticcheck)
_ "github.com/golang-migrate/migrate/source/go_bindata"
^
src/cloud/project_manager/datastore/datastore_test.go:28:2: ST1019(related information): other import of "github.com/golang-migrate/migrate/source/go_bindata" (staticcheck)
bindata "github.com/golang-migrate/migrate/source/go_bindata"
^
src/cloud/shared/idprovider/client.go:535:6: QF1001: could apply De Morgan's law (staticcheck)
if !(k == "Set-Cookie" || k == "Location") {
^
src/cloud/shared/idprovider/client_test.go:96:44: ST1013: should use constant http.StatusFound instead of numeric literal 302 (staticcheck)
http.Redirect(w, r, consentURL.String(), 302)
^
src/common/testing/test_utils/cert_generator/cert_generator.go:120:2: QF1003: could use tagged switch on keyType (staticcheck)
if keyType == "pkcs1" {
^
src/e2e_test/perf_tool/pkg/metrics/data_loss_handler.go:87:6: QF1009: probably want to use time.Time.Equal instead (staticcheck)
if (ts == time.Time{}) {
^
src/e2e_test/perf_tool/pkg/metrics/prometheus_recorder.go:129:7: QF1001: could apply De Morgan's law (staticcheck)
if !(mf.GetType() == io_prometheus_client.MetricType_COUNTER || mf.GetType() == io_prometheus_client.MetricType_GAUGE) {
^
src/e2e_test/perf_tool/pkg/suites/experiments.go:27:2: ST1019: package "px.dev/pixie/src/e2e_test/perf_tool/experimentpb" is being imported more than once (staticcheck)
"px.dev/pixie/src/e2e_test/perf_tool/experimentpb"
^
src/e2e_test/perf_tool/pkg/suites/experiments.go:28:2: ST1019(related information): other import of "px.dev/pixie/src/e2e_test/perf_tool/experimentpb" (staticcheck)
pb "px.dev/pixie/src/e2e_test/perf_tool/experimentpb"
^
src/e2e_test/vizier/exectime/cmd/benchmark.go:136:29: ST1016: methods on the same type should have the same receiver name (seen 1x "t", 4x "d") (staticcheck)
func (d *ErrorDistribution) Append(v interface{}) {
^
src/e2e_test/vizier/exectime/cmd/benchmark.go:175:29: ST1016: methods on the same type should have the same receiver name (seen 1x "t", 5x "d") (staticcheck)
func (d *BytesDistribution) Append(v interface{}) {
^
src/operator/controllers/monitor.go:49:2: ST1019: package "px.dev/pixie/src/operator/apis/px.dev/v1alpha1" is being imported more than once (staticcheck)
"px.dev/pixie/src/operator/apis/px.dev/v1alpha1"
^
src/operator/controllers/monitor.go:50:2: ST1019(related information): other import of "px.dev/pixie/src/operator/apis/px.dev/v1alpha1" (staticcheck)
pixiev1alpha1 "px.dev/pixie/src/operator/apis/px.dev/v1alpha1"
^
src/operator/controllers/monitor.go:194:24: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
m.podStates.write(pod.ObjectMeta.Labels["name"], pod.ObjectMeta.Name, &podWrapper{pod: pod})
^
src/operator/controllers/monitor.go:204:26: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
m.podStates.delete(pod.ObjectMeta.Labels["name"], pod.ObjectMeta.Name)
^
src/operator/controllers/monitor.go:207:24: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
m.podStates.write(pod.ObjectMeta.Labels["name"], pod.ObjectMeta.Name, &podWrapper{pod: pod})
^
src/operator/controllers/monitor.go:215:25: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
m.podStates.delete(pod.ObjectMeta.Labels["name"], pod.ObjectMeta.Name)
^
src/operator/controllers/monitor.go:418:7: QF1001: could apply De Morgan's law (staticcheck)
if !(ownerRef.Kind == "StatefulSet") {
^
src/operator/controllers/monitor.go:455:13: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
if p.pod.ObjectMeta.Labels["plane"] != "control" {
^
src/operator/controllers/monitor.go:675:2: QF1003: could use tagged switch on state.Reason (staticcheck)
if state.Reason == status.NATSPodFailed {
^
src/pixie_cli/pkg/components/table_renderer.go:167:3: QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)) (staticcheck)
buf.WriteString(fmt.Sprintf("%q:", fmt.Sprintf("%v", mi.Key)))
^
src/pixie_cli/pkg/components/table_renderer.go:331:14: QF1004: could use strings.ReplaceAll instead (staticcheck)
dataStr = strings.Replace(dataStr, "\"", "\"\"", -1)
^
src/shared/artifacts/manifest/manifest.go:51:28: ST1016: methods on the same type should have the same receiver name (seen 2x "m", 5x "a") (staticcheck)
func (a *ArtifactManifest) ArtifactSets() []*versionspb.ArtifactSet {
^
src/shared/k8s/proto_utils_test.go:1017:35: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
assert.Equal(t, "object_md", obj.ObjectMeta.Name)
^
src/shared/k8s/proto_utils_test.go:1319:33: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
assert.Equal(t, "object_md", e.ObjectMeta.Name)
^
src/shared/k8s/proto_utils_test.go:1478:35: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
assert.Equal(t, "object_md", obj.ObjectMeta.Name)
^
src/shared/services/election/election.go:58:56: ST1011: var expectedMaxSkewMS is of type time.Duration; don't use unit-specific suffix "MS" (staticcheck)
func NewK8sLeaderElectionMgr(electionNamespace string, expectedMaxSkewMS, renewDeadlineMS time.Duration, electionName string) (*K8sLeaderElectionMgr, error) {
^
src/stirling/testing/demo_apps/go_http/go_http_client/main.go:73:3: QF1003: could use tagged switch on *reqType (staticcheck)
if *reqType == "get" || *reqType == "mix" {
^
src/utils/artifacts/versions_gen/main.go:50:2: QF1002: could use tagged switch on artifactName (staticcheck)
switch {
^
src/utils/dev_dns_updater/dev_dns_updater.go:128:18: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
svcName := svc.ObjectMeta.Name
^
src/utils/dev_dns_updater/dev_dns_updater.go:142:19: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
SvcName: svc.ObjectMeta.Name,
^
src/utils/dev_dns_updater/dev_dns_updater.go:153:20: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
SvcName: svc.ObjectMeta.Name,
^
src/utils/shared/k8s/delete.go:380:45: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
err = svcs.Delete(context.Background(), s.ObjectMeta.Name, metav1.DeleteOptions{})
^
src/utils/shared/k8s/delete.go:398:45: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
err = pods.Delete(context.Background(), s.ObjectMeta.Name, metav1.DeleteOptions{})
^
src/vizier/services/cloud_connector/bridge/vzinfo.go:419:30: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
return unhealthyPEMPods[i].ObjectMeta.Name < unhealthyPEMPods[j].ObjectMeta.Name
^
src/vizier/services/cloud_connector/bridge/vzinfo.go:594:14: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
if len(j.ObjectMeta.OwnerReferences) > 0 && j.ObjectMeta.OwnerReferences[0].Name == cronJob && j.Status.Succeeded == 1 {
^
src/vizier/services/cloud_connector/bridge/vzinfo.go:595:76: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
err = v.clientset.BatchV1().Jobs(v.ns).Delete(context.Background(), j.ObjectMeta.Name, metav1.DeleteOptions{
^
src/vizier/services/cloud_connector/vzmetrics/scrape.go:115:8: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
if p.ObjectMeta.Annotations[scrapeAnnotationName] != "true" {
^
src/vizier/services/cloud_connector/vzmetrics/scrape.go:118:16: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
podName := p.ObjectMeta.Name
^
src/vizier/services/cloud_connector/vzmetrics/scrape.go:119:17: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
port, ok := p.ObjectMeta.Annotations[portAnnotationName]
^
src/vizier/services/metadata/controllers/k8smeta/k8s_metadata_handler_test.go:504:3: QF1003: could use tagged switch on prevUpdateVersion (staticcheck)
if prevUpdateVersion == 3 {
^
src/vizier/services/metadata/controllers/k8smeta/k8s_metadata_handler_test.go:523:3: QF1003: could use tagged switch on prevUpdateVersion (staticcheck)
if prevUpdateVersion == 3 {
^
src/vizier/services/metadata/controllers/k8smeta/k8s_metadata_store.go:141:3: QF1006: could lift into loop condition (staticcheck)
if tIdx == len(tKeys) && uIdx == len(uKeys) {
^
src/vizier/services/metadata/controllers/server.go:260:8: QF1001: could apply De Morgan's law (staticcheck)
for !(finishedUpdates && finishedSchema) {
^
50 issues:
* staticcheck: 50
```
</details>
---------
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>1 parent d08b5aa commit abe7238
File tree
162 files changed
+606
-592
lines changed- src
- api/go/pxapi
- examples
- basic_example
- encryption_example
- example_mux
- standalone_pem_example
- streaming_example
- carnot
- docstring
- pkg
- tables
- goplanner
- plandebugger
- cloud
- api
- apienv
- controllers
- ptproxy
- artifact_tracker
- controllers
- auth
- apikey
- controllers
- autocomplete
- config_manager/controllers
- cron_script/controllers
- indexer
- md
- metrics/controllers
- plugin/controllers
- profile
- controllers
- datastore
- project_manager
- controllers
- datastore
- scriptmgr/controllers
- vzconn/bridge
- vzmgr
- controllers
- deployment
- common/testing/test_utils/cert_generator
- e2e_test
- perf_tool
- cmd
- datastudio
- pkg
- cluster/local
- deploy/steps
- suites
- profiler_loadtest/go
- protocol_loadtest/grpc
- vizier
- exectime/cmd
- planner
- dump_schemas/godumpschemas
- operator
- controllers
- pixie_cli
- pkg
- auth
- cmd
- components
- live
- pxanalytics
- pxconfig
- sentryhook
- utils
- vizier
- stirling
- demo_apps
- go_http/server
- wrk_sweeper
- source_connectors
- perf_profiler/testing/go
- socket_tracer/protocols/http2/testing/go_grpc_server
- testing/demo_apps/go_http/go_http_client
- utils
- artifacts/manifest_updater
- dev_dns_updater
- script
- template_generator/vizier_yamls
- vizier/services
- cloud_connector
- bridge
- metadata
- controllers
- agent
- cronscript
- k8smeta
- tracepoint
- query_broker
- controllers
- script_runner
- tools
- arc_addons/pixielabs/lint
- chef/cookbooks/px_dev/attributes
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
162 files changed
+606
-592
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | 130 | | |
137 | 131 | | |
138 | 132 | | |
139 | 133 | | |
140 | 134 | | |
141 | 135 | | |
142 | 136 | | |
143 | | - | |
| 137 | + | |
144 | 138 | | |
145 | 139 | | |
146 | 140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | | - | |
4 | | - | |
5 | 4 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | 5 | | |
25 | 6 | | |
26 | 7 | | |
27 | 8 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | 9 | | |
33 | 10 | | |
34 | 11 | | |
| |||
39 | 16 | | |
40 | 17 | | |
41 | 18 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | 19 | | |
46 | | - | |
47 | | - | |
48 | 20 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
| 31 | + | |
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
39 | | - | |
40 | 38 | | |
41 | 39 | | |
42 | 40 | | |
| |||
56 | 54 | | |
57 | 55 | | |
58 | 56 | | |
59 | | - | |
60 | | - | |
| 57 | + | |
61 | 58 | | |
62 | 59 | | |
63 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
| 31 | + | |
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
39 | | - | |
40 | 38 | | |
41 | 39 | | |
42 | 40 | | |
| |||
56 | 54 | | |
57 | 55 | | |
58 | 56 | | |
59 | | - | |
60 | | - | |
| 57 | + | |
61 | 58 | | |
62 | 59 | | |
63 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
| 33 | + | |
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
42 | | - | |
43 | 41 | | |
44 | 42 | | |
45 | 43 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| |||
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
106 | | - | |
107 | | - | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
| 31 | + | |
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
37 | | - | |
38 | 36 | | |
39 | 37 | | |
40 | 38 | | |
| |||
54 | 52 | | |
55 | 53 | | |
56 | 54 | | |
57 | | - | |
58 | | - | |
| 55 | + | |
59 | 56 | | |
60 | 57 | | |
61 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
184 | | - | |
185 | 184 | | |
186 | 185 | | |
187 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
| |||
0 commit comments