Showing 158 of 158 total issues
File I18n.php
has 329 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Strata\I18n;
use Strata\Strata;
Function uuid
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public static function uuid()
{
$node = getenv('SERVER_ADDR');
if (strpos($node, ':') !== false) {
if (substr_count($node, '::')) {
- 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
Hash
has 29 functions (exceeds 20 allowed). Consider refactoring. Open
class Hash
{
/**
* Get a single value specified by $path out of $data.
Query
has 29 functions (exceeds 20 allowed). Consider refactoring. Open
class Query
{
/**
* A list of WP_Query filters. Defaults to a list of published posts
* ordered by name alphabetically unpaged.
Function extract
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public static function extract(array $data, $path)
{
if (empty($path)) {
return $data;
}
- 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 combine
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public static function combine(array $data, $keyPath, $valuePath = null, $groupPath = null)
{
if (empty($data)) {
return array();
}
- 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 _simpleOp
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
protected static function _simpleOp($op, $data, $path, $values = null)
{
$_list =& $data;
$count = count($path);
- 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 scanThemeDirectories
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
protected function scanThemeDirectories($base)
{
$tree = array("themes" => array());
$di = new \RecursiveDirectoryIterator($base);
- 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
Strata
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
class Strata extends StrataContext
{
use StrataConfigurableTrait;
/**
Consider simplifying this complex logical expression. Open
if ($op === '=' && $val && $val[0] === '/') {
if (!preg_match($val, $prop)) {
return false;
}
} elseif (($op === '=' && $prop != $val)
Function rules
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public static function rules($type, $rules, $reset = false)
{
$var = '_' . $type;
switch ($type) {
- 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
File FormHelper.php
has 294 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Strata\View\Helper;
use Strata\Model\ModelEntity;
File ModelEntity.php
has 291 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Strata\Model\CustomPostType;
use Strata\Utility\Hash;
Function expand
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public static function expand($data, $separator = '.')
{
$result = array();
$stack = array();
- 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
Request
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class Request
{
/**
* A cache of the parsed GET values in the current request.
* @var array
UrlRoute
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class UrlRoute extends Route
{
/**
* @var string The hidden key for dynamically defined callback functions.
*/
Function debug
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
function debug()
{
if (!WP_DEBUG) {
return;
}
- 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 uuid
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function uuid()
{
$node = getenv('SERVER_ADDR');
if (strpos($node, ':') !== false) {
if (substr_count($node, '::')) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (preg_match('/(.*?(?:\\b|_))(' . self::$_singular['cacheIrregular'] . ')$/i', $word, $regs)) {
self::$_cache['singularize'][$word] = $regs[1] .
substr($regs[2], 0, 1) .
substr(self::$_singular['merged']['irregular'][strtolower($regs[2])], 1);
return self::$_cache['singularize'][$word];
- 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 130.
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
if (preg_match('/(.*?(?:\\b|_))(' . self::$_plural['cacheIrregular'] . ')$/i', $word, $regs)) {
self::$_cache['pluralize'][$word] = $regs[1] .
substr($regs[2], 0, 1) .
substr(self::$_plural['merged']['irregular'][strtolower($regs[2])], 1);
return self::$_cache['pluralize'][$word];
- 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 130.
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