Showing 74 of 74 total issues
Similar blocks of code found in 12 locations. Consider refactoring. Open
Assets::PLUGIN_ROW_GROUP => [
Assets::THEME_BASE => [850 => 'plugins/row-group/rowGroup.dataTables.min.css'],
Assets::THEME_BOOTSTRAP3 => [850 => 'plugins/row-group/rowGroup.bootstrap.min.css'],
Assets::THEME_BOOTSTRAP4 => [850 => 'plugins/row-group/rowGroup.bootstrap4.min.css'],
Assets::THEME_FOUNDATION => [850 => 'plugins/row-group/rowGroup.foundation.min.css'],
- 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 93.
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
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct(View $view, string $dataTables, string $name, array $url, array $options) {
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct(string $name, bool $database = true, array $columnSchema = [], string $associationPath = '', ?FunctionExpression $functionExpression = null) {
Function setPluginSelectLanguageColumns
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function setPluginSelectLanguageColumns($columns) {
if (!in_array(getType($columns), ['string', 'array'])) {
throw new InvalidArgumentException('Columns must be a string or a array with plural translations.');
} elseif (is_array($columns)) {
$allowedKeys = ['_', '0', '1'];
- 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 setRenderer
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function setRenderer($renderer) {
$rendererType = getType($renderer);
if (!in_array($rendererType, ['string', 'array'])) {
throw new InvalidArgumentException("\$renderer must be a string or array. Found: $rendererType.");
}
- 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 setOrderFixed
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function setOrderFixed(array $orderFixed) {
if (getType(Functions::getInstance()->arrayKeyFirst($orderFixed)) === 'string') {
foreach ($orderFixed as $key => $objectItem) {
if (!in_array($key, ['pre', 'post'])) {
throw new InvalidArgumentException("You must use only 'pre' or 'post' key for objects type. Found: $key.");
- 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 getFind
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getFind(): Query {
$select = [];
$contains = [];
$columns = $this->_configBundle->Columns;
$table = $this->_configBundle->getDataTables()->getOrmTable();
- 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 setPluginSelectLanguageCells
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function setPluginSelectLanguageCells($cells) {
if (!in_array(getType($cells), ['string', 'array'])) {
throw new InvalidArgumentException('Cells must be a string or a array with plural translations.');
} elseif (is_array($cells)) {
$allowedKeys = ['_', '0', '1'];
- 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 setPluginSelectLanguageRows
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function setPluginSelectLanguageRows($rows) {
if (!in_array(getType($rows), ['string', 'array'])) {
throw new InvalidArgumentException('Rows must be a string or a array with plural translations.');
} elseif (is_array($rows)) {
$allowedKeys = ['_', '0', '1'];
- 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
Avoid too many return
statements within this method. Open
return static::CODE_SUCCESS;
Function setOrder
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function setOrder(array $order) {
Validator::getInstance()->checkKeysValueTypesOrFail($order, 'integer', 'array', '$order');
foreach ($order as $item) {
Validator::getInstance()->checkArraySizeOrFail($item, 2, 'In setOrder($order) you must pass the index and order (asc or desc). Eg.: [0, \'asc\'].');
Validator::getInstance()->checkKeysValueTypesOrFail($item, 'integer', ['integer', 'string'], '$order');
- 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 checkOrderDefault
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function checkOrderDefault(array $orderFixed) {
Validator::getInstance()->checkKeysValueTypesOrFail($orderFixed, ['integer', 'string'], 'array', '$orderFixed');
foreach ($orderFixed as $item) {
Validator::getInstance()->checkArraySizeOrFail($item, 2, "In \$orderFixed you must pass the index and after the order (asc or desc). Eg.: [0, 'asc'].");
$param1 = $item[Functions::getInstance()->arrayKeyFirst($item)];
- 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 getAssociationPath
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getAssociationPath($table, string $neededAssociation, array $currentPath = [], int $treeMax = 15) {
if (empty($currentPath)) {
$this->getAssociationAttempt = 0;
}
$this->getAssociationAttempt++;
- 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 getPropertyUsingPath
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getPropertyUsingPath(string $path, EntityInterface $entity, string $property) {
$table = $this->_configBundle->getDataTables()->getOrmTable();
if ($path === $table->getAlias()) {
return $entity->{$property};
}
- 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"