core/controller/pipelinerun/controller.go
Showing 15 of 15 total issues
File controller.go
has 768 lines of code (exceeds 500 allowed). Consider refactoring. Open
Open
// Copyright © 2023 Horizoncd.//// Licensed under the Apache License, Version 2.0 (the "License");// you may not use this file except in compliance with the License.// You may obtain a copy of the License at
controller
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type controller struct { prMgr *prmanager.PRManager appMgr appmanager.Manager clusterMgr clustermanager.Manager envMgr envmanager.Manager
Method controller.executeRollback
has 88 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *controller) executeRollback(ctx context.Context, application *appmodels.Application, cluster *clustermodels.Cluster, pr *prmodels.Pipelinerun) error { // 1. get pipelinerun to rollback if pr.RollbackFrom == nil { return perror.Wrapf(herrors.ErrParamInvalid, "pipelinerun to rollback is empty")
Method controller.executeDeploy
has 67 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *controller) executeDeploy(ctx context.Context, application *appmodels.Application, cluster *clustermodels.Cluster, pr *prmodels.Pipelinerun, currentUser user.User) error { // 1. generate a JWT token for tekton callback callbackToken, err := c.tokenSvc.CreateJWTToken(strconv.Itoa(int(currentUser.GetID())), c.tokenConfig.CallbackTokenExpireIn, tokensvc.WithPipelinerunID(pr.ID))
Method controller.executeRollback
has 17 return statements (exceeds 4 allowed). Open
Open
func (c *controller) executeRollback(ctx context.Context, application *appmodels.Application, cluster *clustermodels.Cluster, pr *prmodels.Pipelinerun) error { // 1. get pipelinerun to rollback if pr.RollbackFrom == nil { return perror.Wrapf(herrors.ErrParamInvalid, "pipelinerun to rollback is empty")
Method controller.ListPRMessages
has 58 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *controller) ListPRMessages(ctx context.Context, pipelineRunID uint, query *q.Query) (int, []*PRMessage, error) { const op = "pipelinerun controller: list pr messages" defer wlog.Start(ctx, op).StopPrint()
Method controller.GetDiff
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *controller) GetDiff(ctx context.Context, pipelinerunID uint) (_ *GetDiffResponse, err error) { const op = "pipelinerun controller: get pipelinerun diff" defer wlog.Start(ctx, op).StopPrint() // 1. get pipeline
Method controller.executeDeploy
has 9 return statements (exceeds 4 allowed). Open
Open
func (c *controller) executeDeploy(ctx context.Context, application *appmodels.Application, cluster *clustermodels.Cluster, pr *prmodels.Pipelinerun, currentUser user.User) error { // 1. generate a JWT token for tekton callback callbackToken, err := c.tokenSvc.CreateJWTToken(strconv.Itoa(int(currentUser.GetID())), c.tokenConfig.CallbackTokenExpireIn, tokensvc.WithPipelinerunID(pr.ID))
Method controller.executeRestart
has 7 return statements (exceeds 4 allowed). Open
Open
func (c *controller) executeRestart(ctx context.Context, application *appmodels.Application, cluster *clustermodels.Cluster, pr *prmodels.Pipelinerun) error { // 1. update pr status to running if err := c.prMgr.PipelineRun.UpdateStatusByID(ctx, pr.ID, prmodels.StatusRunning); err != nil { return perror.Wrapf(err, "failed to update pr status, pr = %d, status = %s",
Method controller.GetDiff
has 7 return statements (exceeds 4 allowed). Open
Open
func (c *controller) GetDiff(ctx context.Context, pipelinerunID uint) (_ *GetDiffResponse, err error) { const op = "pipelinerun controller: get pipelinerun diff" defer wlog.Start(ctx, op).StopPrint() // 1. get pipeline
Method controller.calculatePrSuccessStatus
has 6 return statements (exceeds 4 allowed). Open
Open
func (c *controller) calculatePrSuccessStatus(ctx context.Context, pipelinerun *prmodels.Pipelinerun) (prmodels.PipelineStatus, error) { cluster, err := c.clusterMgr.GetByIDIncludeSoftDelete(ctx, pipelinerun.ClusterID) if err != nil { return prmodels.StatusPending, err
Method controller.StopPipelinerun
has 6 return statements (exceeds 4 allowed). Open
Open
func (c *controller) StopPipelinerun(ctx context.Context, pipelinerunID uint) (err error) { const op = "pipelinerun controller: stop pipelinerun" defer wlog.Start(ctx, op).StopPrint() pipelinerun, err := c.prMgr.PipelineRun.GetByID(ctx, pipelinerunID)
Method controller.StopPipelinerunForCluster
has 6 return statements (exceeds 4 allowed). Open
Open
func (c *controller) StopPipelinerunForCluster(ctx context.Context, clusterID uint) (err error) { const op = "pipelinerun controller: stop pipelinerun" defer wlog.Start(ctx, op).StopPrint() if err != nil {
Method controller.executeDeploy
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (c *controller) executeDeploy(ctx context.Context, application *appmodels.Application, cluster *clustermodels.Cluster, pr *prmodels.Pipelinerun, currentUser user.User) error {
Method controller.updatePrStatus
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *controller) updatePrStatus(ctx context.Context, checkrun *prmodels.CheckRun) error { pipelinerun, err := c.prMgr.PipelineRun.GetByID(ctx, checkrun.PipelineRunID) if err != nil { return err }