horizoncd/horizon

View on GitHub
pkg/pr/dao/pipelinerun.go

Summary

Maintainability
C
1 day
Test Coverage

Showing 7 of 7 total issues

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

func (d *pipelinerunDAO) GetLatestSuccessByClusterID(ctx context.Context, clusterID uint) (*models.Pipelinerun, error) {
var pipelinerun models.Pipelinerun
result := d.db.WithContext(ctx).Raw(common.PipelinerunGetLatestSuccessByClusterID, clusterID).Scan(&pipelinerun)
if result.Error != nil {
return nil, herrors.NewErrGetFailed(herrors.PipelinerunInDB, result.Error.Error())
Severity: Major
Found in pkg/pr/dao/pipelinerun.go and 3 other locations - About 1 hr to fix
pkg/pr/dao/pipelinerun.go on lines 68..78
pkg/pr/dao/pipelinerun.go on lines 80..90
pkg/pr/dao/pipelinerun.go on lines 231..243

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

func (d *pipelinerunDAO) GetByID(ctx context.Context, pipelinerunID uint) (*models.Pipelinerun, error) {
var pr models.Pipelinerun
result := d.db.WithContext(ctx).Raw(common.PipelinerunGetByID, pipelinerunID).Scan(&pr)
if result.Error != nil {
return nil, herrors.NewErrGetFailed(herrors.PipelinerunInDB, result.Error.Error())
Severity: Major
Found in pkg/pr/dao/pipelinerun.go and 3 other locations - About 1 hr to fix
pkg/pr/dao/pipelinerun.go on lines 80..90
pkg/pr/dao/pipelinerun.go on lines 149..159
pkg/pr/dao/pipelinerun.go on lines 231..243

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

func (d *pipelinerunDAO) GetByCIEventID(ctx context.Context, ciEventID string) (*models.Pipelinerun, error) {
var pr models.Pipelinerun
result := d.db.WithContext(ctx).Raw(common.PipelinerunGetByCIEventID, ciEventID).Scan(&pr)
if result.Error != nil {
return nil, herrors.NewErrGetFailed(herrors.PipelinerunInDB, result.Error.Error())
Severity: Major
Found in pkg/pr/dao/pipelinerun.go and 3 other locations - About 1 hr to fix
pkg/pr/dao/pipelinerun.go on lines 68..78
pkg/pr/dao/pipelinerun.go on lines 149..159
pkg/pr/dao/pipelinerun.go on lines 231..243

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

func (d *pipelinerunDAO) GetFirstCanRollbackPipelinerun(ctx context.Context,
clusterID uint) (*models.Pipelinerun, error) {
var pipelinerun models.Pipelinerun
result := d.db.WithContext(ctx).Raw(common.PipelinerunGetFirstCanRollbackByClusterID, clusterID).Scan(&pipelinerun)
 
 
Severity: Major
Found in pkg/pr/dao/pipelinerun.go and 3 other locations - About 1 hr to fix
pkg/pr/dao/pipelinerun.go on lines 68..78
pkg/pr/dao/pipelinerun.go on lines 80..90
pkg/pr/dao/pipelinerun.go on lines 149..159

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

func (d *pipelinerunDAO) Create(ctx context.Context, pipelinerun *models.Pipelinerun) (*models.Pipelinerun, error) {
result := d.db.WithContext(ctx).Create(pipelinerun)
 
if result.Error != nil {
return nil, herrors.NewErrInsertFailed(herrors.PipelinerunInDB, result.Error.Error())
Severity: Major
Found in pkg/pr/dao/pipelinerun.go and 4 other locations - About 1 hr to fix
pkg/environment/dao/dao.go on lines 67..75
pkg/pr/dao/check.go on lines 87..95
pkg/pr/dao/message.go on lines 27..35
pkg/region/dao/dao.go on lines 122..130

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

func (d *pipelinerunDAO) DeleteByClusterID(ctx context.Context, clusterID uint) error {
result := d.db.WithContext(ctx).Exec(common.PipelinerunDeleteByClusterID, clusterID)
 
if result.Error != nil {
return herrors.NewErrDeleteFailed(herrors.PipelinerunInDB, result.Error.Error())
Severity: Minor
Found in pkg/pr/dao/pipelinerun.go and 1 other location - About 50 mins to fix
pkg/pr/dao/pipelinerun.go on lines 102..110

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

func (d *pipelinerunDAO) DeleteByID(ctx context.Context, pipelinerunID uint) error {
result := d.db.WithContext(ctx).Exec(common.PipelinerunDeleteByID, pipelinerunID)
 
if result.Error != nil {
return herrors.NewErrDeleteFailed(herrors.PipelinerunInDB, result.Error.Error())
Severity: Minor
Found in pkg/pr/dao/pipelinerun.go and 1 other location - About 50 mins to fix
pkg/pr/dao/pipelinerun.go on lines 92..100

There are no issues that match your filters.

Category
Status