horizoncd/horizon

View on GitHub
core/controller/application/controller.go

Summary

Maintainability
F
3 days
Test Coverage
D
61%

Showing 18 of 18 total issues

File controller.go has 695 lines of code (exceeds 500 allowed). Consider refactoring.
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
Severity: Minor
Found in core/controller/application/controller.go - About 6 hrs to fix

    Method controller.List has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring.
    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()
     
     
    Severity: Minor
    Found in core/controller/application/controller.go - About 3 hrs to fix

    Method controller.CreateApplicationV2 has 85 lines of code (exceeds 50 allowed). Consider refactoring.
    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()
     
     
    Severity: Major
    Found in core/controller/application/controller.go - About 2 hrs to fix

      Method controller.List has 72 lines of code (exceeds 50 allowed). Consider refactoring.
      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()
       
       
      Severity: Minor
      Found in core/controller/application/controller.go - About 1 hr to fix

        Method controller.CreateApplication has 67 lines of code (exceeds 50 allowed). Consider refactoring.
        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()
         
         
        Severity: Minor
        Found in core/controller/application/controller.go - About 1 hr to fix

          Method controller.CreateApplicationV2 has 16 return statements (exceeds 4 allowed).
          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()
           
           
          Severity: Major
          Found in core/controller/application/controller.go - About 1 hr to fix

            Method controller.CreateApplication has 14 return statements (exceeds 4 allowed).
            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()
             
             
            Severity: Major
            Found in core/controller/application/controller.go - About 1 hr to fix

              Method controller.CreateApplicationV2 has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
              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()
               
               
              Severity: Minor
              Found in core/controller/application/controller.go - About 1 hr to fix

              Method controller.UpdateApplication has 55 lines of code (exceeds 50 allowed). Consider refactoring.
              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()
               
               
              Severity: Minor
              Found in core/controller/application/controller.go - About 1 hr to fix

                Method controller.UpdateApplication has 9 return statements (exceeds 4 allowed).
                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()
                 
                 
                Severity: Major
                Found in core/controller/application/controller.go - About 55 mins to fix

                  Method controller.UpdateApplicationV2 has 9 return statements (exceeds 4 allowed).
                  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()
                   
                   
                  Severity: Major
                  Found in core/controller/application/controller.go - About 55 mins to fix

                    Method controller.GetApplicationV2 has 9 return statements (exceeds 4 allowed).
                    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)
                    Severity: Major
                    Found in core/controller/application/controller.go - About 55 mins to fix

                      Method controller.DeleteApplication has 9 return statements (exceeds 4 allowed).
                      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
                      Severity: Major
                      Found in core/controller/application/controller.go - About 55 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                        if err != nil {
                        return nil, 0, perror.WithMessage(err, "failed to get groups")
                        }
                        Severity: Major
                        Found in core/controller/application/controller.go - About 45 mins to fix

                          Method controller.List has 7 return statements (exceeds 4 allowed).
                          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()
                           
                           
                          Severity: Major
                          Found in core/controller/application/controller.go - About 45 mins to fix

                            Method controller.GetApplication has 6 return statements (exceeds 4 allowed).
                            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
                            Severity: Major
                            Found in core/controller/application/controller.go - About 40 mins to fix

                              Method controller.validateTemplateInput has 5 return statements (exceeds 4 allowed).
                              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
                              Severity: Major
                              Found in core/controller/application/controller.go - About 35 mins to fix

                                Function validateApplicationName has 5 return statements (exceeds 4 allowed).
                                Open

                                func validateApplicationName(name string) error {
                                if len(name) == 0 {
                                return perror.Wrap(herrors.ErrParamInvalid, "name cannot be empty")
                                }
                                 
                                 
                                Severity: Major
                                Found in core/controller/application/controller.go - About 35 mins to fix

                                  There are no issues that match your filters.

                                  Category
                                  Status