Showing 676 of 677 total issues
Method controller.ListTemplateByGroupID
has 5 return statements (exceeds 4 allowed). Open
func (c *controller) ListTemplateByGroupID(ctx context.Context, groupID uint, withoutCI bool) (Templates, error) {
const op = "template controller: listTemplateByGroupID"
defer wlog.Start(ctx, op).StopPrint()
if !c.groupMgr.GroupExist(ctx, groupID) {
Method controller.GetRelease
has 5 return statements (exceeds 4 allowed). Open
func (c *controller) GetRelease(ctx context.Context, releaseID uint) (*Release, error) {
const op = "template controller: getRelease"
defer wlog.Start(ctx, op).StopPrint()
release, err := c.templateReleaseMgr.GetByID(ctx, releaseID)
Method controller.DeleteRelease
has 5 return statements (exceeds 4 allowed). Open
func (c *controller) DeleteRelease(ctx context.Context, releaseID uint) error {
const op = "template controller: deleteRelease"
defer wlog.Start(ctx, op).StopPrint()
ctx = context.WithValue(ctx, hctx.TemplateOnlyRefCount, true)
Method controller.CreatePipelineRun
has 5 return statements (exceeds 4 allowed). Open
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 service.listGroupMembers
has 5 return statements (exceeds 4 allowed). Open
func (s *service) listGroupMembers(ctx context.Context, resourceID uint) ([]models.Member, error) {
var (
retMembers []models.Member
members []models.Member
err error
Method controller.List
has 5 return statements (exceeds 4 allowed). Open
func (c *controller) List(ctx context.Context, applicationID uint) (ApplicationRegion, error) {
applicationRegions, err := c.mgr.ListByApplicationID(ctx, applicationID)
if err != nil {
return nil, perror.WithMessage(err, "failed to list application regions")
}
Method controller.GetClusterStatusV2
has 5 return statements (exceeds 4 allowed). Open
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 Params.check
has 5 return statements (exceeds 4 allowed). Open
func (params *Params) check() error {
const op = "s3 params check"
if len(params.AccessKey) == 0 {
return errors.E(op, "AccessKey must be specified")
}
Function RenderOutputObject
has 5 return statements (exceeds 4 allowed). Open
func RenderOutputObject(outPutStr, templateName string,
clusterValueFiles ...gitrepo.ClusterValueFile) (interface{}, error) {
// remove the template prefix level, add Value prefix(as helm) and merge to one doc
oneMap := make(map[string]interface{})
var err error
Method service.GetCheckByResource
has 5 return statements (exceeds 4 allowed). Open
func (s *service) GetCheckByResource(ctx context.Context, resourceID uint,
resourceType string) ([]*models.Check, error) {
var (
id = resourceID
app *amodels.Application
Method dao.DeleteByID
has 5 return statements (exceeds 4 allowed). Open
func (d *dao) DeleteByID(ctx context.Context, id uint) error {
_, err := d.GetByID(ctx, id)
if err != nil {
return err
}
Method WebhookLogGenerator.makeRequestBody
has 5 return statements (exceeds 4 allowed). Open
func (w *WebhookLogGenerator) makeRequestBody(ctx context.Context, dep *messageDependency) (string, error) {
message := MessageContent{
EventID: dep.event.ID,
WebhookID: dep.webhook.ID,
EventType: dep.event.EventType,
Method OauthManager.RefreshOauthTokens
has 5 return statements (exceeds 4 allowed). Open
func (m *OauthManager) RefreshOauthTokens(ctx context.Context,
req *OauthTokensRequest) (*OauthTokensResponse, error) {
// check client secret
err := m.checkClientSecret(ctx, req)
if err != nil {
Method EnvironmentList.Less
has 5 return statements (exceeds 4 allowed). Open
func (e EnvironmentList) Less(i, j int) bool {
const pre = "pre"
const online = "online"
if e[i].Name == online {
return false
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
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method Helper.GetTagArchive
has 5 return statements (exceeds 4 allowed). Open
func (h Helper) GetTagArchive(ctx context.Context, gitURL, tagName string) (*git.Tag, error) {
URL, err := url.Parse(gitURL)
if err != nil || gitURL == "" {
return nil, perror.Wrap(herrors.ErrParamInvalid,
fmt.Sprintf("failed to parse gitlab url: %s", err))
Method OauthManager.checkRefreshToken
has 5 return statements (exceeds 4 allowed). Open
func (m *OauthManager) checkRefreshToken(ctx context.Context,
refreshToken, redirectURL string) (*tokenmodels.Token, error) {
token, err := m.tokenStore.GetByCode(ctx, refreshToken)
if err != nil {
if _, ok := perror.Cause(err).(*herrors.HorizonErrNotFound); ok {
Method helper.AcceptMR
has 5 return statements (exceeds 4 allowed). Open
func (h *helper) AcceptMR(ctx context.Context, pid interface{}, mrID int,
mergeCommitMsg *string, shouldRemoveSourceBranch *bool) (mr *gitlab.MergeRequest, err error) {
const op = "gitlab: accept mr"
defer wlog.Start(ctx, op).StopPrint()
Method controller.customizeCreateReqBuildTemplateInfo
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
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 {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method controller.InternalDeploy
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (c *controller) InternalDeploy(ctx context.Context, clusterID uint,
r *InternalDeployRequest) (_ *InternalDeployResponse, err error) {
const op = "cluster controller: internal deploy"
defer wlog.Start(ctx, op).StopPrint()
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"