gogjango/gjango

View on GitHub

Showing 21 of 21 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

package cmd

import (
    "log"
    "strconv"
Severity: Major
Found in cmd/migrate_up.go and 1 other location - About 2 hrs to fix
cmd/migrate_set_version.go on lines 1..34

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 207.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

package cmd

import (
    "log"
    "strconv"
Severity: Major
Found in cmd/migrate_set_version.go and 1 other location - About 2 hrs to fix
cmd/migrate_up.go on lines 1..34

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 207.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

    package cmd
    
    import (
        "fmt"
        "log"
    Severity: Major
    Found in cmd/migrate_down.go and 3 other locations - About 1 hr to fix
    cmd/migrate_init.go on lines 1..27
    cmd/migrate_reset.go on lines 1..27
    cmd/migrate_version.go on lines 1..27

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 147.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

    package cmd
    
    import (
        "fmt"
        "log"
    Severity: Major
    Found in cmd/migrate_init.go and 3 other locations - About 1 hr to fix
    cmd/migrate_down.go on lines 1..27
    cmd/migrate_reset.go on lines 1..27
    cmd/migrate_version.go on lines 1..27

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 147.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

    package cmd
    
    import (
        "fmt"
        "log"
    Severity: Major
    Found in cmd/migrate_reset.go and 3 other locations - About 1 hr to fix
    cmd/migrate_down.go on lines 1..27
    cmd/migrate_init.go on lines 1..27
    cmd/migrate_version.go on lines 1..27

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 147.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

    package cmd
    
    import (
        "fmt"
        "log"
    Severity: Major
    Found in cmd/migrate_version.go and 3 other locations - About 1 hr to fix
    cmd/migrate_down.go on lines 1..27
    cmd/migrate_init.go on lines 1..27
    cmd/migrate_reset.go on lines 1..27

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 147.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (u *UserRepo) FindByToken(token string) (*model.User, error) {
        var user = new(model.User)
        sql := `SELECT "user".*, "role"."id" AS "role__id", "role"."access_level" AS "role__access_level", "role"."name" AS "role__name" 
        FROM "users" AS "user" LEFT JOIN "roles" AS "role" ON "role"."id" = "user"."role_id" 
        WHERE ("user"."token" = ? and deleted_at is null)`
    Severity: Major
    Found in repository/user.go and 1 other location - About 1 hr to fix
    repository/account.go on lines 110..119

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 140.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (a *AccountRepo) FindVerificationToken(token string) (*model.Verification, error) {
        var v = new(model.Verification)
        sql := `SELECT * FROM verifications WHERE (token = ? and deleted_at IS NULL)`
        _, err := a.db.QueryOne(v, sql, token)
        if err != nil {
    Severity: Major
    Found in repository/account.go and 1 other location - About 1 hr to fix
    repository/user.go on lines 81..92

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 140.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (u *UserRepo) FindByEmail(email string) (*model.User, error) {
        user := new(model.User)
        sql := `SELECT "user".*, "role"."id" AS "role__id", "role"."access_level" AS "role__access_level", "role"."name" AS "role__name" 
        FROM "users" AS "user" LEFT JOIN "roles" AS "role" ON "role"."id" = "user"."role_id" 
        WHERE ("user"."email" = ? and deleted_at is null)`
    Severity: Major
    Found in repository/user.go and 1 other location - About 1 hr to fix
    repository/user.go on lines 39..50

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 136.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (u *UserRepo) FindByUsername(username string) (*model.User, error) {
        user := new(model.User)
        sql := `SELECT "user".*, "role"."id" AS "role__id", "role"."access_level" AS "role__access_level", "role"."name" AS "role__name" 
        FROM "users" AS "user" LEFT JOIN "roles" AS "role" ON "role"."id" = "user"."role_id" 
        WHERE ("user"."username" = ? and deleted_at is null)`
    Severity: Major
    Found in repository/user.go and 1 other location - About 1 hr to fix
    repository/user.go on lines 53..64

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 136.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (a *AccountRepo) ChangePassword(u *model.User) error {
        u.Update()
        _, err := a.db.Model(u).Column("password", "updated_at").WherePK().Update()
        if err != nil {
            a.log.Warn("AccountRepo Error: ", zap.Error(err))
    Severity: Minor
    Found in repository/account.go and 1 other location - About 55 mins to fix
    repository/user.go on lines 95..102

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 127.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (u *UserRepo) UpdateLogin(user *model.User) error {
        user.UpdateLastLogin() // update user object's last_login field
        _, err := u.db.Model(user).Column("last_login", "token").WherePK().Update()
        if err != nil {
            u.log.Warn("UserRepo Error", zap.Error(err))
    Severity: Minor
    Found in repository/user.go and 1 other location - About 55 mins to fix
    repository/account.go on lines 100..107

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 127.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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
                  Severity
                  Category
                  Status
                  Source
                  Language