Skip to content

Commit 3b04117

Browse files
chore(ci): Updates to latest golangci-lint (#901)
1 parent 7baf039 commit 3b04117

8 files changed

Lines changed: 30 additions & 20 deletions

File tree

.github/workflows/checks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
- name: golangci-lint
9595
uses: golangci/golangci-lint-action@9d1e0624a798bb64f6c3cea93db47765312263dc
9696
with:
97-
version: v1.57
97+
version: v1.58
9898
working-directory: ${{ matrix.directory }}
9999
skip-cache: true
100100
args: --out-format=colored-line-number

.golangci.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ linters-settings:
99
# Such cases aren't reported by default.
1010
# Default: false
1111
check-type-assertions: true
12+
# https://github.com/golangci/golangci-lint/issues/4743
13+
ignore: ''
1214

1315
exhaustive:
1416
# Program elements to check for exhaustiveness.
@@ -31,7 +33,7 @@ linters-settings:
3133
# Default: true
3234
skipRecvDeref: false
3335

34-
gomnd:
36+
mnd:
3537
# List of function patterns to exclude from analysis.
3638
# Values always ignored: `time.Date`,
3739
# `strconv.FormatInt`, `strconv.FormatUint`, `strconv.FormatFloat`,
@@ -131,7 +133,6 @@ linters:
131133
- durationcheck # checks for two durations multiplied together
132134
- errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
133135
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
134-
- execinquery # checks query string in Query function which reads your Go src files and warning it finds
135136
- exhaustive # checks exhaustiveness of enum switch statements
136137
- exportloopref # checks for pointers to enclosing loop variables
137138
- forbidigo # forbids identifiers
@@ -141,12 +142,12 @@ linters:
141142
- gocritic # provides diagnostics that check for bugs, performance and style issues
142143
- gofmt # checks whether code was gofmt-ed
143144
- goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt
144-
- gomnd # detects magic numbers
145145
- gomodguard # allow and block lists linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations
146146
- goprintffuncname # checks that printf-like functions are named with f at the end
147147
- gosec # inspects source code for security problems
148148
- loggercheck # checks key value pairs for common logger libraries (kitlog,klog,logr,zap)
149149
- makezero # finds slice declarations with non-zero initial length
150+
- mnd # detects magic numbers
150151
- musttag # enforces field tags in (un)marshaled structs
151152
- nakedret # finds naked returns in functions greater than a specified function length
152153
- nestif # reports deeply nested if statements

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ all: toolcheck clean build lint license test
1717
toolcheck:
1818
@echo "Checking for required tools..."
1919
@which buf > /dev/null || (echo "buf not found, please install it from https://docs.buf.build/installation" && exit 1)
20-
@which golangci-lint > /dev/null || (echo "golangci-lint not found, run 'go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2'" && exit 1)
20+
@which golangci-lint > /dev/null || (echo "golangci-lint not found, run 'go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.58.1'" && exit 1)
2121
@which protoc-gen-doc > /dev/null || (echo "protoc-gen-doc not found, run 'go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@v1.5.1'" && exit 1)
2222
@golangci-lint --version | grep "version v\?1.5[678]" > /dev/null || (echo "golangci-lint version must be v1.56 or later [$$(golangci-lint --version)]" && exit 1)
2323
@which goimports >/dev/null || (echo "goimports not found, run 'go install golang.org/x/tools/cmd/goimports@latest'")

lib/fixtures/keycloak.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,17 @@ func createRealm(ctx context.Context, kcConnectParams KeycloakConnectParams, rea
466466

467467
// Create realm
468468
r, err := client.GetRealm(ctx, token.AccessToken, *realm.Realm)
469-
if err != nil {
470-
kcErr := err.(*gocloak.APIError) //nolint:errcheck,errorlint,forcetypeassert // kc error checked below
469+
var kcErr *gocloak.APIError
470+
if errors.As(err, &kcErr) {
471+
switch kcErr.Code {
472+
case http.StatusNotFound:
473+
// yes
474+
case http.StatusConflict:
475+
slog.Info(fmt.Sprintf("⏭️ %s realm already exists, skipping create", *realm.Realm))
476+
default:
477+
return err
478+
}
479+
} else if err != nil {
471480
if kcErr.Code == http.StatusConflict {
472481
slog.Info(fmt.Sprintf("⏭️ %s realm already exists, skipping create", *realm.Realm))
473482
} else if kcErr.Code != http.StatusNotFound {

sdk/internal/archive/writer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//nolint:gomnd // pkzip magics and lengths are inlined for clarity
1+
//nolint:mnd // pkzip magics and lengths are inlined for clarity
22
package archive
33

44
import (

sdk/nanotdf.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ import (
2626

2727
// / Constants
2828
const (
29-
kMaxTDFSize = ((16 * 1024 * 1024) - 3 - 32) //nolint:gomnd // 16 mb - 3(iv) - 32(max auth tag)
29+
kMaxTDFSize = ((16 * 1024 * 1024) - 3 - 32) //nolint:mnd // 16 mb - 3(iv) - 32(max auth tag)
3030
// kDatasetMaxMBBytes = 2097152 // 2mb
3131

3232
// Max size of the encrypted tdfs
3333
// 16mb payload
3434
// ~67kb of policy
3535
// 133 of signature
36-
// kMaxEncryptedNTDFSize = (16 * 1024 * 1024) + (68 * 1024) + 133 //nolint:gomnd // See comment block above
36+
// kMaxEncryptedNTDFSize = (16 * 1024 * 1024) + (68 * 1024) + 133 //nolint:mnd // See comment block above
3737

3838
kIvPadding = 9
3939
kNanoTDFIvSize = 3
@@ -217,11 +217,11 @@ const (
217217
func deserializeBindingCfg(b byte) bindingConfig {
218218
cfg := bindingConfig{}
219219
// Shift to low nybble test low bit
220-
cfg.useEcdsaBinding = (b >> 7 & 0b00000001) == 1 //nolint:gomnd // better readability as literal
220+
cfg.useEcdsaBinding = (b >> 7 & 0b00000001) == 1 //nolint:mnd // better readability as literal
221221
// ignore padding
222222
cfg.padding = 0
223223
// shift to low nybble and use low 3 bits
224-
cfg.eccMode = ocrypto.ECCMode((b >> 4) & 0b00000111) //nolint:gomnd // better readability as literal
224+
cfg.eccMode = ocrypto.ECCMode((b >> 4) & 0b00000111) //nolint:mnd // better readability as literal
225225

226226
return cfg
227227
}
@@ -235,7 +235,7 @@ func serializeBindingCfg(bindCfg bindingConfig) byte {
235235
bindSerial |= 0b10000000
236236
}
237237
// Mask value to low 3 bytes and shift to high nybble
238-
bindSerial |= (byte(bindCfg.eccMode) & 0b00000111) << 4 //nolint:gomnd // better readability as literal
238+
bindSerial |= (byte(bindCfg.eccMode) & 0b00000111) << 4 //nolint:mnd // better readability as literal
239239

240240
return bindSerial
241241
}
@@ -254,11 +254,11 @@ func serializeBindingCfg(bindCfg bindingConfig) byte {
254254
func deserializeSignatureCfg(b byte) signatureConfig {
255255
cfg := signatureConfig{}
256256
// Shift high bit down and mask to test for value
257-
cfg.hasSignature = (b >> 7 & 0b000000001) == 1 //nolint:gomnd // better readability as literal
257+
cfg.hasSignature = (b >> 7 & 0b000000001) == 1 //nolint:mnd // better readability as literal
258258
// Shift high nybble down and mask for eccmode value
259-
cfg.signatureMode = ocrypto.ECCMode((b >> 4) & 0b00000111) //nolint:gomnd // better readability as literal
259+
cfg.signatureMode = ocrypto.ECCMode((b >> 4) & 0b00000111) //nolint:mnd // better readability as literal
260260
// Mask low nybble for cipher value
261-
cfg.cipher = CipherMode(b & 0b00001111) //nolint:gomnd // better readability as literal
261+
cfg.cipher = CipherMode(b & 0b00001111) //nolint:mnd // better readability as literal
262262

263263
return cfg
264264
}
@@ -272,9 +272,9 @@ func serializeSignatureCfg(sigCfg signatureConfig) byte {
272272
sigSerial |= 0b10000000
273273
}
274274
// Mask low 3 bits of mode and shift to high nybble
275-
sigSerial |= byte((sigCfg.signatureMode)&0b00000111) << 4 //nolint:gomnd // better readability as literal
275+
sigSerial |= byte((sigCfg.signatureMode)&0b00000111) << 4 //nolint:mnd // better readability as literal
276276
// Mask low nybble of cipher
277-
sigSerial |= byte((sigCfg.cipher) & 0b00001111) //nolint:gomnd // better readability as literal
277+
sigSerial |= byte((sigCfg.cipher) & 0b00001111) //nolint:mnd // better readability as literal
278278

279279
return sigSerial
280280
}

sdk/sdk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func buildIDPTokenSource(c *config) (auth.AccessTokenSource, error) {
152152
// any just return a KAS client that can only get public keys
153153
if c.clientCredentials == nil {
154154
slog.Info("no client credentials provided. GRPC requests to KAS and services will not be authenticated.")
155-
return nil, nil // not having credentials is not an error
155+
return nil, nil //nolint:nilnil // not having credentials is not an error
156156
}
157157

158158
if c.certExchange != nil && c.tokenExchange != nil {

service/internal/opa/opa.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func (l *AdapterSlogger) GetLevel() opalog.Level {
104104

105105
// getFields returns additional fields of this logger.
106106
func (l *AdapterSlogger) getFieldsKV() []interface{} {
107-
kv := make([]interface{}, len(l.fields)*2) //nolint:gomnd // key and value is added so double the length
107+
kv := make([]interface{}, len(l.fields)*2) //nolint:mnd // key and value is added so double the length
108108
i := 0
109109
for k, v := range l.fields {
110110
kv[i] = k

0 commit comments

Comments
 (0)