horizoncd/horizon

View on GitHub

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) {
Severity: Major
Found in core/controller/template/controller.go - About 35 mins to fix

    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)
    Severity: Major
    Found in core/controller/template/controller.go - About 35 mins to fix

      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)
      Severity: Major
      Found in core/controller/template/controller.go - About 35 mins to fix

        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()
        
        
        Severity: Major
        Found in core/controller/cluster/controller_basic_v2.go - About 35 mins to fix

          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
          Severity: Major
          Found in pkg/member/service/service.go - About 35 mins to fix

            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")
                }
            Severity: Major
            Found in core/controller/applicationregion/controller.go - About 35 mins to fix

              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)
              Severity: Major
              Found in core/controller/cluster/controller_basic_v2.go - About 35 mins to fix

                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")
                    }
                Severity: Major
                Found in lib/s3/s3.go - About 35 mins to fix

                  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
                  Severity: Major
                  Found in core/controller/cluster/controller_basic.go - About 35 mins to fix

                    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
                    Severity: Major
                    Found in pkg/pr/service/service.go - About 35 mins to fix

                      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
                          }
                      Severity: Major
                      Found in pkg/registry/dao/dao.go - About 35 mins to fix

                        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,
                        Severity: Major
                        Found in pkg/eventhandler/wlgenerator/wlgenerator.go - About 35 mins to fix

                          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 {
                          Severity: Major
                          Found in pkg/oauth/manager/manager.go - About 35 mins to fix

                            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
                            Severity: Major
                            Found in pkg/environment/models/environment.go - About 35 mins to fix

                              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
                              Severity: Minor
                              Found in pkg/webhook/dao/dao.go - About 35 mins to fix

                              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))
                              Severity: Major
                              Found in pkg/git/gitlab/gitlab.go - About 35 mins to fix

                                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 {
                                Severity: Major
                                Found in pkg/oauth/manager/manager.go - About 35 mins to fix

                                  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()
                                  
                                  
                                  Severity: Major
                                  Found in lib/gitlab/gitlab.go - About 35 mins to fix

                                    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 {
                                    Severity: Minor
                                    Found in core/controller/cluster/controller_basic_v2.go - About 35 mins to fix

                                    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()
                                    
                                    
                                    Severity: Minor
                                    Found in core/controller/cluster/controller_internal.go - About 35 mins to fix

                                    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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language