Showing 247 of 247 total issues

File UsersFunctions.php has 334 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/*
 * Copyright 2018 Jérôme Gasperi
 *
Severity: Minor
Found in app/resto/core/dbfunctions/UsersFunctions.php - About 4 hrs to fix

    Function process has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        public function process($method, $path, $query)
        {
    
            // Special case for doc generation
            if ( $path === '/_routes' ) {
    Severity: Minor
    Found in app/resto/core/RestoRouter.php - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function keywordsFromFacets has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        private function keywordsFromFacets($properties, $facetCategory, $model)
        {
            $parentId = null;
            $keywords = array();
            for ($i = 0, $ii = count($facetCategory); $i < $ii; $i++) {
    Severity: Minor
    Found in app/resto/core/addons/Tag.php - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function load has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        private function load($params = array())
        {
            $nbOfSegments = count($this->segments);
    
            // Root
    Severity: Minor
    Found in app/resto/core/addons/STAC.php - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method setCatalogsLinksFromFacet has 86 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function setCatalogsLinksFromFacet($params)
        {
            $nbOfSegments = count($this->segments);
            $leafValue = $this->segments[$nbOfSegments - 1];
            
    Severity: Major
    Found in app/resto/core/addons/STAC.php - About 3 hrs to fix

      Function analyze has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          public function analyze($params, $model)
          {
              /*
               * Store original params
               */
      Severity: Minor
      Found in app/resto/core/RestoQueryAnalyzer.php - About 3 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method search has 85 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function search($context, $user, $model, $collections, $paramsWithOperation, $sorting)
          {
              /*
               * Check that mandatory filters are set
               */
      Severity: Major
      Found in app/resto/core/dbfunctions/FeaturesFunctions.php - About 3 hrs to fix

        Function splitString has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function splitString($str)
            {
                $quotted = explode('"', $str);
        
                /*
        Severity: Minor
        Found in app/resto/core/utils/RestoUtil.php - About 3 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function search has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            public function search($context, $user, $model, $collections, $paramsWithOperation, $sorting)
            {
                /*
                 * Check that mandatory filters are set
                 */
        Severity: Minor
        Found in app/resto/core/dbfunctions/FeaturesFunctions.php - About 3 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method getRootCatalogLinks has 78 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getRootCatalogLinks($minMatch)
            {
                $links = array();
        
                /*
        Severity: Major
        Found in app/resto/core/utils/STACUtil.php - About 3 hrs to fix

          Method getSummaries has 78 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getSummaries($types, $collectionId)
              {
                  
                  $summaries = array();
          
          
          Severity: Major
          Found in app/resto/core/dbfunctions/FacetsFunctions.php - About 3 hrs to fix

            Method __construct has 77 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function __construct($options = array())
                {
                    parent::__construct($options);
            
                    /*
            Severity: Major
            Found in app/resto/core/models/LandCoverModel.php - About 3 hrs to fix

              Method hello has 72 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function hello()
                  {
                      
                      $minMatch = isset($this->context->addons['STAC']['options']['minMatch']) && is_int($this->context->addons['STAC']['options']['minMatch']) ? $this->context->addons['STAC']['options']['minMatch'] : 0;
                     
              Severity: Major
              Found in app/resto/core/api/ServicesAPI.php - About 2 hrs to fix

                Method __construct has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function __construct($options = array())
                    {
                        parent::__construct($options);
                
                        /*
                Severity: Major
                Found in app/resto/core/models/DefaultModel.php - About 2 hrs to fix

                  Method load has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function load($params = array())
                      {
                          $nbOfSegments = count($this->segments);
                  
                          // Root
                  Severity: Major
                  Found in app/resto/core/addons/STAC.php - About 2 hrs to fix

                    RestoModel has 24 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    abstract class RestoModel
                    {
                        /*
                         * Model options
                         */
                    Severity: Minor
                    Found in app/resto/core/RestoModel.php - About 2 hrs to fix

                      File FacetsFunctions.php has 275 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      <?php
                      /*
                       * Copyright 2018 Jérôme Gasperi
                       *
                       * Licensed under the Apache License, version 2.0 (the "License");
                      Severity: Minor
                      Found in app/resto/core/dbfunctions/FacetsFunctions.php - About 2 hrs to fix

                        Method toArray has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function toArray()
                            {
                        
                                $osDescription = $this->osDescription[$this->context->lang] ?? $this->osDescription['en'];
                        
                        
                        Severity: Major
                        Found in app/resto/core/RestoCollection.php - About 2 hrs to fix

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

                              public function addUserToGroup($params, $userid)
                              {
                                  if (! isset($params['id'])) {
                                      RestoLogUtil::httpError(400, 'Missing mandatory group identifier');
                                  }
                          Severity: Major
                          Found in app/resto/core/dbfunctions/GroupsFunctions.php and 1 other location - About 2 hrs to fix
                          app/resto/core/dbfunctions/GroupsFunctions.php on lines 186..208

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 131.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

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

                              public function removeUserFromGroup($params, $userid)
                              {
                                  if (! isset($params['id'])) {
                                      RestoLogUtil::httpError(400, 'Missing mandatory group identifier');
                                  }
                          Severity: Major
                          Found in app/resto/core/dbfunctions/GroupsFunctions.php and 1 other location - About 2 hrs to fix
                          app/resto/core/dbfunctions/GroupsFunctions.php on lines 156..178

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 131.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Severity
                          Category
                          Status
                          Source
                          Language