Showing 248 of 248 total issues

Function checkMandatoryFilters has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkMandatoryFilters($searchFilters, $paramsWithOperation)
    {
        $missing = array();
        foreach (array_keys($searchFilters) as $filterName) {
            if (isset($searchFilters[$filterName])) {
Severity: Minor
Found in app/resto/core/dbfunctions/FeaturesFunctions.php - About 45 mins 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 getLogs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function getLogs($params)
    {
        $where = array();
        
        // Paginate
Severity: Minor
Found in app/resto/core/dbfunctions/LogsFunctions.php - About 45 mins 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 getWhereClause has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function getWhereClause($filtersAndJoins, $options = array())
    {
        $size = count($filtersAndJoins['filters']);

        if ($size > 0) {
Severity: Minor
Found in app/resto/core/dbfunctions/FiltersFunctions.php - About 45 mins 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

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

        if (isset($dates[1]) && !in_array($dates[1], array('', '..'))) {
            $filterKey = $model->getFilterName('end');
            $params[$filterKey] = preg_replace('/<.+?>/', '', $dates[1]);
            $model->validateFilter($filterKey, $params[$filterKey]);
        }
Severity: Minor
Found in app/resto/core/RestoQueryAnalyzer.php and 1 other location - About 45 mins to fix
app/resto/core/RestoQueryAnalyzer.php on lines 395..399

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 95.

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

        if (isset($dates[0]) && !in_array($dates[0], array('', '..'))) {
            $filterKey = $model->getFilterName('start');
            $params[$filterKey] = preg_replace('/<.+?>/', '', $dates[0]);
            $model->validateFilter($filterKey, $params[$filterKey]);
        }
Severity: Minor
Found in app/resto/core/RestoQueryAnalyzer.php and 1 other location - About 45 mins to fix
app/resto/core/RestoQueryAnalyzer.php on lines 400..404

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 95.

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

Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function __construct($context, $user, $collections, $model, $query)
Severity: Minor
Found in app/resto/core/RestoFeatureCollection.php - About 35 mins to fix

    Method getFeatureDescription has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function getFeatureDescription($context, $user, $featureId, $collection, $fields)
    Severity: Minor
    Found in app/resto/core/dbfunctions/FeaturesFunctions.php - About 35 mins to fix

      Method processSearchTerms has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          private function processSearchTerms($searchTerm, &$filters, $featureTableName, $filterName, $exclusion)
      Severity: Minor
      Found in app/resto/core/dbfunctions/FiltersFunctions.php - About 35 mins to fix

        Function hasRightsTo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function hasRightsTo($action, $params = array())
            {
        
                $rights = $this->getRights();
        
        
        Severity: Minor
        Found in app/resto/core/RestoUser.php - About 35 mins 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 setQuery has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            private function setQuery()
            {
                /*
                 * Aggregate input parameters
                 *
        Severity: Minor
        Found in app/resto/core/RestoContext.php - About 35 mins 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 uploadFiles has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            private function uploadFiles($files)
            {
                $filePaths = [];
        
                // All files will be uploaded within a dedicated directory with a random name
        Severity: Minor
        Found in app/resto/core/RestoRouter.php - About 35 mins 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 getIdFromBearer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            private function getIdFromBearer($context, $token)
            {
                $payloadObject = $context->decodeJWT($token);
        
                // Unvalid token => no auth
        Severity: Minor
        Found in app/resto/core/utils/SecurityUtil.php - About 35 mins 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 storeBase64File has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function storeBase64File($data, $outputDir, $allowedTypes = array())
            {
                try {
                    if (preg_match('/^data:image\/(\w+);base64,/', $data, $type)) {
                        $data = substr($data, strpos($data, ',') + 1);
        Severity: Minor
        Found in app/resto/core/utils/RestoUtil.php - About 35 mins 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 checkGeoJSONFeature has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function checkGeoJSONFeature($object)
            {
                // Default is nice
                $error = 'Invalid GeoJSON feature';
        
        
        Severity: Minor
        Found in app/resto/core/utils/RestoGeometryUtil.php - About 35 mins 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 setCollectionLinks has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            private function setCollectionLinks($links)
            {
                if (is_array($links)) {
                    for ($i = 0, $l = count($links); $i < $l; $i++) {
                        $this->startElement('link');
        Severity: Minor
        Found in app/resto/core/xml/ATOMFeed.php - About 35 mins 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 updateCatalog has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function updateCatalog($params, $body)
            {
        
                $facetId = $params['segments'][count($params['segments']) - 1 ];
                $facets = (new FacetsFunctions($this->context->dbDriver))->getFacets(array('id' => $facetId));
        Severity: Minor
        Found in app/resto/core/addons/STACCatalog.php - About 35 mins 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 processTriplet has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            private function processTriplet()
            {
                $filter = array();
                $not = false;
        
        
        Severity: Minor
        Found in app/resto/core/utils/FilterParser.php - About 35 mins 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 decodeJWT has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function decodeJWT($token, $acceptExpired = false)
            {
                try {
                    // Convert rJWT to JWT
                    if (count(explode('.', $token)) == 2) {
        Severity: Minor
        Found in app/resto/core/RestoContext.php - About 35 mins 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 WKTPolygonToArray has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function WKTPolygonToArray($wktPolygon)
            {
                /*
                 * Result
                 */
        Severity: Minor
        Found in app/resto/core/utils/RestoGeometryUtil.php - About 35 mins 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 storeUserProfile has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function storeUserProfile($profile, $storageInfo)
            {
                if (!is_array($profile) || !isset($profile['email'])) {
                    RestoLogUtil::httpError(400, 'Cannot save user profile - invalid user identifier');
                }
        Severity: Minor
        Found in app/resto/core/dbfunctions/UsersFunctions.php - About 35 mins 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

        Severity
        Category
        Status
        Source
        Language