horizoncd/horizon

View on GitHub

Showing 676 of 677 total issues

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

func (a *API) CreateApplicationClusterMember(c *gin.Context) {
resourceIDStr := c.Param(_paramApplicationClusterID)
uintID, err := strconv.ParseUint(resourceIDStr, 10, 0)
if err != nil {
response.AbortWithRequestError(c, common.InvalidRequestParam,
Severity: Major
Found in core/http/api/v2/member/apis.go and 2 other locations - About 3 hrs to fix
core/http/api/v2/member/apis.go on lines 58..90
core/http/api/v2/member/apis.go on lines 92..124

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

func (a *API) CreateApplicationMember(c *gin.Context) {
resourceIDStr := c.Param(_paramApplicationID)
uintID, err := strconv.ParseUint(resourceIDStr, 10, 0)
if err != nil {
response.AbortWithRequestError(c, common.InvalidRequestParam,
Severity: Major
Found in core/http/api/v2/member/apis.go and 2 other locations - About 3 hrs to fix
core/http/api/v2/member/apis.go on lines 58..90
core/http/api/v2/member/apis.go on lines 126..158

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

func (a *API) CreateGroupMember(c *gin.Context) {
resourceIDStr := c.Param(_paramGroupID)
uintID, err := strconv.ParseUint(resourceIDStr, 10, 0)
if err != nil {
response.AbortWithRequestError(c, common.InvalidRequestParam,
Severity: Major
Found in core/http/api/v2/member/apis.go and 2 other locations - About 3 hrs to fix
core/http/api/v2/member/apis.go on lines 92..124
core/http/api/v2/member/apis.go on lines 126..158

Method clusterGitopsRepo.CreateCluster has 117 lines of code (exceeds 50 allowed). Consider refactoring.
Open

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

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

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

      func (*deployment) getDeploy(node *v1alpha1.ResourceNode,
      factory dynamicinformer.DynamicSharedInformerFactory) (*v1.Deployment, error) {
      obj, err := factory.ForResource(GVRDeployment).Lister().ByNamespace(node.Namespace).Get(node.Name)
      if err != nil {
      return nil,
      Severity: Major
      Found in pkg/workload/deployment/deployment.go and 1 other location - About 3 hrs to fix
      pkg/workload/statefulset/statefulset.go on lines 63..91

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

      func (*statefulsets) getStatefulSet(node *v1alpha1.ResourceNode,
      factory dynamicinformer.DynamicSharedInformerFactory) (*v1.StatefulSet, error) {
      obj, err := factory.ForResource(GVRStatefulSet).Lister().ByNamespace(node.Namespace).Get(node.Name)
      if err != nil {
      return nil,
      Severity: Major
      Found in pkg/workload/statefulset/statefulset.go and 1 other location - About 3 hrs to fix
      pkg/workload/deployment/deployment.go on lines 67..95

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

      func validatingContentMD5(ctx context.Context, r *http.Request) error {
      data, err := ioutil.ReadAll(r.Body)
      if err != nil {
      log.Errorf(ctx, err.Error())
      return err
      Severity: Major
      Found in core/middleware/authenticate/authenticate.go and 1 other location - About 3 hrs to fix
      core/middleware/user/user.go on lines 208..233

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

      func validatingContentMD5(ctx context.Context, r *http.Request) error {
      data, err := ioutil.ReadAll(r.Body)
      if err != nil {
      log.Errorf(ctx, err.Error())
      return err
      Severity: Major
      Found in core/middleware/user/user.go and 1 other location - About 3 hrs to fix
      core/middleware/authenticate/authenticate.go on lines 131..156

      Method Cleaner.eventNeedClean has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring.
      Open

      func (c *Cleaner) eventNeedClean(ctx context.Context, event *models.Event, current time.Time) bool {
      rules := c.eventRules[event.EventType]
      for _, rule := range rules {
      if current.Before(event.CreatedAt.Add(rule.TTL)) {
      continue
      Severity: Minor
      Found in pkg/jobs/clean/cleaner.go - About 3 hrs to fix

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

      func (c *controller) createPipelineRun(ctx context.Context, clusterID uint,
      r *CreatePipelineRunRequest) (*prmodels.Pipelinerun, error) {
      defer wlog.Start(ctx, "cluster controller: create pipeline run").StopPrint()
       
      cluster, err := c.clusterMgr.GetByID(ctx, clusterID)
      Severity: Minor
      Found in core/controller/cluster/controller_basic_v2.go - About 3 hrs to fix

      Method controller.Deploy has 110 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

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

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

        func (a *API) SearchChildren(c *gin.Context) {
        groupID := c.Query(_paramGroupID)
        intID, err := strconv.ParseUint(groupID, 10, 0)
        if err != nil {
        response.AbortWithRequestError(c, common.InvalidRequestParam, fmt.Sprintf("invalid param, groupID: %s", groupID))
        Severity: Major
        Found in core/http/api/v2/group/apis.go and 1 other location - About 3 hrs to fix
        core/http/api/v2/group/apis.go on lines 296..326

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

        func (a *API) SearchGroups(c *gin.Context) {
        groupID := c.Query(_paramGroupID)
        intID, err := strconv.ParseUint(groupID, 10, 0)
        if err != nil {
        response.AbortWithRequestError(c, common.InvalidRequestParam, fmt.Sprintf("invalid param, groupID: %s", groupID))
        Severity: Major
        Found in core/http/api/v2/group/apis.go and 1 other location - About 3 hrs to fix
        core/http/api/v2/group/apis.go on lines 263..293

        Method appGitopsRepo.CreateOrUpdateApplication has 108 lines of code (exceeds 50 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: Major
        Found in pkg/application/gitrepo/gitrepo_applicationv2.go - About 3 hrs to fix

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

          type CheckDAO interface {
          // Create create a check
          Create(ctx context.Context, check *models.Check) (*models.Check, error)
          // Update check run
          UpdateByID(ctx context.Context, checkRunID uint, newCheckRun *models.CheckRun) error
          Severity: Major
          Found in pkg/pr/dao/check.go and 1 other location - About 3 hrs to fix
          pkg/pr/manager/check.go on lines 16..26

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

          type CheckManager interface {
          // Create create a check
          Create(ctx context.Context, check *models.Check) (*models.Check, error)
          // Update check run
          UpdateByID(ctx context.Context, checkRunID uint, newCheckRun *models.CheckRun) error
          Severity: Major
          Found in pkg/pr/manager/check.go and 1 other location - About 3 hrs to fix
          pkg/pr/dao/check.go on lines 13..23

          Method controller.InternalDeploy has 107 lines of code (exceeds 50 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: Major
          Found in core/controller/cluster/controller_internal.go - About 3 hrs to fix

            Method WebhookLogGenerator.Process has a Cognitive Complexity of 38 (exceeds 20 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: Minor
            Found in pkg/eventhandler/wlgenerator/wlgenerator.go - About 3 hrs to fix

            Method controller.InternalDeployV2 has a Cognitive Complexity of 38 (exceeds 20 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: Minor
            Found in core/controller/cluster/controller_internal_v2.go - About 3 hrs to fix
            Severity
            Category
            Status
            Source
            Language