gogjango/gjango

View on GitHub

Showing 9 of 21 total issues

goPgDB has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

type goPgDB struct {
    sqlMock *SQLMock
}
Severity: Minor
Found in mockgopg/orm.go - About 2 hrs to fix

    Function NewServices has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    func NewServices(DB *pg.DB, Log *zap.Logger, JWT *mw.JWT, Mail mail.Service, Mobile mobile.Service, R *gin.Engine) *Services {
    Severity: Minor
    Found in route/route.go - About 45 mins to fix

      Method Service.Authenticate has 6 return statements (exceeds 4 allowed).
      Open

      func (s *Service) Authenticate(c context.Context, email, password string) (*model.AuthToken, error) {
          u, err := s.userRepo.FindByEmail(email)
          if err != nil {
              return nil, apperr.Unauthorized
          }
      Severity: Major
      Found in repository/auth/auth.go - About 40 mins to fix

        Method Service.MobileVerify has 6 return statements (exceeds 4 allowed).
        Open

        func (s *Service) MobileVerify(c context.Context, countryCode, mobile, code string, signup bool) (*model.AuthToken, error) {
            // send code to twilio
            err := s.mob.CheckCode(countryCode, mobile, code)
            if err != nil {
                return nil, err
        Severity: Major
        Found in repository/auth/auth.go - About 40 mins to fix

          Method AccountRepo.CreateWithMobile has 6 return statements (exceeds 4 allowed).
          Open

          func (a *AccountRepo) CreateWithMobile(u *model.User) error {
              user := new(model.User)
              sql := `SELECT id FROM users WHERE username = ? OR email = ? OR (country_code = ? AND mobile = ?) AND deleted_at IS NULL`
              res, err := a.db.Query(user, sql, u.Username, u.Email, u.CountryCode, u.Mobile)
              if err == apperr.DB {
          Severity: Major
          Found in repository/account.go - About 40 mins to fix

            Function NewAuthService has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            func NewAuthService(userRepo model.UserRepo, accountRepo model.AccountRepo, jwt JWT, m mail.Service, mob mobile.Service) *Service {
            Severity: Minor
            Found in repository/auth/auth.go - About 35 mins to fix

              Method AccountRepo.CreateAndVerify has 5 return statements (exceeds 4 allowed).
              Open

              func (a *AccountRepo) CreateAndVerify(u *model.User) (*model.Verification, error) {
                  user := new(model.User)
                  sql := `SELECT id FROM users WHERE username = ? OR email = ? OR (country_code = ? AND mobile = ?) AND deleted_at IS NULL`
                  res, err := a.db.Query(user, sql, u.Username, u.Email, u.CountryCode, u.Mobile)
                  if err == apperr.DB {
              Severity: Major
              Found in repository/account.go - About 35 mins to fix

                Method goPgDB.doQuery has 5 return statements (exceeds 4 allowed).
                Open

                func (p *goPgDB) doQuery(ctx context.Context, dst interface{}, query string, params ...interface{}) (orm.Result, error) {
                    // replace duplicate space
                    space := regexp.MustCompile(`\s+`)
                
                    for k, v := range p.sqlMock.queries {
                Severity: Major
                Found in mockgopg/orm.go - About 35 mins to fix

                  Function Merge has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func Merge(dst, src interface{}) {
                      s := reflect.ValueOf(src)
                      d := reflect.ValueOf(dst)
                      if s.Kind() != reflect.Ptr || d.Kind() != reflect.Ptr {
                          return
                  Severity: Minor
                  Found in repository/platform/structs/structs.go - About 25 mins to fix

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language