horizoncd/horizon

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

Summary

Maintainability
C
1 day
Test Coverage

Showing 7 of 7 total issues

Method dao.List has 63 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (d *dao) List(ctx context.Context, groupIDs []uint,
query *q.Query) (int, []*models.Application, error) {
var (
applications []*models.Application
total int64
Severity: Minor
Found in pkg/application/dao/dao.go - About 1 hr to fix

    Method dao.List has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
    Open

    func (d *dao) List(ctx context.Context, groupIDs []uint,
    query *q.Query) (int, []*models.Application, error) {
    var (
    applications []*models.Application
    total int64
    Severity: Minor
    Found in pkg/application/dao/dao.go - About 1 hr to fix

    Method dao.TransferByID has 7 return statements (exceeds 4 allowed).
    Open

    func (d *dao) TransferByID(ctx context.Context, id uint, groupID uint) error {
    currentUser, err := corecommon.UserFromContext(ctx)
    if err != nil {
    return err
    }
    Severity: Major
    Found in pkg/application/dao/dao.go - About 45 mins to fix

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

      func (d *dao) UpdateByID(ctx context.Context, id uint, application *models.Application) (*models.Application, error) {
      var applicationInDB models.Application
      if err := d.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
      // 1. get application in db first
      result := tx.Raw(common.ApplicationQueryByID, id).Scan(&applicationInDB)
      Severity: Major
      Found in pkg/application/dao/dao.go - About 40 mins to fix

        Method dao.DeleteByID has 5 return statements (exceeds 4 allowed).
        Open

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

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

          func (d *dao) Create(ctx context.Context, application *models.Application,
          extraMembers map[*usermodels.User]string) (*models.Application, error) {
          err := d.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
          // TODO: check the group exist
           
           
          Severity: Major
          Found in pkg/application/dao/dao.go - About 35 mins to fix

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

            func (d *dao) GetByNameFuzzily(ctx context.Context, name string,
            includeSoftDelete bool) ([]*models.Application, error) {
            var applications []*models.Application
             
            statement := d.db.Unscoped().WithContext(ctx).Where("name like ?", fmt.Sprintf("%%%s%%", name))
            Severity: Major
            Found in pkg/application/dao/dao.go and 1 other location - About 2 hrs to fix
            pkg/cluster/dao/dao.go on lines 400..416

            There are no issues that match your filters.

            Category
            Status