Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(linter): using binary staticcheck #4542

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ linters:
- prealloc
- predeclared
- promlinter
- staticcheck
- thelper
- typecheck
- unconvert
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ format:

.PHONY: lint
lint: linter
$(GOBIN)/staticcheck ./...
$(GOLANGCI_LINT) run ./...

.PHONY: linter
Expand Down
3 changes: 1 addition & 2 deletions pkg/api/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,8 @@
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

Check failure on line 112 in pkg/api/metrics.go

View workflow job for this annotation

GitHub Actions / Lint

SA1019: http.CloseNotifier has been deprecated since Go 1.11 and an alternative has been available since Go 1.7: the CloseNotifier interface predates Go's context package. New code should use Request.Context instead. (staticcheck)
}

type responseWriter struct {
Expand Down
1 change: 1 addition & 0 deletions pkg/crypto/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions pkg/keystore/file/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I believe that the most correct is to set the ethereum address to the empty string if the curve is not btcec.S256(), as that makes sense only for that curve. The switch was added on #3797 and elliptic.Marshal does not provide a valid ethereum address.

addr = elliptic.Marshal(elliptic.P256(), k.PublicKey.X, k.PublicKey.Y)
notanatol marked this conversation as resolved.
Show resolved Hide resolved
default:
return nil, fmt.Errorf("unsupported curve: %v", k.PublicKey.Curve)
Expand Down
3 changes: 1 addition & 2 deletions pkg/log/httpaccess/http_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@

// 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()

Check failure on line 117 in pkg/log/httpaccess/http_access.go

View workflow job for this annotation

GitHub Actions / Lint

SA1019: http.CloseNotifier has been deprecated since Go 1.11 and an alternative has been available since Go 1.7: the CloseNotifier interface predates Go's context package. New code should use Request.Context instead. (staticcheck)
}

// Hijack implements http.Hijacker.
Expand Down
2 changes: 1 addition & 1 deletion pkg/manifest/mantaray/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/manifest/mantaray/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/p2p/libp2p/libp2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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{
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/leveldbstore/recovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)} }
Expand Down
Loading