Skip to content

Commit 6de37de

Browse files
authored
Merge pull request #1139 from duglin/upgradeLint
upgrade-lint
2 parents 240eb02 + 25cdf94 commit 6de37de

File tree

8 files changed

+20
-15
lines changed

8 files changed

+20
-15
lines changed

.github/workflows/go-lint.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ jobs:
3333

3434
- name: Go Lint on ./v2
3535
if: steps.golangci_configuration.outputs.files_exists == 'true'
36-
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2
36+
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
3737
with:
38-
version: v1.61
38+
version: v2.0
3939
working-directory: v2
40-

.golangci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
version: "2"
12
run:
23
timeout: 5m
34

v2/binding/buffering/copy_message.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ func CopyMessage(ctx context.Context, m binding.Message, transformers ...binding
4444
bm := binaryBufferedMessage{}
4545

4646
encoding, err := binding.DirectWrite(ctx, m, &sm, &bm, transformers...)
47-
if encoding == binding.EncodingStructured {
47+
switch encoding {
48+
case binding.EncodingStructured:
4849
return &sm, err
49-
} else if encoding == binding.EncodingBinary {
50+
case binding.EncodingBinary:
5051
return &bm, err
51-
} else {
52+
default:
5253
e, err := binding.ToEvent(ctx, m, transformers...)
5354
if err != nil {
5455
return nil, err

v2/binding/test/transformer.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,17 @@ func RunTransformerTests(t *testing.T, ctx context.Context, tests []TransformerT
4545
require.NoError(t, err)
4646

4747
var e *event.Event
48-
if enc == binding.EncodingStructured {
48+
switch enc {
49+
case binding.EncodingStructured:
4950
e, err = binding.ToEvent(ctx, &mockStructured)
5051
require.NoError(t, err)
51-
} else if enc == binding.EncodingBinary {
52+
case binding.EncodingBinary:
5253
e, err = binding.ToEvent(ctx, &mockBinary)
5354
require.NoError(t, err)
54-
} else {
55+
default:
5556
t.Fatalf("Unexpected encoding %v", enc)
5657
}
58+
5759
require.NoError(t, err)
5860
if tt.AssertFunc != nil {
5961
tt.AssertFunc(t, *e)

v2/event/extensions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func validateExtensionName(key string) error {
4949
}
5050

5151
for _, c := range key {
52-
if !((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')) {
52+
if (c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && (c < '0' || c > '9') {
5353
return errors.New("bad key, CloudEvents attribute names MUST consist of lower-case letters ('a' to 'z'), upper-case letters ('A' to 'Z') or digits ('0' to '9') from the ASCII character set")
5454
}
5555
}

v2/protocol/http/message_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ func TestNewMessageFromHttpRequest(t *testing.T) {
3939
test.EachEvent(t, test.Events(), func(t *testing.T, eventIn event.Event) {
4040
t.Run(tt.name, func(t *testing.T) {
4141
ctx := context.TODO()
42-
if tt.encoding == binding.EncodingStructured {
42+
switch tt.encoding {
43+
case binding.EncodingStructured:
4344
ctx = binding.WithForceStructured(ctx)
44-
} else if tt.encoding == binding.EncodingBinary {
45+
case binding.EncodingBinary:
4546
ctx = binding.WithForceBinary(ctx)
4647
}
4748

v2/protocol/http/protocol.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ func (p *Protocol) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
326326

327327
if !ok {
328328
rw.Header().Add("Retry-After", strconv.Itoa(int(reset)))
329-
http.Error(rw, "limit exceeded", 429)
329+
http.Error(rw, "limit exceeded", http.StatusTooManyRequests)
330330
return
331331
}
332332

v2/protocol/http/utility_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ func TestNewEventFromHttpRequest(t *testing.T) {
3838
test.EachEvent(t, test.Events(), func(t *testing.T, eventIn event.Event) {
3939
t.Run(tt.name, func(t *testing.T) {
4040
ctx := context.TODO()
41-
if tt.encoding == binding.EncodingStructured {
41+
switch tt.encoding {
42+
case binding.EncodingStructured:
4243
ctx = binding.WithForceStructured(ctx)
43-
} else if tt.encoding == binding.EncodingBinary {
44+
case binding.EncodingBinary:
4445
ctx = binding.WithForceBinary(ctx)
4546
}
4647

0 commit comments

Comments
 (0)