Showing 43 of 119 total issues
Method RoleService.dbToCollResourceWithRel
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func (s *RoleService) dbToCollResourceWithRel(ctx context.Context, dbrows []*dbRole) (*user.RoleCollection, error) {
params, ok := ctx.Value(aphgrpc.ContextKeyParams).(*aphgrpc.JSONAPIParams)
if !ok {
return &user.RoleCollection{}, fmt.Errorf("no params object found in context")
}
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method RoleService.UpdateRole
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func (s *RoleService) UpdateRole(ctx context.Context, r *user.UpdateRoleRequest) (*user.Role, error) {
result, err := s.existsResource(r.Id)
if err != nil {
return &user.Role{}, aphgrpc.HandleError(ctx, err)
}
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method PermissionService.ListPermissions
has 9 return statements (exceeds 4 allowed). Open
func (s *PermissionService) ListPermissions(ctx context.Context, r *jsonapi.SimpleListRequest) (*user.PermissionCollection, error) {
params, md, err := aphgrpc.ValidateAndParseSimpleListParams(s, r)
if err != nil {
grpc.SetTrailer(ctx, md)
return &user.PermissionCollection{}, status.Error(codes.InvalidArgument, err.Error())
- Create a ticketCreate a ticket
Method RoleService.CreatePermissionRelationship
has 7 return statements (exceeds 4 allowed). Open
func (s *RoleService) CreatePermissionRelationship(ctx context.Context, r *jsonapi.DataCollection) (*empty.Empty, error) {
if len(r.Data) == 0 {
return &empty.Empty{}, aphgrpc.HandleInsertArgError(ctx, fmt.Errorf("no id given"))
}
result, err := s.existsResource(r.Id)
- Create a ticketCreate a ticket
Method RoleService.CreateUserRelationship
has 7 return statements (exceeds 4 allowed). Open
func (s *RoleService) CreateUserRelationship(ctx context.Context, r *jsonapi.DataCollection) (*empty.Empty, error) {
if len(r.Data) == 0 {
return &empty.Empty{}, aphgrpc.HandleInsertArgError(ctx, fmt.Errorf("no id given"))
}
result, err := s.existsResource(r.Id)
- Create a ticketCreate a ticket
Method UserService.CreateRoleRelationship
has 7 return statements (exceeds 4 allowed). Open
func (s *UserService) CreateRoleRelationship(ctx context.Context, r *jsonapi.DataCollection) (*empty.Empty, error) {
if len(r.Data) == 0 {
return &empty.Empty{}, aphgrpc.HandleInsertArgError(ctx, fmt.Errorf("no id given"))
}
result, err := s.existsResource(r.Id)
- Create a ticketCreate a ticket
Method RoleService.UpdatePermissionRelationship
has 6 return statements (exceeds 4 allowed). Open
func (s *RoleService) UpdatePermissionRelationship(ctx context.Context, r *jsonapi.DataCollection) (*empty.Empty, error) {
if len(r.Data) == 0 {
return &empty.Empty{}, aphgrpc.HandleInsertArgError(ctx, fmt.Errorf("no id given"))
}
result, err := s.existsResource(r.Id)
- Create a ticketCreate a ticket
Method RoleService.dbToCollResourceWithRel
has 6 return statements (exceeds 4 allowed). Open
func (s *RoleService) dbToCollResourceWithRel(ctx context.Context, dbrows []*dbRole) (*user.RoleCollection, error) {
params, ok := ctx.Value(aphgrpc.ContextKeyParams).(*aphgrpc.JSONAPIParams)
if !ok {
return &user.RoleCollection{}, fmt.Errorf("no params object found in context")
}
- Create a ticketCreate a ticket
Method UserService.UpdateUser
has 6 return statements (exceeds 4 allowed). Open
func (s *UserService) UpdateUser(ctx context.Context, r *user.UpdateUserRequest) (*user.User, error) {
result, err := s.existsResource(r.Id)
if err != nil {
return &user.User{}, aphgrpc.HandleError(ctx, err)
}
- Create a ticketCreate a ticket
Function replyUser
has 6 return statements (exceeds 4 allowed). Open
func replyUser(subj string, c message.UserClient, req *pubsub.IdRequest) *pubsub.UserReply {
switch subj {
case "UserService.Get":
u, err := c.Get(req.Id)
if err != nil {
- Create a ticketCreate a ticket
Method RoleService.buildResourceRelationships
has 6 return statements (exceeds 4 allowed). Open
func (s *RoleService) buildResourceRelationships(ctx context.Context, id int64, role *user.Role) error {
params, ok := ctx.Value(aphgrpc.ContextKeyParams).(*aphgrpc.JSONAPIParams)
if !ok {
return fmt.Errorf("no params object found in context")
}
- Create a ticketCreate a ticket
Method RoleService.UpdateUserRelationship
has 6 return statements (exceeds 4 allowed). Open
func (s *RoleService) UpdateUserRelationship(ctx context.Context, r *jsonapi.DataCollection) (*empty.Empty, error) {
if len(r.Data) == 0 {
return &empty.Empty{}, aphgrpc.HandleInsertArgError(ctx, fmt.Errorf("no id given"))
}
result, err := s.existsResource(r.Id)
- Create a ticketCreate a ticket
Method UserService.UpdateRoleRelationship
has 6 return statements (exceeds 4 allowed). Open
func (s *UserService) UpdateRoleRelationship(ctx context.Context, r *jsonapi.DataCollection) (*empty.Empty, error) {
if len(r.Data) == 0 {
return &empty.Empty{}, aphgrpc.HandleInsertArgError(ctx, fmt.Errorf("no id given"))
}
result, err := s.existsResource(r.Id)
- Create a ticketCreate a ticket
Method RoleService.UpdateRole
has 6 return statements (exceeds 4 allowed). Open
func (s *RoleService) UpdateRole(ctx context.Context, r *user.UpdateRoleRequest) (*user.Role, error) {
result, err := s.existsResource(r.Id)
if err != nil {
return &user.Role{}, aphgrpc.HandleError(ctx, err)
}
- Create a ticketCreate a ticket
Function NewTestPostgresFromEnv
has 5 return statements (exceeds 4 allowed). Open
func NewTestPostgresFromEnv() (*TestPostgres, error) {
pg := new(TestPostgres)
if err := CheckPostgresEnv(); err != nil {
return pg, err
}
- Create a ticketCreate a ticket
Method RoleService.DeletePermissionRelationship
has 5 return statements (exceeds 4 allowed). Open
func (s *RoleService) DeletePermissionRelationship(ctx context.Context, r *jsonapi.DataCollection) (*empty.Empty, error) {
if len(r.Data) == 0 {
return &empty.Empty{}, aphgrpc.HandleInsertArgError(ctx, fmt.Errorf("no id given"))
}
result, err := s.existsResource(r.Id)
- Create a ticketCreate a ticket
Function RunUserServer
has 5 return statements (exceeds 4 allowed). Open
func RunUserServer(c *cli.Context) error {
dbh, err := getPgWrapper(c)
if err != nil {
return cli.NewExitError(
fmt.Sprintf("Unable to create database connection %s", err.Error()),
- Create a ticketCreate a ticket
Method PermissionService.GetPermission
has 5 return statements (exceeds 4 allowed). Open
func (s *PermissionService) GetPermission(ctx context.Context, r *jsonapi.GetRequestWithFields) (*user.Permission, error) {
getReq := &jsonapi.GetRequest{
Id: r.Id,
Fields: r.Fields,
}
- Create a ticketCreate a ticket
Method RoleService.CreateRole
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (s *RoleService) CreateRole(ctx context.Context, r *user.CreateRoleRequest) (*user.Role, error) {
dbrole := s.attrTodbRole(r.Data.Attributes)
rcolumns := aphgrpc.GetDefinedTags(dbrole, "db")
if len(rcolumns) > 0 {
err := s.Dbh.InsertInto("auth_role").
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function RunPermissionServer
has 5 return statements (exceeds 4 allowed). Open
func RunPermissionServer(c *cli.Context) error {
dbh, err := getPgWrapper(c)
if err != nil {
return cli.NewExitError(
fmt.Sprintf("Unable to create database connection %s", err.Error()),
- Create a ticketCreate a ticket