Skip to content

Commit

Permalink
address GoLangCI and DeepSource comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Paras Shah committed Dec 18, 2019
1 parent e6c2c6b commit 5c4763d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dgraph/cmd/zero/zero.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
7 changes: 4 additions & 3 deletions edgraph/access_ee.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions edgraph/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5c4763d

Please sign in to comment.