diff --git a/.golangci.yaml b/.golangci.yaml index 675f873..63cf78c 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -48,7 +48,7 @@ linters: - errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`. - errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13. - exhaustive # check exhaustiveness of enum switch statements - - exportloopref # checks for pointers to enclosing loop variables + - copyloopvar - forcetypeassert # finds forced type assertions - gci # Gci control golang package import order and make it always deterministic. - gochecknoglobals # Checks that no globals are present in Go code @@ -98,7 +98,6 @@ linters: - gocyclo # Computes and checks the cyclomatic complexity of functions - godot # Check if comments end in a period - godox # Tool for detection of FIXME, TODO and other comment keywords - - gomnd # An analyzer to detect magic numbers. - ireturn # Accept Interfaces, Return Concrete Types - lll # Reports long lines - maintidx # maintidx measures the maintainability index of each function. diff --git a/cmd/cmd.go b/cmd/cmd.go index 8028ec7..832dc99 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2023-2024 Steffen Vogel // SPDX-License-Identifier: Apache-2.0 +//go:build darwin + package main import ( diff --git a/ecdh/public_key.go b/ecdh/public_key.go index fc20ff3..70d9ec9 100644 --- a/ecdh/public_key.go +++ b/ecdh/public_key.go @@ -19,6 +19,7 @@ var _ dh.PublicKey = (*PublicKey)(nil) var ( ErrUnsupportedCurve = errors.New("unsupported curve") ErrUnmarshal = errors.New("failed to unmarshal key") + ErrParse = errors.New("failed to parse") ) type PublicKey struct { @@ -39,19 +40,19 @@ func (pk *PublicKey) UnmarshalText(text []byte) error { var curveName, keyStr string if n, err := fmt.Sscanf(string(text), "ecdh:%s:pk:%s", &curveName, &keyStr); err != nil { - return fmt.Errorf("failed to parse: %w", err) + return fmt.Errorf("%w: %w", ErrParse, err) } else if n != 1 { - return fmt.Errorf("failed to parse") + return ErrParse } curve := curveFromName(curveName) if curve == nil { - return fmt.Errorf("unsupported curve: %s", curveName) + return fmt.Errorf("%w: %s", ErrUnsupportedCurve, curveName) } key, err := base64.StdEncoding.DecodeString(keyStr) if err != nil { - return fmt.Errorf("failed to parse: %w", err) + return fmt.Errorf("%w: %w", ErrParse, err) } pk.PublicKey, err = curve.NewPublicKey(key) @@ -81,6 +82,7 @@ func (pk *PublicKey) ECDSA() (*ecdsa.PublicKey, error) { return nil, fmt.Errorf("%w: %v", ErrUnsupportedCurve, pk.Curve()) } + //nolint:staticcheck x, y := elliptic.Unmarshal(curve, pk.Bytes()) if x == nil { return nil, ErrUnmarshal diff --git a/handshake/handshake_chained.go b/handshake/handshake_chained.go index eece638..beb39b8 100644 --- a/handshake/handshake_chained.go +++ b/handshake/handshake_chained.go @@ -27,9 +27,6 @@ func (cp ChainedHandshake) Secret(ctx context.Context) (s Secret, err error) { res := make([]Secret, len(cp)) for i, p := range cp { - i := i - p := p - group.Go(func() (err error) { res[i], err = p.Secret(ctx) return err diff --git a/handshake/key.go b/handshake/key.go index 828f632..307b5a3 100644 --- a/handshake/key.go +++ b/handshake/key.go @@ -33,6 +33,8 @@ func (k *Key) UnmarshalText(t []byte) (err error) { parts := strings.Split(s, "_") var protoParts int + + //nolint:goconst switch parts[0] { case "Noise", "WireGuard": protoParts = 5 diff --git a/internal/openpgp/objects.go b/internal/openpgp/objects.go index 6247a46..c3cb1a4 100644 --- a/internal/openpgp/objects.go +++ b/internal/openpgp/objects.go @@ -141,6 +141,7 @@ type ApplicationRelated struct { Keys [4]KeyInfo } +//nolint:gocognit func (ar *ApplicationRelated) Decode(b []byte) (err error) { var v, w, x []byte var t iso.Tag diff --git a/provider/applese.go b/provider/applese.go index a5d734d..dc7fc01 100644 --- a/provider/applese.go +++ b/provider/applese.go @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2023-2024 Steffen Vogel // SPDX-License-Identifier: Apache-2.0 +//go:build darwin + package provider import ( diff --git a/provider/applese_test.go b/provider/applese_test.go index 00c2877..8c7fdd2 100644 --- a/provider/applese_test.go +++ b/provider/applese_test.go @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2023 Steffen Vogel // SPDX-License-Identifier: Apache-2.0 +//go:build darwin + package provider import ( diff --git a/provider/openpgp.go b/provider/openpgp.go index db3cdc0..48feba6 100644 --- a/provider/openpgp.go +++ b/provider/openpgp.go @@ -28,6 +28,7 @@ func (s *openpgpSlotRef) UnmarshalText(text []byte) error { return ErrParse } + //nolint:goconst switch curve { case "Secp256r1": default: