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
*
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' ) {
- Read upRead up
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++) {
- Read upRead up
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
- Read upRead up
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];
Function analyze
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function analyze($params, $model)
{
/*
* Store original params
*/
- Read upRead up
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
*/
Function splitString
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public static function splitString($str)
{
$quotted = explode('"', $str);
/*
- Read upRead up
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
*/
- Read upRead up
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();
/*
Method getSummaries
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getSummaries($types, $collectionId)
{
$summaries = array();
Method __construct
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct($options = array())
{
parent::__construct($options);
/*
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;
Method __construct
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct($options = array())
{
parent::__construct($options);
/*
Method load
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function load($params = array())
{
$nbOfSegments = count($this->segments);
// Root
RestoModel
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class RestoModel
{
/*
* Model options
*/
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");
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'];
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');
}
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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');
}
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76