Method dao.List
has 101 lines of code (exceeds 50 allowed). Consider refactoring.
func (d *dao) List(ctx context.Context, query *q.Query, userID uint,
withRegion bool, appIDs ...uint) (int, []*models.ClusterWithRegion, error) {
var (
clusters []*models.ClusterWithRegion
total int64
Method dao.List
has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
func (d *dao) List(ctx context.Context, query *q.Query, userID uint,
withRegion bool, appIDs ...uint) (int, []*models.ClusterWithRegion, error) {
var (
clusters []*models.ClusterWithRegion
total int64
Method dao.Create
has 62 lines of code (exceeds 50 allowed). Consider refactoring.
func (d *dao) Create(ctx context.Context, cluster *models.Cluster,
tags []*tagmodels.Tag, extraMembers map[*usermodels.User]string) (*models.Cluster, error) {
currentUser, err := common.UserFromContext(ctx)
if err != nil {
return nil, err
Method dao.Create
has 8 return statements (exceeds 4 allowed).
func (d *dao) Create(ctx context.Context, cluster *models.Cluster,
tags []*tagmodels.Tag, extraMembers map[*usermodels.User]string) (*models.Cluster, error) {
currentUser, err := common.UserFromContext(ctx)
if err != nil {
return nil, err
Method dao.UpdateByID
has 6 return statements (exceeds 4 allowed).
func (d *dao) UpdateByID(ctx context.Context, id uint, cluster *models.Cluster) (*models.Cluster, error) {
var clusterInDB models.Cluster
if err := d.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
result := tx.Raw(sqlcommon.ClusterQueryByID, id).Scan(&clusterInDB)
Method dao.List
has 5 arguments (exceeds 4 allowed). Consider refactoring.
func (d *dao) List(ctx context.Context, query *q.Query, userID uint,
withRegion bool, appIDs ...uint) (int, []*models.ClusterWithRegion, error) {
Similar blocks of code found in 2 locations. Consider refactoring.
func (d *dao) GetByNameFuzzily(ctx context.Context, name string, includeSoftDelete bool) ([]*models.Cluster, error) {
var clusters []*models.Cluster
statement := d.db.Unscoped().WithContext(ctx).Where("name like ?", fmt.Sprintf("%%%s%%", name))
if !includeSoftDelete {
There are no issues that match your filters.