Skip to content

Commit

Permalink
chore(ci): Updates to golangci-lint 1.64
Browse files Browse the repository at this point in the history
- Updates config to use latest recommended linters
- Fixes new linter errors and warnings, most notably moving to the now standard `slices` package instead of the `exp` one
  • Loading branch information
dmihalcik-virtru committed Feb 24, 2025
1 parent 9ca042d commit b893920
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8
with:
version: v1.61
version: v1.64
working-directory: ${{ matrix.directory }}
skip-cache: true
args: --out-format=colored-line-number
Expand Down
6 changes: 2 additions & 4 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ linters-settings:
# Such cases aren't reported by default.
# Default: false
check-type-assertions: true
# https://github.com/golangci/golangci-lint/issues/4743
ignore: ''

exhaustive:
# Program elements to check for exhaustiveness.
Expand Down Expand Up @@ -138,7 +136,7 @@ linters:
- errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
- exhaustive # checks exhaustiveness of enum switch statements
# - exportloopref # checks for pointers to enclosing loop variables Since Go1.22 (loopvar) this linter is no longer relevant. Replaced by copyloopvar."
- exptostd # Added in 1.63. Checks for usages of the deprecated experimental packages
# - fatcontext
- forbidigo # forbids identifiers
- forcetypeassert # finds forced type assertions
Expand Down Expand Up @@ -173,14 +171,14 @@ linters:
# - spancheck # checks for incorrect usage of opentracing.Span # Added in golangci-lint 1.56
- sqlclosecheck # checks that sql.Rows and sql.Stmt are closed
- stylecheck # is a replacement for golint
- tenv # detects using os.Setenv instead of t.Setenv since Go1.17
- testableexamples # checks if examples are testable (have an expected output)
- testifylint
#- testpackage # makes you use a separate _test package
- tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes
- unconvert # removes unnecessary type conversions
- unparam # reports unused function parameters
- usestdlibvars # detects the possibility to use variables/constants from the Go standard library
- usetesting # Replaced tenv in golangci-lint 1.63
- wastedassign # finds wasted assignment statements
- whitespace # detects leading and trailing whitespace

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ toolcheck:
@which buf > /dev/null || (echo "buf not found, please install it from https://docs.buf.build/installation" && exit 1)
@which golangci-lint > /dev/null || (echo "golangci-lint not found, run 'go install github.com/golangci/golangci-lint/cmd/[email protected]'" && exit 1)
@which protoc-gen-doc > /dev/null || (echo "protoc-gen-doc not found, run 'go install github.com/pseudomuto/protoc-gen-doc/cmd/[email protected]'" && exit 1)
@golangci-lint --version | grep "version v\?1.6[123]" > /dev/null || (echo "golangci-lint version must be v1.61 or later [$$(golangci-lint --version)]" && exit 1)
@golangci-lint --version | grep "version v\?1.6[1234]" > /dev/null || (echo "golangci-lint version must be v1.61 or later [$$(golangci-lint --version)]" && exit 1)
@which goimports >/dev/null || (echo "goimports not found, run 'go install golang.org/x/tools/cmd/goimports@latest'")

fix: tidy fmt
Expand Down
6 changes: 3 additions & 3 deletions lib/ocrypto/asym_decryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ func FromPrivatePEM(privateKeyInPem string) (PrivateKeyDecryptor, error) {

switch privateKey := priv.(type) {
case *ecdsa.PrivateKey:
if sk, err := privateKey.ECDH(); err != nil {
sk, err := privateKey.ECDH()
if err != nil {
return nil, fmt.Errorf("unable to create ECDH key: %w", err)
} else {
return NewECDecryptor(sk)
}
return NewECDecryptor(sk)
case *ecdh.PrivateKey:
return NewECDecryptor(privateKey)
case *rsa.PrivateKey:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,8 @@ func EntityResolution(ctx context.Context,
if exErr != nil {
return entityresolution.ResolveEntitiesResponse{},
connect.NewError(connect.CodeNotFound, ErrNotFound)
} else {
keycloakEntities = expandedRepresentations
}
keycloakEntities = expandedRepresentations
default:
logger.Error("no group found for", slog.String("entity", ident.String()))
var entityNotFoundErr entityresolution.EntityNotFoundError
Expand Down
2 changes: 1 addition & 1 deletion service/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ require (
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.31.0
go.opentelemetry.io/otel/sdk v1.31.0
go.opentelemetry.io/otel/trace v1.31.0
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225
google.golang.org/grpc v1.67.1
google.golang.org/protobuf v1.35.1
gopkg.in/natefinch/lumberjack.v2 v2.2.1
Expand Down Expand Up @@ -78,6 +77,7 @@ require (
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.31.0 // indirect
go.opentelemetry.io/otel/metric v1.31.0 // indirect
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
)

Expand Down
2 changes: 1 addition & 1 deletion service/pkg/server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net/url"
"os"
"os/signal"
"slices"
"syscall"

"github.com/opentdf/platform/lib/ocrypto"
Expand All @@ -23,7 +24,6 @@ import (
"github.com/opentdf/platform/service/pkg/serviceregistry"
"github.com/opentdf/platform/service/tracing"
wellknown "github.com/opentdf/platform/service/wellknownconfiguration"
"golang.org/x/exp/slices"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
Expand Down

0 comments on commit b893920

Please sign in to comment.