Skip to content

Commit

Permalink
fix(various): suppress errcheck linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jochumdev committed Nov 12, 2024
1 parent 8b6ca15 commit 191046f
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Lint files
uses: dagger/dagger-for-github@v7
with:
version: "v0.14.0"
version: v0.14.0
verb: call
args: lint --root=. logs
cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }}
Expand All @@ -29,7 +29,7 @@ jobs:
- name: Run unit tests
uses: dagger/dagger-for-github@v7
with:
version: "v0.14.0"
version: v0.14.0
verb: call
args: test --root=. logs
cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Lint files
uses: dagger/dagger-for-github@v7
with:
version: "v0.14.0"
version: v0.14.0
verb: call
args: lint --root=. logs
cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }}
Expand All @@ -27,7 +27,7 @@ jobs:
- name: Run unit tests
uses: dagger/dagger-for-github@v7
with:
version: "v0.14.0"
version: v0.14.0
verb: call
args: test --root=. logs
cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }}
12 changes: 6 additions & 6 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ runtimes:
- [email protected]
lint:
enabled:
- [email protected].0
- [email protected].269
- [email protected].1
- [email protected].286
- [email protected]
- trufflehog@3.82.13
- trufflehog@3.83.6
- [email protected]
- [email protected].3
- [email protected].4
- [email protected]
- git-diff-check
- [email protected]
- [email protected]
- golangci-lint@1.61.0
- golangci-lint@1.62.0
- [email protected]
disabled:
- gokart
- shellcheck
- shfmt
cli:
version: 1.22.7
version: 1.22.8
plugins:
sources:
- id: trunk
Expand Down
2 changes: 1 addition & 1 deletion client/orb/transport/drpc/drpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (t *Transport) CallNoCodec(ctx context.Context, req *client.Request[any, an
}

// Unmarshal the result.
if err := mdResult.GetData().UnmarshalTo(result.(proto.Message)); err != nil {
if err := mdResult.GetData().UnmarshalTo(result.(proto.Message)); err != nil { //nolint:errcheck
return orberrors.From(err)
}

Expand Down
2 changes: 1 addition & 1 deletion client/tests/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func (s *TestSuite) doRequest(ctx context.Context, req *TestRequest, c client.Ty
s.Require().Error(err)
} else {
s.Require().NoError(err)
s.Equal(req.Response.(*proto.CallResponse).GetMsg(), rsp.GetMsg(), "unexpected response")
s.Equal(req.Response.(*proto.CallResponse).GetMsg(), rsp.GetMsg(), "unexpected response") //nolint:errcheck
}
}

Expand Down
8 changes: 4 additions & 4 deletions codecs/jsonpb/jsonpb.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type mEncoder struct {
}

func (m *mEncoder) Encode(v any) error {
b, err := protojson.Marshal(v.(protoreflect.ProtoMessage))
b, err := protojson.Marshal(v.(protoreflect.ProtoMessage)) //nolint:errcheck
if err != nil {
return err
}
Expand All @@ -45,7 +45,7 @@ func (m *mDecoder) Decode(v any) error {
return err
}

return protojson.Unmarshal(b, v.(protoreflect.ProtoMessage))
return protojson.Unmarshal(b, v.(protoreflect.ProtoMessage)) //nolint:errcheck
}

// JSONPb wraps Google's implementation of a JSON <> Protocol buffer marshaller
Expand All @@ -54,13 +54,13 @@ type JSONPb struct{}

// Encode encodes "v" into byte sequence.
func (j *JSONPb) Encode(v any) ([]byte, error) {
return protojson.Marshal(v.(protoreflect.ProtoMessage))
return protojson.Marshal(v.(protoreflect.ProtoMessage)) //nolint:errcheck
}

// Decode decodes "data" into "v".
// "v" must be a pointer value.
func (j *JSONPb) Decode(b []byte, v any) error {
return protojson.Unmarshal(b, v.(protoreflect.ProtoMessage))
return protojson.Unmarshal(b, v.(protoreflect.ProtoMessage)) //nolint:errcheck
}

// NewEncoder returns a new JSON/ProtocolBuffer encoder.
Expand Down
2 changes: 1 addition & 1 deletion config/source/cli/urfave/urfave.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (c *flagCLI) parse(args []string) error {
}

for n, tf := range c.stringSliceFlags {
if !slices.Equal(c.flags[n].Default.([]string), tf.Get(ctx)) {
if !slices.Equal(c.flags[n].Default.([]string), tf.Get(ctx)) { //nolint:errcheck
c.flags[n].Value = tf.Get(ctx)
}
}
Expand Down
2 changes: 1 addition & 1 deletion server/cmd/protoc-gen-go-orb/orb/orb.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func genServices(file *protogen.File, generated *protogen.GeneratedFile) []servi

// genService will generate a single service description.
func genService(file *protogen.File, generated *protogen.GeneratedFile, service *protogen.Service) serviceDesc {
if service.Desc.Options().(*descriptorpb.ServiceOptions).GetDeprecated() {
if service.Desc.Options().(*descriptorpb.ServiceOptions).GetDeprecated() { //nolint:errcheck
generated.P("//")
generated.P(deprecationComment)
}
Expand Down
8 changes: 4 additions & 4 deletions server/cmd/protoc-gen-go-orb/orbgrpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func genService(gen *protogen.Plugin, file *protogen.File, g *protogen.Generated
// Copy comments from proto file.
genServiceComments(g, service)

if service.Desc.Options().(*descriptorpb.ServiceOptions).GetDeprecated() {
if service.Desc.Options().(*descriptorpb.ServiceOptions).GetDeprecated() { //nolint:errcheck
g.P("//")
g.P(deprecationComment)
}
Expand All @@ -240,15 +240,15 @@ func genService(gen *protogen.Plugin, file *protogen.File, g *protogen.Generated
// Copy comments from proto file.
genServiceComments(g, service)

if service.Desc.Options().(*descriptorpb.ServiceOptions).GetDeprecated() {
if service.Desc.Options().(*descriptorpb.ServiceOptions).GetDeprecated() { //nolint:errcheck
g.P("//")
g.P(deprecationComment)
}
g.AnnotateSymbol(serverType, protogen.Annotation{Location: service.Location})
g.P("type ", serverType, " interface {")
for _, method := range service.Methods {
g.AnnotateSymbol(serverType+"."+method.GoName, protogen.Annotation{Location: method.Location})
if method.Desc.Options().(*descriptorpb.MethodOptions).GetDeprecated() {
if method.Desc.Options().(*descriptorpb.MethodOptions).GetDeprecated() { //nolint:errcheck
g.P(deprecationComment)
}
g.P(method.Comments.Leading,
Expand All @@ -272,7 +272,7 @@ func genService(gen *protogen.Plugin, file *protogen.File, g *protogen.Generated
g.P("}")

// Server registration.
if service.Desc.Options().(*descriptorpb.ServiceOptions).GetDeprecated() {
if service.Desc.Options().(*descriptorpb.ServiceOptions).GetDeprecated() { //nolint:errcheck
g.P(deprecationComment)
}
serviceDescVar := service.GoName + "_ServiceDesc"
Expand Down
2 changes: 1 addition & 1 deletion server/drpc/handle_rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (m *Mux) HandleRPC(stream drpc.Stream, rpc string) (err error) {

return drpcerr.WithCode(errors.New(oErr.Message), uint64(oErr.Code)) //nolint:gosec
case out != nil && !reflect.ValueOf(out).IsNil():
outData, err := anypb.New(out.(proto.Message))
outData, err := anypb.New(out.(proto.Message)) //nolint:errcheck
if err != nil {
return errs.Wrap(err)
}
Expand Down
2 changes: 1 addition & 1 deletion server/hertz/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func NewGRPCHandler[Tin any, Tout any](

// Apply middleware.
h := func(ctx context.Context, req any) (any, error) {
return fHandler(ctx, req.(*Tin))
return fHandler(ctx, req.(*Tin)) //nolint:errcheck
}
for _, m := range srv.config.OptMiddlewares {
h = m.Call(h)
Expand Down
2 changes: 1 addition & 1 deletion server/http/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func NewGRPCHandler[Tin any, Tout any](

// Apply middleware.
h := func(ctx context.Context, req any) (any, error) {
return fHandler(ctx, req.(*Tin))
return fHandler(ctx, req.(*Tin)) //nolint:errcheck
}
for _, m := range srv.config.OptMiddlewares {
h = m.Call(h)
Expand Down
4 changes: 2 additions & 2 deletions server/http/tests/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func TestServerIntegration(t *testing.T) {

e, err := srv.GetEntrypoint("test-ep-1")
require.NoError(t, err, "failed to fetch entrypoint 1")
require.Len(t, e.(*mhttp.Server).Router().Routes(), 1, "number of routes not equal to 1")
require.Len(t, e.(*mhttp.Server).Router().Routes(), 1, "number of routes not equal to 1") //nolint:errcheck
makeRequests(t, "https://"+e.Address(), thttp.TypeHTTP3)

e, err = srv.GetEntrypoint("test-ep-2")
Expand Down Expand Up @@ -685,7 +685,7 @@ func setupServer(tb testing.TB, nolog bool, opts ...server.Option) (*mhttp.Serve
return nil, cancel, err
}

return server.(*mhttp.Server), cleanup, nil
return server.(*mhttp.Server), cleanup, nil //nolint:errcheck
}

func makeRequests(t *testing.T, addr string, reqType thttp.ReqType) {
Expand Down

0 comments on commit 191046f

Please sign in to comment.