Skip to content

Commit 9a3f1e9

Browse files
authored
Bump CI Go version to include 1.24.x + golangci-lint to 1.64.5 (#198)
1 parent c9b2fc9 commit 9a3f1e9

File tree

6 files changed

+37
-14
lines changed

6 files changed

+37
-14
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
- 1.21.x
2323
- 1.22.x
2424
- 1.23.x
25+
- 1.24.x
2526
steps:
2627
- name: Checkout code
2728
uses: actions/checkout@v4
@@ -36,5 +37,5 @@ jobs:
3637
- name: Lint
3738
# Often, lint guidelines depend on the Go version. To prevent
3839
# conflicting guidance, run only on the most recent supported version.
39-
if: matrix.go-version == '1.23.x'
40+
if: matrix.go-version == '1.24.x'
4041
run: make lint-go

.golangci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@ linters:
2626
- cyclop # covered by gocyclo
2727
- depguard # we can manage dependencies strictly if the need arises in the future
2828
- err113 # internal error causes may be dynamic
29-
- execinquery # deprecated by author
3029
- exhaustruct # don't _always_ need to exhaustively create struct
3130
- funlen # rely on code review to limit function length
3231
- gocognit # dubious "cognitive overhead" quantification
3332
- gofumpt # prefer standard gofmt
3433
- goimports # rely on gci instead
35-
- gomnd # some unnamed constants are okay
3634
- gomoddirectives # we use go modules replacements intentionally
3735
- gomodguard # not compatible with go workspaces
3836
- intrange # enable once go 1.22 is baseline
@@ -42,6 +40,7 @@ linters:
4240
- mnd # some unnamed constants are okay
4341
- nlreturn # generous whitespace violates house style
4442
- nonamedreturns # usage of named returns should be selective
43+
- tenv # deprecated: replaced by usetesting
4544
- testpackage # internal tests are fine
4645
- wrapcheck # don't _always_ need to wrap errors
4746
- wsl # over-generous whitespace violates house style

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ LICENSE_IGNORE := -e internal/testdata/
1212
# Set to use a different compiler. For example, `GO=go1.18rc1 make test`.
1313
GO ?= go
1414
ARGS ?= --strict --strict_message --strict_error
15-
GOLANGCI_LINT_VERSION ?= v1.60.1
15+
GOLANGCI_LINT_VERSION ?= v1.64.5
1616
# Set to use a different version of protovalidate-conformance.
1717
# Should be kept in sync with the version referenced in proto/buf.lock and
1818
# 'buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go' in go.mod.

builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ func (bldr *builder) processFieldExpressions(
305305
FieldType: celRuleField.GetFieldType().Enum(),
306306
FieldName: proto.String(celRuleField.GetFieldName()),
307307
Subscript: &validate.FieldPathElement_Index{
308-
Index: uint64(i),
308+
Index: uint64(i), //nolint:gosec // indices are guaranteed to be non-negative
309309
},
310310
},
311311
}

cel/library.go

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ func NewLibrary() cel.Library {
5656
// should avoid exposing additional functions as they will not be portable.
5757
type library struct{}
5858

59-
//nolint:funlen
60-
func (l library) CompileOptions() []cel.EnvOption {
59+
func (l library) CompileOptions() []cel.EnvOption { //nolint:funlen,gocyclo
6160
return []cel.EnvOption{
6261
cel.TypeDescs(protoregistry.GlobalFiles),
6362
cel.DefaultUTCTimeZone(true),
@@ -258,7 +257,11 @@ func (l library) CompileOptions() []cel.EnvOption {
258257
if !ok {
259258
return types.UnsupportedRefValConversionErr(rhs)
260259
}
261-
return types.Bool(strings.Contains(lhs.Value().(string), substr))
260+
value, ok := lhs.Value().(string)
261+
if !ok {
262+
return types.UnsupportedRefValConversionErr(lhs)
263+
}
264+
return types.Bool(strings.Contains(value, substr))
262265
}),
263266
),
264267
cel.MemberOverload("contains_bytes", []*cel.Type{cel.BytesType, cel.BytesType}, cel.BoolType,
@@ -267,7 +270,11 @@ func (l library) CompileOptions() []cel.EnvOption {
267270
if !ok {
268271
return types.UnsupportedRefValConversionErr(rhs)
269272
}
270-
return types.Bool(bytes.Contains(lhs.Value().([]byte), substr))
273+
value, ok := lhs.Value().([]byte)
274+
if !ok {
275+
return types.UnsupportedRefValConversionErr(lhs)
276+
}
277+
return types.Bool(bytes.Contains(value, substr))
271278
}),
272279
),
273280
),
@@ -279,7 +286,11 @@ func (l library) CompileOptions() []cel.EnvOption {
279286
if !ok {
280287
return types.UnsupportedRefValConversionErr(rhs)
281288
}
282-
return types.Bool(strings.HasSuffix(lhs.Value().(string), suffix))
289+
value, ok := lhs.Value().(string)
290+
if !ok {
291+
return types.UnsupportedRefValConversionErr(lhs)
292+
}
293+
return types.Bool(strings.HasSuffix(value, suffix))
283294
}),
284295
),
285296
cel.MemberOverload("ends_with_bytes", []*cel.Type{cel.BytesType, cel.BytesType}, cel.BoolType,
@@ -288,7 +299,11 @@ func (l library) CompileOptions() []cel.EnvOption {
288299
if !ok {
289300
return types.UnsupportedRefValConversionErr(rhs)
290301
}
291-
return types.Bool(bytes.HasSuffix(lhs.Value().([]byte), suffix))
302+
value, ok := lhs.Value().([]byte)
303+
if !ok {
304+
return types.UnsupportedRefValConversionErr(lhs)
305+
}
306+
return types.Bool(bytes.HasSuffix(value, suffix))
292307
}),
293308
),
294309
),
@@ -300,7 +315,11 @@ func (l library) CompileOptions() []cel.EnvOption {
300315
if !ok {
301316
return types.UnsupportedRefValConversionErr(rhs)
302317
}
303-
return types.Bool(strings.HasPrefix(lhs.Value().(string), prefix))
318+
value, ok := lhs.Value().(string)
319+
if !ok {
320+
return types.UnsupportedRefValConversionErr(lhs)
321+
}
322+
return types.Bool(strings.HasPrefix(value, prefix))
304323
}),
305324
),
306325
cel.MemberOverload("starts_with_bytes", []*cel.Type{cel.BytesType, cel.BytesType}, cel.BoolType,
@@ -309,7 +328,11 @@ func (l library) CompileOptions() []cel.EnvOption {
309328
if !ok {
310329
return types.UnsupportedRefValConversionErr(rhs)
311330
}
312-
return types.Bool(bytes.HasPrefix(lhs.Value().([]byte), prefix))
331+
value, ok := lhs.Value().([]byte)
332+
if !ok {
333+
return types.UnsupportedRefValConversionErr(lhs)
334+
}
335+
return types.Bool(bytes.HasPrefix(value, prefix))
313336
}),
314337
),
315338
),

repeated.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (r listItems) Evaluate(msg protoreflect.Message, val protoreflect.Value, cf
5858
FieldNumber: proto.Int32(r.base.FieldPathElement.GetFieldNumber()),
5959
FieldType: r.base.FieldPathElement.GetFieldType().Enum(),
6060
FieldName: proto.String(r.base.FieldPathElement.GetFieldName()),
61-
Subscript: &validate.FieldPathElement_Index{Index: uint64(i)},
61+
Subscript: &validate.FieldPathElement_Index{Index: uint64(i)}, //nolint:gosec // indices are guaranteed to be non-negative
6262
}, r.base.RulePrefix.GetElements())
6363
}
6464
if ok, err = mergeViolations(err, itemErr, cfg); !ok {

0 commit comments

Comments
 (0)