horizoncd/horizon

View on GitHub

Showing 440 of 677 total issues

Method API.List has 78 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (a *API) List(c *gin.Context) {
withFullPathStr := c.Query(_withFullPath)
withFullPath, _ := strconv.ParseBool(withFullPathStr)
 
keywords := q.KeyWords{}
Severity: Major
Found in core/http/api/v2/template/apis.go - About 2 hrs to fix

    Method dao.List has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
    Open

    func (d *dao) List(ctx context.Context, query *q.Query, userID uint,
    withRegion bool, appIDs ...uint) (int, []*models.ClusterWithRegion, error) {
    var (
    clusters []*models.ClusterWithRegion
    total int64
    Severity: Minor
    Found in pkg/cluster/dao/dao.go - About 2 hrs to fix

    Method controller.List has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
    Open

    func (c *controller) List(ctx context.Context, query *q.Query) ([]*ListClusterWithFullResponse, int, error) {
    applicationIDs := make([]uint, 0)
     
    currentUser, err := common.UserFromContext(ctx)
    if err != nil {
    Severity: Minor
    Found in core/controller/cluster/controller_basic.go - About 2 hrs to fix

    Method controller.ListV2 has 75 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (c *controller) ListV2(ctx context.Context, query *q.Query, withFullPath bool) (Templates, error) {
    var (
    groupIDs []uint
    err error
    )
    Severity: Minor
    Found in core/controller/template/controller.go - About 2 hrs to fix

      Method controller.LoginOrLink has 74 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (c *controller) LoginOrLink(ctx context.Context,
      code string, state string, redirectURL string) (*usermodel.User, error) {
      bts, err := base64.StdEncoding.DecodeString(state)
      if err != nil {
      return nil, perror.Wrapf(
      Severity: Minor
      Found in core/controller/idp/controller.go - About 1 hr to fix

        Function Middleware has 74 lines of code (exceeds 50 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 1 hr to fix

          Method ArgoServer.ListResourceEvents has 73 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (argoServer *ArgoServer) ListResourceEvents(w http.ResponseWriter, r *http.Request) {
          d := []byte(`
          {
          "metadata": {
          "selfLink": "/api/v1/namespaces/test-guanggao/events",
          Severity: Minor
          Found in pkg/argocd/mock/mock.go - About 1 hr to fix

            Method WebhookLogGenerator.makeRequestBody has 73 lines of code (exceeds 50 allowed). Consider refactoring.
            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: Minor
            Found in pkg/eventhandler/wlgenerator/wlgenerator.go - About 1 hr to fix

              Method clusterGitopsRepo.GetCluster has 21 return statements (exceeds 4 allowed).
              Open

              func (g *clusterGitopsRepo) GetCluster(ctx context.Context,
              application, cluster, templateName string) (_ *ClusterFiles, err error) {
              const op = "cluster git repo: get cluster"
              defer wlog.Start(ctx, op).StopPrint()
               
               
              Severity: Major
              Found in pkg/cluster/gitrepo/gitrepo_cluster.go - About 1 hr to fix

                Method controller.UpdateCluster has 21 return statements (exceeds 4 allowed).
                Open

                func (c *controller) UpdateCluster(ctx context.Context, clusterID uint,
                r *UpdateClusterRequest, mergePatch bool) (_ *GetClusterResponse, err error) {
                const op = "cluster controller: update cluster"
                defer wlog.Start(ctx, op).StopPrint()
                 
                 
                Severity: Major
                Found in core/controller/cluster/controller_basic.go - About 1 hr to fix

                  Method controller.Rollback has 21 return statements (exceeds 4 allowed).
                  Open

                  func (c *controller) Rollback(ctx context.Context,
                  clusterID uint, r *RollbackRequest) (_ *PipelinerunIDResponse, err error) {
                  const op = "cluster controller: rollback"
                  defer wlog.Start(ctx, op).StopPrint()
                   
                   
                  Severity: Major
                  Found in core/controller/cluster/controller_operation.go - About 1 hr to fix

                    Method controller.CreateClusterV2 has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (c *controller) CreateClusterV2(ctx context.Context,
                    params *CreateClusterParamsV2) (*CreateClusterResponseV2, error) {
                    const op = "cluster controller: create cluster v2"
                    defer wlog.Start(ctx, op).StopPrint()
                     
                     
                    Severity: Minor
                    Found in core/controller/cluster/controller_basic_v2.go - About 1 hr to fix

                    Function isClusterActuallyHealthy has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func isClusterActuallyHealthy(ctx context.Context, clusterState *cd.ClusterState, image string,
                    restartTime time.Time, replicas int) bool {
                    checkReplicas := func(clusterVersion *cd.ClusterVersion) bool {
                    if replicas == 0 || len(clusterVersion.Pods) == 0 || image == "" {
                    return true
                    Severity: Minor
                    Found in core/controller/cluster/controller_status.go - About 1 hr to fix

                    Method converter.ConvertMembers has a Cognitive Complexity of 30 (exceeds 20 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: Minor
                    Found in core/controller/member/models.go - About 1 hr to fix

                    Method service.sync has 72 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (s *service) sync(ctx context.Context) {
                    log.Info(ctx, "Start to sync grafana datasource")
                     
                    logErr := func(err error) {
                    log.Errorf(ctx, "Sync grafana datasource error: %+v", err)
                    Severity: Minor
                    Found in pkg/grafana/grafana.go - About 1 hr to fix

                      Method API.Create has 72 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (a *API) Create(c *gin.Context) {
                      op := "cluster: create v2"
                      applicationIDStr := c.Param(common.ParamApplicationID)
                      applicationID, err := strconv.ParseUint(applicationIDStr, 10, 0)
                      if err != nil {
                      Severity: Minor
                      Found in core/http/api/v2/cluster/apis_basic.go - About 1 hr 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

                          Function parseContext has 71 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func parseContext(c *gin.Context) *q.Query {
                          keywords := make(map[string]interface{})
                           
                          userIDStr := c.Query(common.ClusterQueryByUser)
                          if userIDStr != "" {
                          Severity: Minor
                          Found in core/http/api/v2/cluster/apis_basic.go - About 1 hr to fix

                            Method API.RegisterRoute has 71 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (a *API) RegisterRoute(engine *gin.Engine) {
                            coreAPI := engine.Group("/apis/core/v2/groups")
                            var coreRoutes = route.Routes{
                            {
                            Method: http.MethodPost,
                            Severity: Minor
                            Found in core/http/api/v2/group/routers.go - About 1 hr to fix

                              Method API.RegisterRoute has 71 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                              func (api *API) RegisterRoute(engine *gin.Engine) {
                              apiGroup := engine.Group("/apis/core/v2")
                              var routes = route.Routes{
                              {
                              Method: http.MethodGet,
                              Severity: Minor
                              Found in core/http/api/v2/pipelinerun/routers.go - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language