Showing 43 of 119 total issues
Method UserService.ListUsers
has a Cognitive Complexity of 113 (exceeds 20 allowed). Consider refactoring. Open
func (s *UserService) ListUsers(ctx context.Context, r *jsonapi.ListRequest) (*user.UserCollection, error) {
params, md, err := aphgrpc.ValidateAndParseListParams(s, r)
if err != nil {
grpc.SetTrailer(ctx, md)
return &user.UserCollection{}, status.Error(codes.InvalidArgument, err.Error())
- 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
File user.go
has 963 lines of code (exceeds 500 allowed). Consider refactoring. Open
package server
import (
"context"
"fmt"
- Create a ticketCreate a ticket
File role.go
has 868 lines of code (exceeds 500 allowed). Consider refactoring. Open
package server
import (
"context"
"fmt"
- Create a ticketCreate a ticket
Function main
has 235 lines of code (exceeds 50 allowed). Consider refactoring. Open
func main() {
app := cli.NewApp()
app.Name = "modware-user"
app.Usage = "starts the modware-user microservice with HTTP and grpc backends"
app.Version = "1.0.0"
- Create a ticketCreate a ticket
Method UserService.ListUsers
has 202 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *UserService) ListUsers(ctx context.Context, r *jsonapi.ListRequest) (*user.UserCollection, error) {
params, md, err := aphgrpc.ValidateAndParseListParams(s, r)
if err != nil {
grpc.SetTrailer(ctx, md)
return &user.UserCollection{}, status.Error(codes.InvalidArgument, err.Error())
- Create a ticketCreate a ticket
Method UserService.ListUsers
has 57 return statements (exceeds 4 allowed). Open
func (s *UserService) ListUsers(ctx context.Context, r *jsonapi.ListRequest) (*user.UserCollection, error) {
params, md, err := aphgrpc.ValidateAndParseListParams(s, r)
if err != nil {
grpc.SetTrailer(ctx, md)
return &user.UserCollection{}, status.Error(codes.InvalidArgument, err.Error())
- Create a ticketCreate a ticket
UserService
has 36 methods (exceeds 20 allowed). Consider refactoring. Open
type UserService struct {
*aphgrpc.Service
}
- Create a ticketCreate a ticket
RoleService
has 35 methods (exceeds 20 allowed). Consider refactoring. Open
type RoleService struct {
*aphgrpc.Service
}
- Create a ticketCreate a ticket
Function LoadUser
has 106 lines of code (exceeds 50 allowed). Consider refactoring. Open
func LoadUser(c *cli.Context) error {
conn, err := grpc.Dial(
fmt.Sprintf("%s:%s", c.String("user-grpc-host"), c.String("user-grpc-port")),
grpc.WithInsecure(),
)
- Create a ticketCreate a ticket
Method RoleService.ListRoles
has 78 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *RoleService) ListRoles(ctx context.Context, r *jsonapi.SimpleListRequest) (*user.RoleCollection, error) {
params, md, err := aphgrpc.ValidateAndParseSimpleListParams(s, r)
if err != nil {
grpc.SetTrailer(ctx, md)
return &user.RoleCollection{}, status.Error(codes.InvalidArgument, err.Error())
- Create a ticketCreate a ticket
Method RoleService.ListRoles
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
func (s *RoleService) ListRoles(ctx context.Context, r *jsonapi.SimpleListRequest) (*user.RoleCollection, error) {
params, md, err := aphgrpc.ValidateAndParseSimpleListParams(s, r)
if err != nil {
grpc.SetTrailer(ctx, md)
return &user.RoleCollection{}, status.Error(codes.InvalidArgument, err.Error())
- 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.ListRoles
has 21 return statements (exceeds 4 allowed). Open
func (s *RoleService) ListRoles(ctx context.Context, r *jsonapi.SimpleListRequest) (*user.RoleCollection, error) {
params, md, err := aphgrpc.ValidateAndParseSimpleListParams(s, r)
if err != nil {
grpc.SetTrailer(ctx, md)
return &user.RoleCollection{}, status.Error(codes.InvalidArgument, err.Error())
- Create a ticketCreate a ticket
Function RunPermissionServer
has 71 lines of code (exceeds 50 allowed). Consider refactoring. 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
Function RunUserServer
has 71 lines of code (exceeds 50 allowed). Consider refactoring. 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
Function RunRoleServer
has 71 lines of code (exceeds 50 allowed). Consider refactoring. Open
func RunRoleServer(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
Function newUser
has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring. Open
func newUser(record []string) *pb.CreateUserRequest {
attr := &pb.UserAttributes{}
for i, v := range record {
switch i {
case 6:
- 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 UserService.UpdateUser
has 53 lines of code (exceeds 50 allowed). Consider refactoring. 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 LoadUser
has 11 return statements (exceeds 4 allowed). Open
func LoadUser(c *cli.Context) error {
conn, err := grpc.Dial(
fmt.Sprintf("%s:%s", c.String("user-grpc-host"), c.String("user-grpc-port")),
grpc.WithInsecure(),
)
- Create a ticketCreate a ticket
Method UserService.GetUser
has 11 return statements (exceeds 4 allowed). Open
func (s *UserService) GetUser(ctx context.Context, r *jsonapi.GetRequest) (*user.User, error) {
params, md, err := aphgrpc.ValidateAndParseGetParams(s, r)
if err != nil {
grpc.SetTrailer(ctx, md)
return new(user.User), status.Error(codes.InvalidArgument, err.Error())
- Create a ticketCreate a ticket
Method RoleService.GetRole
has 11 return statements (exceeds 4 allowed). Open
func (s *RoleService) GetRole(ctx context.Context, r *jsonapi.GetRequest) (*user.Role, error) {
params, md, err := aphgrpc.ValidateAndParseGetParams(s, r)
if err != nil {
grpc.SetTrailer(ctx, md)
return &user.Role{}, status.Error(codes.InvalidArgument, err.Error())
- Create a ticketCreate a ticket