horizoncd/horizon

View on GitHub
pkg/group/dao/dao.go

Summary

Maintainability
B
6 hrs
Test Coverage

Showing 6 of 6 total issues

Method dao.Create has 57 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (d *dao) Create(ctx context.Context, group *models.Group) (*models.Group, error) {
currentUser, err := common.UserFromContext(ctx)
if err != nil {
return nil, err
}
Severity: Minor
Found in pkg/group/dao/dao.go - About 1 hr to fix

    Method dao.Create has 11 return statements (exceeds 4 allowed).
    Open

    func (d *dao) Create(ctx context.Context, group *models.Group) (*models.Group, error) {
    currentUser, err := common.UserFromContext(ctx)
    if err != nil {
    return nil, err
    }
    Severity: Major
    Found in pkg/group/dao/dao.go - About 1 hr to fix

      Method dao.Transfer has 9 return statements (exceeds 4 allowed).
      Open

      func (d *dao) Transfer(ctx context.Context, id, newParentID uint) error {
      currentUser, err := common.UserFromContext(ctx)
      if err != nil {
      return nil
      }
      Severity: Major
      Found in pkg/group/dao/dao.go - About 55 mins to fix

        Method dao.ListByTraversalIDsContains has 6 return statements (exceeds 4 allowed).
        Open

        func (d *dao) ListByTraversalIDsContains(ctx context.Context, ids []uint) ([]*models.Group, error) {
        if len(ids) == 0 {
        return nil, nil
        }
        var groups []*models.Group
        Severity: Major
        Found in pkg/group/dao/dao.go - About 40 mins to fix

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

          func (d *dao) GetByPaths(ctx context.Context, paths []string) ([]*models.Group, error) {
          var groups []*models.Group
          result := d.db.WithContext(ctx).Raw(dbcommon.GroupQueryByPaths, paths).Scan(&groups)
           
          if result.Error != nil {
          Severity: Major
          Found in pkg/group/dao/dao.go and 1 other location - About 1 hr to fix
          pkg/group/dao/dao.go on lines 199..208

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

          func (d *dao) GetByIDs(ctx context.Context, ids []uint) ([]*models.Group, error) {
          var groups []*models.Group
          result := d.db.WithContext(ctx).Raw(dbcommon.GroupQueryByIDs, ids).Scan(&groups)
           
          if result.Error != nil {
          Severity: Major
          Found in pkg/group/dao/dao.go and 1 other location - About 1 hr to fix
          pkg/group/dao/dao.go on lines 188..197

          There are no issues that match your filters.

          Category
          Status