Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
Signed-off-by: Edward McFarlane <[email protected]>
  • Loading branch information
emcfarlane committed Jun 12, 2024
1 parent 3e8cdb4 commit 9bb955e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
8 changes: 7 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ linters:
- lll # don't want hard limits for line length
- maintidx # covered by gocyclo
- maligned # readability trumps efficient struct packing
- mnd # status codes are clearer than constants
- nlreturn # generous whitespace violates house style
- nonamedreturns # named returns are fine; it's *bare* returns that are bad
- nosnakecase # deprecated in https://github.com/golangci/golangci-lint/pull/3065
Expand All @@ -64,7 +65,7 @@ issues:
exclude:
# Don't ban use of fmt.Errorf to create new errors, but the remaining
# checks from err113 are useful.
- "err113: do not define dynamic errors.*"
- "do not define dynamic errors, use wrapped static errors instead: .*"

exclude-rules:
# If future reflect.Kinds are nil-able, we'll find out when a test fails.
Expand Down Expand Up @@ -129,3 +130,8 @@ issues:
# Allow fmt.Sprintf for cmd/protoc-gen-connect-go for consistency
- linters: [perfsprint]
path: cmd/protoc-gen-connect-go/main.go
# Allow non-canonical headers in tests
- linters: [canonicalheader]
path: protocol_grpc_test.go
- linters: [canonicalheader]
path: connect_ext_test.go
4 changes: 2 additions & 2 deletions client_stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ func verifyHeaders(t *testing.T, headers http.Header) {
assert.Equal(t, headers, http.Header{})

// Verify set/del don't panic
headers.Set("a", "b")
headers.Del("a")
headers.Set("A", "b")
headers.Del("A")
}

type nopStreamingClientConn struct {
Expand Down
8 changes: 4 additions & 4 deletions error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func TestErrorNilUnderlying(t *testing.T) {
err.AddDetail(detail)
assert.Equal(t, len(err.Details()), 1)
assert.Equal(t, err.Details()[0].Type(), "google.protobuf.Empty")
err.Meta().Set("foo", "bar")
assert.Equal(t, err.Meta().Get("foo"), "bar")
err.Meta().Set("Foo", "bar")
assert.Equal(t, err.Meta().Get("Foo"), "bar")
assert.Equal(t, CodeOf(err), CodeUnknown)
}

Expand All @@ -51,9 +51,9 @@ func TestErrorFormatting(t *testing.T) {
NewError(CodeUnavailable, errors.New("")).Error(),
CodeUnavailable.String(),
)
got := NewError(CodeUnavailable, errors.New("foo")).Error()
got := NewError(CodeUnavailable, errors.New("Foo")).Error()
assert.True(t, strings.Contains(got, CodeUnavailable.String()))
assert.True(t, strings.Contains(got, "foo"))
assert.True(t, strings.Contains(got, "Foo"))
}

func TestErrorCode(t *testing.T) {
Expand Down
9 changes: 5 additions & 4 deletions protocol_connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,8 @@ func (m *connectUnaryRequestMarshaler) marshalWithGet(message any) *Error {
if !isTooBig {
url := m.buildGetURL(data, false /* compressed */)
if m.getURLMaxBytes <= 0 || len(url.String()) < m.getURLMaxBytes {
return m.writeWithGet(url)
m.writeWithGet(url)
return nil
}
if m.compressionPool == nil {
if m.getUseFallback {
Expand All @@ -1044,7 +1045,8 @@ func (m *connectUnaryRequestMarshaler) marshalWithGet(message any) *Error {
}
url := m.buildGetURL(compressed.Bytes(), true /* compressed */)
if m.getURLMaxBytes <= 0 || len(url.String()) < m.getURLMaxBytes {
return m.writeWithGet(url)
m.writeWithGet(url)
return nil
}
if m.getUseFallback {
setHeaderCanonical(m.header, connectUnaryHeaderCompression, m.compressionName)
Expand All @@ -1071,14 +1073,13 @@ func (m *connectUnaryRequestMarshaler) buildGetURL(data []byte, compressed bool)
return &url
}

func (m *connectUnaryRequestMarshaler) writeWithGet(url *url.URL) *Error {
func (m *connectUnaryRequestMarshaler) writeWithGet(url *url.URL) {
delHeaderCanonical(m.header, connectHeaderProtocolVersion)
delHeaderCanonical(m.header, headerContentType)
delHeaderCanonical(m.header, headerContentEncoding)
delHeaderCanonical(m.header, headerContentLength)
m.duplexCall.SetMethod(http.MethodGet)
*m.duplexCall.URL() = *url
return nil
}

type connectUnaryUnmarshaler struct {
Expand Down

0 comments on commit 9bb955e

Please sign in to comment.