horizoncd/horizon

View on GitHub

Showing 676 of 677 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func (a *API) UpdateRelease(c *gin.Context) {
op := "template: update release"
 
r := c.Param(_releaseParam)
var (
Severity: Major
Found in core/http/api/v2/template/apis.go and 1 other location - About 5 hrs to fix
core/http/api/v2/template/apis.go on lines 369..403

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func (a *API) DeleteRelease(c *gin.Context) {
op := "template: delete release"
 
r := c.Param(_releaseParam)
var (
Severity: Major
Found in core/http/api/v2/template/apis.go and 1 other location - About 5 hrs to fix
core/http/api/v2/template/apis.go on lines 405..434

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func (a *API) DeleteTemplate(c *gin.Context) {
op := "template: delete template"
 
t := c.Param(_templateParam)
var (
Severity: Major
Found in core/http/api/v2/template/apis.go and 1 other location - About 5 hrs to fix
core/http/api/v2/template/apis.go on lines 517..546

Similar blocks of code found in 3 locations. Consider refactoring.
Open

func handleTemplate(c *gin.Context, mgr *managerparam.Manager, r *gin.Engine,
authRecord auth.AttributesRecord, requestInfo *auth.RequestInfo) {
template, err := mgr.TemplateMgr.GetByName(c, authRecord.Name)
if err != nil {
if e, ok := perror.Cause(err).(*herrors.HorizonErrNotFound); ok && e.Source == herrors.TemplateInDB {
Severity: Major
Found in core/middleware/prehandle/prehandle.go and 2 other locations - About 5 hrs to fix
core/middleware/prehandle/prehandle.go on lines 111..135
core/middleware/prehandle/prehandle.go on lines 137..161

Similar blocks of code found in 3 locations. Consider refactoring.
Open

func handleCluster(c *gin.Context, mgr *managerparam.Manager, r *gin.Engine,
authRecord auth.AttributesRecord, requestInfo *auth.RequestInfo) {
cluster, err := mgr.ClusterMgr.GetByName(c, authRecord.Name)
if err != nil {
if e, ok := perror.Cause(err).(*herrors.HorizonErrNotFound); ok && e.Source == herrors.ClusterInDB {
Severity: Major
Found in core/middleware/prehandle/prehandle.go and 2 other locations - About 5 hrs to fix
core/middleware/prehandle/prehandle.go on lines 111..135
core/middleware/prehandle/prehandle.go on lines 206..230

Similar blocks of code found in 3 locations. Consider refactoring.
Open

func handleApplication(c *gin.Context, mgr *managerparam.Manager, r *gin.Engine,
authRecord auth.AttributesRecord, requestInfo *auth.RequestInfo) {
app, err := mgr.ApplicationMgr.GetByName(c, authRecord.Name)
if err != nil {
if e, ok := perror.Cause(err).(*herrors.HorizonErrNotFound); ok && e.Source == herrors.ApplicationInDB {
Severity: Major
Found in core/middleware/prehandle/prehandle.go and 2 other locations - About 5 hrs to fix
core/middleware/prehandle/prehandle.go on lines 137..161
core/middleware/prehandle/prehandle.go on lines 206..230

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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

      func SignRequest(ctx context.Context, request *http.Request, publicKey string, secretKey string) string {
      /*
      * StringToSign = HTTP-Verb + "\n" +
      * PATH + "\n" +
      * Content-MD5 + "\n" +
      Severity: Major
      Found in core/middleware/user/user.go and 1 other location - About 4 hrs to fix
      core/middleware/authenticate/authenticate.go on lines 158..188

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

      func SignRequest(ctx context.Context, request *http.Request, publicKey string, secretKey string) string {
      /*
      * StringToSign = HTTP-Verb + "\n" +
      * PATH + "\n" +
      * Content-MD5 + "\n" +
      Severity: Major
      Found in core/middleware/authenticate/authenticate.go and 1 other location - About 4 hrs to fix
      core/middleware/user/user.go on lines 235..265

      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

        Method controller.UpdateCluster has 141 lines of code (exceeds 50 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: Major
        Found in core/controller/cluster/controller_basic.go - About 4 hrs to fix

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

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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            func (a *API) UpdateByID(c *gin.Context) {
            regionIDStr := c.Param(_regionIDParam)
            regionID, err := strconv.ParseUint(regionIDStr, 10, 0)
            if err != nil {
            response.AbortWithRPCError(c, rpcerror.ParamError.WithErrMsg(fmt.Sprintf("invalid regionID: %s, err: %s",
            Severity: Major
            Found in core/http/api/v2/region/apis.go and 1 other location - About 4 hrs to fix
            core/http/api/v2/registry/apis.go on lines 68..95

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            func (a *API) UpdateByID(c *gin.Context) {
            idStr := c.Param(_registryIDParam)
            id, err := strconv.ParseUint(idStr, 10, 0)
            if err != nil {
            response.AbortWithRPCError(c, rpcerror.ParamError.WithErrMsg(fmt.Sprintf("invalid id: %s, err: %s",
            Severity: Major
            Found in core/http/api/v2/registry/apis.go and 1 other location - About 4 hrs to fix
            core/http/api/v2/region/apis.go on lines 58..85

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

            func (c *controller) GetClusterStatus(ctx context.Context, clusterID uint) (_ *GetClusterStatusResponse, err error) {
            const op = "cluster controller: get cluster status"
            defer wlog.Start(ctx, op).StopPrint()
             
            resp := &GetClusterStatusResponse{}
            Severity: Minor
            Found in core/controller/cluster/controller_status.go - About 4 hrs to fix

            clusterGitopsRepo has 33 methods (exceeds 20 allowed). Consider refactoring.
            Open

            type clusterGitopsRepo struct {
            gitlabLib gitlablib.Interface
            clustersGroup *gitlab.Group
            recyclingClustersGroup *gitlab.Group
            templateRepo templaterepo.TemplateRepo
            Severity: Minor
            Found in pkg/cluster/gitrepo/gitrepo_cluster.go - About 4 hrs to fix
              Severity
              Category
              Status
              Source
              Language