From 8061cae4c242b697bcaa41e71f37eb343580381c Mon Sep 17 00:00:00 2001 From: notanatol Date: Fri, 12 Jan 2024 18:45:02 +0200 Subject: [PATCH 1/3] fix: using binary staticcheck --- Makefile | 1 + pkg/api/metrics.go | 3 +-- pkg/crypto/crypto.go | 1 + pkg/keystore/file/key.go | 1 + pkg/log/httpaccess/http_access.go | 3 +-- pkg/manifest/mantaray/marshal.go | 2 +- pkg/manifest/mantaray/node.go | 6 +++--- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index f245354331c..e09c37d5e16 100644 --- a/Makefile +++ b/Makefile @@ -86,6 +86,7 @@ format: .PHONY: lint lint: linter + $(GOBIN)/staticcheck ./... $(GOLANGCI_LINT) run ./... .PHONY: linter diff --git a/pkg/api/metrics.go b/pkg/api/metrics.go index 9146d1079a4..3ec9ec7cf34 100644 --- a/pkg/api/metrics.go +++ b/pkg/api/metrics.go @@ -108,8 +108,7 @@ type UpgradedResponseWriter interface { http.Pusher http.Hijacker http.Flusher - // staticcheck SA1019 CloseNotifier interface is required by gorilla compress handler - // nolint:staticcheck + //lint:ignore SA1019 CloseNotifier interface is required by gorilla compress handler http.CloseNotifier } diff --git a/pkg/crypto/crypto.go b/pkg/crypto/crypto.go index a2e0ba2e468..ff913f521e7 100644 --- a/pkg/crypto/crypto.go +++ b/pkg/crypto/crypto.go @@ -116,6 +116,7 @@ func NewEthereumAddress(p ecdsa.PublicKey) ([]byte, error) { if p.X == nil || p.Y == nil { return nil, errors.New("invalid public key") } + //lint:ignore SA1019 to be addressed soon pubBytes := elliptic.Marshal(btcec.S256(), p.X, p.Y) pubHash, err := LegacyKeccak256(pubBytes[1:]) if err != nil { diff --git a/pkg/keystore/file/key.go b/pkg/keystore/file/key.go index fbec230f942..20c071f87a7 100644 --- a/pkg/keystore/file/key.go +++ b/pkg/keystore/file/key.go @@ -83,6 +83,7 @@ func encryptKey(k *ecdsa.PrivateKey, password string, edg keystore.EDG) ([]byte, } addr = a case elliptic.P256(): + //lint:ignore SA1019 to be addressed soon addr = elliptic.Marshal(elliptic.P256(), k.PublicKey.X, k.PublicKey.Y) default: return nil, fmt.Errorf("unsupported curve: %v", k.PublicKey.Curve) diff --git a/pkg/log/httpaccess/http_access.go b/pkg/log/httpaccess/http_access.go index 4b240534716..98803416bd7 100644 --- a/pkg/log/httpaccess/http_access.go +++ b/pkg/log/httpaccess/http_access.go @@ -113,8 +113,7 @@ func (rr *responseRecorder) WriteHeader(s int) { // CloseNotify implements http.CloseNotifier. func (rr *responseRecorder) CloseNotify() <-chan bool { - // staticcheck SA1019 CloseNotifier interface is required by gorilla compress handler. - // nolint:staticcheck + //lint:ignore SA1019 CloseNotifier interface is required by gorilla compress handler. return rr.ResponseWriter.(http.CloseNotifier).CloseNotify() } diff --git a/pkg/manifest/mantaray/marshal.go b/pkg/manifest/mantaray/marshal.go index 2ea9b3e95f8..7e94d265297 100644 --- a/pkg/manifest/mantaray/marshal.go +++ b/pkg/manifest/mantaray/marshal.go @@ -192,7 +192,7 @@ func (bb *bitsForBytes) set(b byte) { bb.bits[b/8] |= 1 << (b % 8) } -//nolint:unused +//lint:ignore U1000 we keep this around for now func (bb *bitsForBytes) get(b byte) bool { return bb.getUint8(b) } diff --git a/pkg/manifest/mantaray/node.go b/pkg/manifest/mantaray/node.go index 5a59c010d52..c18f5323f35 100644 --- a/pkg/manifest/mantaray/node.go +++ b/pkg/manifest/mantaray/node.go @@ -110,12 +110,12 @@ func (n *Node) makeWithMetadata() { n.nodeType = n.nodeType | nodeTypeWithMetadata } -//nolint:unused +//lint:ignore U1000 we keep this around for now func (n *Node) makeNotValue() { n.nodeType = (nodeTypeMask ^ nodeTypeValue) & n.nodeType } -//nolint:unused +//lint:ignore U1000 we keep this around for now func (n *Node) makeNotEdge() { n.nodeType = (nodeTypeMask ^ nodeTypeEdge) & n.nodeType } @@ -124,7 +124,7 @@ func (n *Node) makeNotWithPathSeparator() { n.nodeType = (nodeTypeMask ^ nodeTypeWithPathSeparator) & n.nodeType } -//nolint:unused +//lint:ignore U1000 we keep this around for now func (n *Node) makeNotWithMetadata() { n.nodeType = (nodeTypeMask ^ nodeTypeWithMetadata) & n.nodeType } From da5a1ba93256f43ed6782e89fde11085521bebfc Mon Sep 17 00:00:00 2001 From: notanatol Date: Fri, 12 Jan 2024 18:56:53 +0200 Subject: [PATCH 2/3] fix: order --- pkg/api/metrics.go | 3 ++- pkg/log/httpaccess/http_access.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/api/metrics.go b/pkg/api/metrics.go index 3ec9ec7cf34..05cd074010b 100644 --- a/pkg/api/metrics.go +++ b/pkg/api/metrics.go @@ -108,7 +108,8 @@ type UpgradedResponseWriter interface { http.Pusher http.Hijacker http.Flusher - //lint:ignore SA1019 CloseNotifier interface is required by gorilla compress handler + // lint:ignore SA1019 CloseNotifier interface is required by gorilla compress handler + // nolint:staticcheck http.CloseNotifier } diff --git a/pkg/log/httpaccess/http_access.go b/pkg/log/httpaccess/http_access.go index 98803416bd7..24b936c7dae 100644 --- a/pkg/log/httpaccess/http_access.go +++ b/pkg/log/httpaccess/http_access.go @@ -113,7 +113,8 @@ func (rr *responseRecorder) WriteHeader(s int) { // CloseNotify implements http.CloseNotifier. func (rr *responseRecorder) CloseNotify() <-chan bool { - //lint:ignore SA1019 CloseNotifier interface is required by gorilla compress handler. + // nolint:staticcheck + // lint:ignore SA1019 CloseNotifier interface is required by gorilla compress handler return rr.ResponseWriter.(http.CloseNotifier).CloseNotify() } From 1dac78d9abbd1153e8a43d81b6043cfa0630bdf5 Mon Sep 17 00:00:00 2001 From: notanatol Date: Mon, 15 Jan 2024 13:37:16 +0200 Subject: [PATCH 3/3] chore: remove staticcheck from golangci-lint --- .golangci.yml | 1 - pkg/api/metrics.go | 3 +-- pkg/log/httpaccess/http_access.go | 3 +-- pkg/p2p/libp2p/libp2p.go | 5 ++--- pkg/storage/leveldbstore/recovery_test.go | 2 +- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index def3e2a3d8d..30ed8f9bbae 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -28,7 +28,6 @@ linters: - prealloc - predeclared - promlinter - - staticcheck - thelper - typecheck - unconvert diff --git a/pkg/api/metrics.go b/pkg/api/metrics.go index 05cd074010b..3ec9ec7cf34 100644 --- a/pkg/api/metrics.go +++ b/pkg/api/metrics.go @@ -108,8 +108,7 @@ type UpgradedResponseWriter interface { http.Pusher http.Hijacker http.Flusher - // lint:ignore SA1019 CloseNotifier interface is required by gorilla compress handler - // nolint:staticcheck + //lint:ignore SA1019 CloseNotifier interface is required by gorilla compress handler http.CloseNotifier } diff --git a/pkg/log/httpaccess/http_access.go b/pkg/log/httpaccess/http_access.go index 24b936c7dae..9c8ee95fef8 100644 --- a/pkg/log/httpaccess/http_access.go +++ b/pkg/log/httpaccess/http_access.go @@ -113,8 +113,7 @@ func (rr *responseRecorder) WriteHeader(s int) { // CloseNotify implements http.CloseNotifier. func (rr *responseRecorder) CloseNotify() <-chan bool { - // nolint:staticcheck - // lint:ignore SA1019 CloseNotifier interface is required by gorilla compress handler + //lint:ignore SA1019 CloseNotifier interface is required by gorilla compress handler return rr.ResponseWriter.(http.CloseNotifier).CloseNotify() } diff --git a/pkg/p2p/libp2p/libp2p.go b/pkg/p2p/libp2p/libp2p.go index d7250a517fb..645703e93a8 100644 --- a/pkg/p2p/libp2p/libp2p.go +++ b/pkg/p2p/libp2p/libp2p.go @@ -55,7 +55,6 @@ import ( ocprom "contrib.go.opencensus.io/exporter/prometheus" m2 "github.com/ethersphere/bee/pkg/metrics" - rcmgrObs "github.com/libp2p/go-libp2p/p2p/host/resource-manager" "github.com/prometheus/client_golang/prometheus" ) @@ -175,7 +174,7 @@ func New(ctx context.Context, signer beecrypto.Signer, networkID uint64, overlay } if o.Registry != nil { - rcmgrObs.MustRegisterWith(o.Registry) + rcmgr.MustRegisterWith(o.Registry) } _, err = ocprom.NewExporter(ocprom.Options{ @@ -201,7 +200,7 @@ func New(ctx context.Context, signer beecrypto.Signer, networkID uint64, overlay // The resource manager expects a limiter, se we create one from our limits. limiter := rcmgr.NewFixedLimiter(limits) - str, err := rcmgrObs.NewStatsTraceReporter() + str, err := rcmgr.NewStatsTraceReporter() if err != nil { return nil, err } diff --git a/pkg/storage/leveldbstore/recovery_test.go b/pkg/storage/leveldbstore/recovery_test.go index f3d504f6e62..8ffa8b183de 100644 --- a/pkg/storage/leveldbstore/recovery_test.go +++ b/pkg/storage/leveldbstore/recovery_test.go @@ -23,7 +23,7 @@ type obj struct { } func (o *obj) ID() string { return o.Key } -func (_ *obj) Namespace() string { return "obj" } +func (*obj) Namespace() string { return "obj" } func (o *obj) Marshal() ([]byte, error) { return json.Marshal(o) } func (o *obj) Unmarshal(buf []byte) error { return json.Unmarshal(buf, o) } func (o *obj) Clone() storage.Item { return &obj{Key: o.Key, Val: slices.Clone(o.Val)} }