horizoncd/horizon

View on GitHub

Showing 440 of 677 total issues

File gitrepo_cluster.go has 1601 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: Major
Found in pkg/cluster/gitrepo/gitrepo_cluster.go - About 3 days to fix

    Function Init has 392 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func Init(ctx context.Context, flags *Flags, coreConfig *config.Config) {
    // init roles
    file, err := os.OpenFile(flags.RoleConfigFile, os.O_RDONLY, 0644)
    if err != nil {
    panic(err)
    Severity: Major
    Found in core/cmd/cmd.go - About 1 day to fix

      File controller_basic.go has 917 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: Major
      Found in core/controller/cluster/controller_basic.go - About 1 day to fix

        Method clusterGitopsRepo.UpgradeCluster has 314 lines of code (exceeds 50 allowed). Consider refactoring.
        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 1 day to fix

          Method clusterGitopsRepo.UpgradeCluster has a Cognitive Complexity of 72 (exceeds 20 allowed). Consider refactoring.
          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: Minor
          Found in pkg/cluster/gitrepo/gitrepo_cluster.go - About 1 day to fix

          Method cd.GetClusterStateV1 has a Cognitive Complexity of 70 (exceeds 20 allowed). Consider refactoring.
          Open

          func (c *cd) GetClusterStateV1(ctx context.Context,
          params *GetClusterStateParams) (clusterState *ClusterState, err error) {
          const op = "cd: get cluster status"
          defer wlog.Start(ctx, op).StopPrint()
           
           
          Severity: Minor
          Found in pkg/cd/cd.go - About 1 day to fix

          File controller.go has 774 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: Major
          Found in core/controller/template/controller.go - About 1 day to fix

            File controller.go has 768 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: Major
            Found in core/controller/pipelinerun/controller.go - About 1 day to fix

              Method controller.UpdateClusterV2 has a Cognitive Complexity of 64 (exceeds 20 allowed). Consider refactoring.
              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: Minor
              Found in core/controller/cluster/controller_basic_v2.go - About 7 hrs to fix

              Method controller.ListV2 has a Cognitive Complexity of 63 (exceeds 20 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 7 hrs to fix

              Method eventHandlerService.Start has a Cognitive Complexity of 62 (exceeds 20 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: Minor
              Found in pkg/eventhandler/eventhandler.go - About 7 hrs to fix

              Method controller.GetByFullPath has a Cognitive Complexity of 60 (exceeds 20 allowed). Consider refactoring.
              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: Minor
              Found in core/controller/group/controller.go - About 6 hrs to fix

              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

                File controller_basic_v2.go has 685 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/cluster/controller_basic_v2.go - About 6 hrs to fix

                  File cmd.go has 664 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/cmd/cmd.go - About 5 hrs to fix

                    Method controller.UpdateCluster has a Cognitive Complexity of 52 (exceeds 20 allowed). Consider refactoring.
                    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: Minor
                    Found in core/controller/cluster/controller_basic.go - About 5 hrs to fix

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

                    func (api *API) RegisterRoute(engine *gin.Engine) {
                    apiV2Group := engine.Group("/apis/core/v2")
                    apiV2Routes := route.Routes{
                    {
                    Method: http.MethodPost,
                    Severity: Major
                    Found in core/http/api/v2/cluster/routers.go - About 5 hrs to fix

                      Method controller.UpdateClusterV2 has 149 lines of code (exceeds 50 allowed). Consider refactoring.
                      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 4 hrs to fix

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

                        func (c *controller) DeleteCluster(ctx context.Context, clusterID uint, hard bool) (err error) {
                        const op = "cluster controller: delete cluster"
                        defer wlog.Start(ctx, op).StopPrint()
                         
                        // get some relevant models
                        Severity: Minor
                        Found in core/controller/cluster/controller_basic.go - About 4 hrs to fix

                        Method cd.GetClusterStateV1 has 141 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (c *cd) GetClusterStateV1(ctx context.Context,
                        params *GetClusterStateParams) (clusterState *ClusterState, err error) {
                        const op = "cd: get cluster status"
                        defer wlog.Start(ctx, op).StopPrint()
                         
                         
                        Severity: Major
                        Found in pkg/cd/cd.go - About 4 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language