horizoncd/horizon

View on GitHub

Showing 440 of 677 total issues

Method eventHandlerService.Start has 90 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (e *eventHandlerService) Start() {
go func() {
defer func() {
if err := recover(); err != nil {
log.Errorf(e.ctx, "event handler service panic: %s", string(debug.Stack()))
Severity: Major
Found in pkg/eventhandler/eventhandler.go - About 2 hrs to fix

    Function parsePodLifeCycle has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
    Open

    func parsePodLifeCycle(pod corev1.Pod) []*LifeCycleItem {
    var lifeCycle []*LifeCycleItem
    // if DeletionTimestamp is set, pod is Terminating
    if pod.DeletionTimestamp != nil {
    lifeCycle = []*LifeCycleItem{
    Severity: Minor
    Found in pkg/cd/util.go - About 2 hrs to fix

    Method clusterGitopsRepo.UpdateCluster has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
    Open

    func (g *clusterGitopsRepo) UpdateCluster(ctx context.Context, params *UpdateClusterParams) error {
    const op = "cluster git repo: update cluster"
    defer wlog.Start(ctx, op).StopPrint()
     
    currentUser, err := common.UserFromContext(ctx)
    Severity: Minor
    Found in pkg/cluster/gitrepo/gitrepo_cluster.go - About 2 hrs to fix

    Method appGitopsRepo.CreateOrUpdateApplication has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
    Open

    func (g appGitopsRepo) CreateOrUpdateApplication(ctx context.Context,
    application string, req CreateOrUpdateRequest) error {
    const op = "gitlab repo: create or update application"
    defer wlog.Start(ctx, op).StopPrint()
     
     
    Severity: Minor
    Found in pkg/application/gitrepo/gitrepo_applicationv2.go - About 2 hrs to fix

    Method WebhookLogGenerator.Process has 88 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (w *WebhookLogGenerator) Process(ctx context.Context, events []*models.Event,
    resume bool) error {
    var (
    webhookLogs []*webhookmodels.WebhookLog
    conditionsToCreate = map[uint]map[uint]messageDependency{}
    Severity: Major
    Found in pkg/eventhandler/wlgenerator/wlgenerator.go - About 2 hrs to fix

      Method controller.executeRollback has 88 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (c *controller) executeRollback(ctx context.Context, application *appmodels.Application,
      cluster *clustermodels.Cluster, pr *prmodels.Pipelinerun) error {
      // 1. get pipelinerun to rollback
      if pr.RollbackFrom == nil {
      return perror.Wrapf(herrors.ErrParamInvalid, "pipelinerun to rollback is empty")
      Severity: Major
      Found in core/controller/pipelinerun/controller.go - About 2 hrs to fix

        manager has 23 methods (exceeds 20 allowed). Consider refactoring.
        Open

        type manager struct {
        groupDAO groupdao.DAO
        applicationDAO applicationdao.DAO
        envregionDAO envregiondao.DAO
        regionDAO regiondao.DAO
        Severity: Minor
        Found in pkg/group/manager/manager.go - About 2 hrs to fix

          Function parsePodLifeCycle has 87 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func parsePodLifeCycle(pod corev1.Pod) []*LifeCycleItem {
          var lifeCycle []*LifeCycleItem
          // if DeletionTimestamp is set, pod is Terminating
          if pod.DeletionTimestamp != nil {
          lifeCycle = []*LifeCycleItem{
          Severity: Major
          Found in pkg/cd/util.go - About 2 hrs to fix

            Function WriteTarContents has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
            Open

            func WriteTarContents(out *tar.Writer, c *chart.Chart, prefix string) error {
            base := filepath.Join(prefix, c.Name())
             
            // Pull out the dependencies of a v1 Chart, since there's no way
            // to tell the serializer to skip a field for just this use case
            Severity: Minor
            Found in pkg/templaterepo/chartutil.go - About 2 hrs to fix

            Method CreateClusterParamsV2.toClusterModel has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
            Open

            func (r *CreateClusterParamsV2) toClusterModel(application *appmodels.Application,
            er *envregionmodels.EnvironmentRegion, info *BuildTemplateInfo,
            template *templatemodels.Template, expireSeconds uint) (*models.Cluster, []*tagmodels.Tag) {
            cluster := &models.Cluster{
            ApplicationID: application.ID,
            Severity: Minor
            Found in core/controller/cluster/models_basic_v2.go - About 2 hrs to fix

            Function Middleware has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
            Open

            func Middleware(skippers ...middleware.Skipper) gin.HandlerFunc {
            return middleware.New(func(c *gin.Context) {
            // get auth record
            record, ok := c.Get(common.ContextAuthRecord)
            if !ok {
            Severity: Minor
            Found in core/middleware/admission/admission.go - About 2 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.UpdateClusterV2 has 26 return statements (exceeds 4 allowed).
              Open

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

                Method clusterGitopsRepo.UpgradeCluster has 25 return statements (exceeds 4 allowed).
                Open

                func (g *clusterGitopsRepo) UpgradeCluster(ctx context.Context,
                param *UpgradeValuesParam) (string, error) {
                const op = "cluster git repo: upgrade cluster"
                defer wlog.Start(ctx, op).StopPrint()
                currentUser, err := common.UserFromContext(ctx)
                Severity: Major
                Found in pkg/cluster/gitrepo/gitrepo_cluster.go - About 2 hrs to fix

                  Method controller.InternalDeployV2 has 25 return statements (exceeds 4 allowed).
                  Open

                  func (c *controller) InternalDeployV2(ctx context.Context, clusterID uint,
                  r *InternalDeployRequestV2) (_ *InternalDeployResponseV2, err error) {
                  const op = "cluster controller: internal deploy v2"
                  defer wlog.Start(ctx, op).StopPrint()
                   
                   
                  Severity: Major
                  Found in core/controller/cluster/controller_internal_v2.go - About 2 hrs to fix

                    Function Middleware has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func Middleware(keys authenticate.KeysConfig, skippers ...middleware.Skipper) gin.HandlerFunc {
                    return middleware.New(func(c *gin.Context) {
                    r := c.Request
                    log.Infof(c, "request url path: %v", r.URL)
                     
                     
                    Severity: Minor
                    Found in core/middleware/authenticate/authenticate.go - About 2 hrs to fix

                    Method Collector.getClustersAndApps has 81 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (collector *Collector) getClustersAndApps() ([]*item, []*appWithTags) {
                    ctx := context.Background()
                     
                    // dummy user
                    // nolint
                    Severity: Major
                    Found in pkg/cluster/metrics/metrics.go - About 2 hrs to fix

                      File apis_operation.go has 509 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/http/api/v2/cluster/apis_operation.go - About 2 hrs to fix

                        Method controller.GetByFullPath has 24 return statements (exceeds 4 allowed).
                        Open

                        func (c *controller) GetByFullPath(ctx context.Context,
                        resourcePath string, resourceType string) (*service.Child, error) {
                        const op = "get record by fullPath"
                        defer wlog.Start(ctx, op).StopPrint()
                         
                         
                        Severity: Major
                        Found in core/controller/group/controller.go - About 2 hrs to fix

                          Method converter.ConvertMembers has 79 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (c *converter) ConvertMembers(ctx context.Context, members []models.Member) ([]Member, error) {
                          var userIDs []uint
                           
                          for _, member := range members {
                          if member.MemberType != models.MemberUser {
                          Severity: Major
                          Found in core/controller/member/models.go - About 2 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language