core/controller/application/controller.go
Showing 18 of 18 total issues
File controller.go
has 695 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
Method controller.List
has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring. Open
Open
func (c *controller) List(ctx context.Context, query *q.Query) ( listApplicationResp []*ListApplicationResponse, count int, err error) { const op = "application controller: list application" defer wlog.Start(ctx, op).StopPrint()
- Read upRead up
Method controller.CreateApplicationV2
has 85 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *controller) CreateApplicationV2(ctx context.Context, groupID uint, request *CreateOrUpdateApplicationRequestV2) (*CreateApplicationResponseV2, error) { const op = "application controller: create application v2" defer wlog.Start(ctx, op).StopPrint()
Method controller.List
has 72 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *controller) List(ctx context.Context, query *q.Query) ( listApplicationResp []*ListApplicationResponse, count int, err error) { const op = "application controller: list application" defer wlog.Start(ctx, op).StopPrint()
Method controller.CreateApplication
has 67 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *controller) CreateApplication(ctx context.Context, groupID uint, request *CreateApplicationRequest) (_ *GetApplicationResponse, err error) { const op = "application controller: create application" defer wlog.Start(ctx, op).StopPrint()
Method controller.CreateApplicationV2
has 16 return statements (exceeds 4 allowed). Open
Open
func (c *controller) CreateApplicationV2(ctx context.Context, groupID uint, request *CreateOrUpdateApplicationRequestV2) (*CreateApplicationResponseV2, error) { const op = "application controller: create application v2" defer wlog.Start(ctx, op).StopPrint()
Method controller.CreateApplication
has 14 return statements (exceeds 4 allowed). Open
Open
func (c *controller) CreateApplication(ctx context.Context, groupID uint, request *CreateApplicationRequest) (_ *GetApplicationResponse, err error) { const op = "application controller: create application" defer wlog.Start(ctx, op).StopPrint()
Method controller.CreateApplicationV2
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
Open
func (c *controller) CreateApplicationV2(ctx context.Context, groupID uint, request *CreateOrUpdateApplicationRequestV2) (*CreateApplicationResponseV2, error) { const op = "application controller: create application v2" defer wlog.Start(ctx, op).StopPrint()
- Read upRead up
Method controller.UpdateApplication
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *controller) UpdateApplication(ctx context.Context, id uint, request *UpdateApplicationRequest) (_ *GetApplicationResponse, err error) { const op = "application controller: update application" defer wlog.Start(ctx, op).StopPrint()
Method controller.UpdateApplication
has 9 return statements (exceeds 4 allowed). Open
Open
func (c *controller) UpdateApplication(ctx context.Context, id uint, request *UpdateApplicationRequest) (_ *GetApplicationResponse, err error) { const op = "application controller: update application" defer wlog.Start(ctx, op).StopPrint()
Method controller.UpdateApplicationV2
has 9 return statements (exceeds 4 allowed). Open
Open
func (c *controller) UpdateApplicationV2(ctx context.Context, id uint, request *CreateOrUpdateApplicationRequestV2) (err error) { const op = "application controller: update application v2" defer wlog.Start(ctx, op).StopPrint()
Method controller.GetApplicationV2
has 9 return statements (exceeds 4 allowed). Open
Open
func (c *controller) GetApplicationV2(ctx context.Context, id uint) (_ *GetApplicationResponseV2, err error) { const op = "application controller: get application v2" defer wlog.Start(ctx, op).StopPrint() // 1. get application in db app, err := c.applicationMgr.GetByID(ctx, id)
Method controller.DeleteApplication
has 9 return statements (exceeds 4 allowed). Open
Open
func (c *controller) DeleteApplication(ctx context.Context, id uint, hard bool) (err error) { const op = "application controller: delete application" defer wlog.Start(ctx, op).StopPrint() // 1. get application in db
Avoid deeply nested control flow statements. Open
Open
if err != nil { return nil, 0, perror.WithMessage(err, "failed to get groups") }
Method controller.List
has 7 return statements (exceeds 4 allowed). Open
Open
func (c *controller) List(ctx context.Context, query *q.Query) ( listApplicationResp []*ListApplicationResponse, count int, err error) { const op = "application controller: list application" defer wlog.Start(ctx, op).StopPrint()
Method controller.GetApplication
has 6 return statements (exceeds 4 allowed). Open
Open
func (c *controller) GetApplication(ctx context.Context, id uint) (_ *GetApplicationResponse, err error) { const op = "application controller: get application" defer wlog.Start(ctx, op).StopPrint() // 1. get application in db
Method controller.validateTemplateInput
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *controller) validateTemplateInput(ctx context.Context, template, release string, templateInput *TemplateInput) error { tr, err := c.templateReleaseMgr.GetByTemplateNameAndRelease(ctx, template, release) if err != nil { return err
Function validateApplicationName
has 5 return statements (exceeds 4 allowed). Open
Open
func validateApplicationName(name string) error { if len(name) == 0 { return perror.Wrap(herrors.ErrParamInvalid, "name cannot be empty") }