horizoncd/horizon

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

Summary

Maintainability
A
2 hrs
Test Coverage

Showing 4 of 4 total issues

Method dao.ListWebhookLogs has 52 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (d *dao) ListWebhookLogs(ctx context.Context, query *q.Query,
resources map[string][]uint) ([]*models.WebhookLogWithEventInfo, int64, error) {
var (
logs []*models.WebhookLogWithEventInfo
count int64
Severity: Minor
Found in pkg/webhook/dao/dao.go - About 1 hr to fix

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

    func (d *dao) ListWebhookLogs(ctx context.Context, query *q.Query,
    resources map[string][]uint) ([]*models.WebhookLogWithEventInfo, int64, error) {
    var (
    logs []*models.WebhookLogWithEventInfo
    count int64
    Severity: Minor
    Found in pkg/webhook/dao/dao.go - About 35 mins to fix

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

    func (d *dao) CreateWebhookLogs(ctx context.Context,
    wls []*models.WebhookLog) ([]*models.WebhookLog, error) {
    d.db.WithContext(ctx).Commit().Callback()
    if result := d.db.WithContext(ctx).Create(wls); result.Error != nil {
    return nil, herrors.NewErrInsertFailed(herrors.WebhookLogInDB, result.Error.Error())
    Severity: Minor
    Found in pkg/webhook/dao/dao.go and 1 other location - About 30 mins to fix
    pkg/webhook/dao/dao.go on lines 157..164

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

    func (d *dao) CreateWebhookLog(ctx context.Context,
    wl *models.WebhookLog) (*models.WebhookLog, error) {
    d.db.WithContext(ctx).Commit().Callback()
    if result := d.db.WithContext(ctx).Create(wl); result.Error != nil {
    return nil, herrors.NewErrInsertFailed(herrors.WebhookLogInDB, result.Error.Error())
    Severity: Minor
    Found in pkg/webhook/dao/dao.go and 1 other location - About 30 mins to fix
    pkg/webhook/dao/dao.go on lines 166..173
    Category
    Status