From 5c4763dda823c5a72149e50e4a47ec6d127431bf Mon Sep 17 00:00:00 2001 From: Paras Shah Date: Wed, 18 Dec 2019 13:21:30 -0800 Subject: [PATCH] address GoLangCI and DeepSource comments --- dgraph/cmd/zero/zero.go | 2 +- edgraph/access_ee.go | 7 ++++--- edgraph/server.go | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dgraph/cmd/zero/zero.go b/dgraph/cmd/zero/zero.go index b489fc0d90c..9fe670443d4 100644 --- a/dgraph/cmd/zero/zero.go +++ b/dgraph/cmd/zero/zero.go @@ -783,6 +783,6 @@ func (s *Server) applyLicense(ctx context.Context, signedData io.Reader) error { } // CurrentState return the current membership state. -func (s *Server) CurrentState(ctx context.Context, _ *api.Payload) (resp *pb.MembershipState, err error) { +func (s *Server) CurrentState(ctx context.Context, _ *api.Payload) (*pb.MembershipState, error) { return s.latestMembershipState(ctx) } diff --git a/edgraph/access_ee.go b/edgraph/access_ee.go index 2397c407b78..1f9a3284601 100644 --- a/edgraph/access_ee.go +++ b/edgraph/access_ee.go @@ -733,11 +733,12 @@ func authorizeState(ctx context.Context) error { // doAuthorizeState checks if the user is authorized to perform this API request doAuthorizeState := func() error { userData, err := extractUserAndGroups(ctx) - if err == errNoJwt { + switch { + case err == errNoJwt: return status.Error(codes.PermissionDenied, err.Error()) - } else if err != nil { + case err != nil: return status.Error(codes.Unauthenticated, err.Error()) - } else { + default: userId = userData[0] if userId == x.GrootId { return nil diff --git a/edgraph/server.go b/edgraph/server.go index 25cd1792398..2e4cfa6aca0 100644 --- a/edgraph/server.go +++ b/edgraph/server.go @@ -611,11 +611,11 @@ func (s *Server) doState(ctx context.Context, authorize int) ( } m := jsonpb.Marshaler{} - var json bytes.Buffer - if err := m.Marshal(&json, ms); err != nil { + var jsonState bytes.Buffer + if err := m.Marshal(&jsonState, ms); err != nil { return nil, errors.New("Error marshalling state information to JSON") } - return &api.Response{Json: json.Bytes()}, nil + return &api.Response{Json: jsonState.Bytes()}, nil } // Query handles queries or mutations