Method controller.UpdateClusterV2
has a Cognitive Complexity of 64 (exceeds 20 allowed). Consider refactoring.
func (c *controller) UpdateClusterV2(ctx context.Context, clusterID uint,
r *UpdateClusterRequestV2, mergePatch bool) error {
const op = "cluster controller: update cluster v2"
defer wlog.Start(ctx, op).StopPrint()
File controller_basic_v2.go
has 685 lines of code (exceeds 500 allowed). Consider refactoring.
Method controller.UpdateClusterV2
has 149 lines of code (exceeds 50 allowed). Consider refactoring.
func (c *controller) UpdateClusterV2(ctx context.Context, clusterID uint,
r *UpdateClusterRequestV2, mergePatch bool) error {
const op = "cluster controller: update cluster v2"
defer wlog.Start(ctx, op).StopPrint()
Method controller.createPipelineRun
has 124 lines of code (exceeds 50 allowed). Consider refactoring.
func (c *controller) createPipelineRun(ctx context.Context, clusterID uint,
r *CreatePipelineRunRequest) (*prmodels.Pipelinerun, error) {
defer wlog.Start(ctx, "cluster controller: create pipeline run").StopPrint()
cluster, err := c.clusterMgr.GetByID(ctx, clusterID)
Method controller.CreateClusterV2
has 122 lines of code (exceeds 50 allowed). Consider refactoring.
func (c *controller) CreateClusterV2(ctx context.Context,
params *CreateClusterParamsV2) (*CreateClusterResponseV2, error) {
const op = "cluster controller: create cluster v2"
defer wlog.Start(ctx, op).StopPrint()
Method controller.createPipelineRun
has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring.
func (c *controller) createPipelineRun(ctx context.Context, clusterID uint,
r *CreatePipelineRunRequest) (*prmodels.Pipelinerun, error) {
defer wlog.Start(ctx, "cluster controller: create pipeline run").StopPrint()
cluster, err := c.clusterMgr.GetByID(ctx, clusterID)
Method controller.GetClusterV2
has 92 lines of code (exceeds 50 allowed). Consider refactoring.
func (c *controller) GetClusterV2(ctx context.Context, clusterID uint) (*GetClusterResponseV2, error) {
const op = "cluster controller: get cluster v2"
defer wlog.Start(ctx, op).StopPrint()
Method controller.UpdateClusterV2
has 26 return statements (exceeds 4 allowed).
func (c *controller) UpdateClusterV2(ctx context.Context, clusterID uint,
r *UpdateClusterRequestV2, mergePatch bool) error {
const op = "cluster controller: update cluster v2"
defer wlog.Start(ctx, op).StopPrint()
Method controller.CreateClusterV2
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
func (c *controller) CreateClusterV2(ctx context.Context,
params *CreateClusterParamsV2) (*CreateClusterResponseV2, error) {
const op = "cluster controller: create cluster v2"
defer wlog.Start(ctx, op).StopPrint()
Method controller.CreateClusterV2
has 19 return statements (exceeds 4 allowed).
func (c *controller) CreateClusterV2(ctx context.Context,
params *CreateClusterParamsV2) (*CreateClusterResponseV2, error) {
const op = "cluster controller: create cluster v2"
defer wlog.Start(ctx, op).StopPrint()
Method controller.GetClusterV2
has 16 return statements (exceeds 4 allowed).
func (c *controller) GetClusterV2(ctx context.Context, clusterID uint) (*GetClusterResponseV2, error) {
const op = "cluster controller: get cluster v2"
defer wlog.Start(ctx, op).StopPrint()
Method controller.createPipelineRun
has 13 return statements (exceeds 4 allowed).
func (c *controller) createPipelineRun(ctx context.Context, clusterID uint,
r *CreatePipelineRunRequest) (*prmodels.Pipelinerun, error) {
defer wlog.Start(ctx, "cluster controller: create pipeline run").StopPrint()
cluster, err := c.clusterMgr.GetByID(ctx, clusterID)
Avoid deeply nested control flow statements.
} else if r.Git.Branch != "" {
gitRefType = codemodels.GitRefTypeBranch
gitRef = r.Git.Branch
}
Method controller.CreatePipelineRun
has 5 return statements (exceeds 4 allowed).
func (c *controller) CreatePipelineRun(ctx context.Context, clusterID uint,
r *CreatePipelineRunRequest) (*prmodels.PipelineBasic, error) {
const op = "pipelinerun controller: create pipelinerun"
defer wlog.Start(ctx, op).StopPrint()
Method controller.GetClusterStatusV2
has 5 return statements (exceeds 4 allowed).
func (c *controller) GetClusterStatusV2(ctx context.Context, clusterID uint) (*StatusResponseV2, error) {
const op = "cluster controller: get cluster status v2"
defer wlog.Start(ctx, op).StopPrint()
cluster, err := c.clusterMgr.GetByID(ctx, clusterID)
Method controller.customizeCreateReqBuildTemplateInfo
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
func (c *controller) customizeCreateReqBuildTemplateInfo(ctx context.Context, params *CreateClusterParamsV2,
application *appmodels.Application) (*BuildTemplateInfo, error) {
buildTemplateInfo := &BuildTemplateInfo{}
appGitRepoFile, err := c.applicationGitRepo.GetApplication(ctx, application.Name, params.Environment)
if err != nil {
Identical blocks of code found in 2 locations. Consider refactoring.
if err != nil {
if deleteErr := c.clusterGitRepo.DeleteCluster(ctx, application.Name, cluster.Name, cluster.ID); deleteErr != nil {
if _, ok := perror.Cause(deleteErr).(*herrors.HorizonErrNotFound); !ok {
err = perror.WithMessage(err, deleteErr.Error())
Identical blocks of code found in 2 locations. Consider refactoring.
if r.Git != nil {
if r.Git.Commit != "" {
gitRefType = codemodels.GitRefTypeCommit
gitRef = r.Git.Commit
} else if r.Git.Tag != "" {
core/controller/cluster/controller_build_deploy.go on lines 65..76 There are no issues that match your filters.