Showing 158 of 158 total issues
Function sort
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public static function sort(array $data, $path, $dir = 'asc', $type = 'regular')
{
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
Method tokenize
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function tokenize($data, $separator = ',', $leftBound = '(', $rightBound = ')')
{
if (empty($data)) {
return array();
}
FormHelper
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class FormHelper extends Helper
{
/**
* @var Strata\Controller\Request The active request
*/
Method cleanInsert
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function cleanInsert($str, $options)
{
$clean = $options['clean'];
if (!$clean) {
return $str;
Method saveWPGettextFunctions
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function saveWPGettextFunctions(array $functions, Translations $translations, $file = '')
{
foreach ($this->getFunctions() as $function) {
list($name, $line, $args) = $function;
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (!isset(self::$_plural['cacheUninflected']) || !isset(self::$_plural['cacheIrregular'])) {
self::$_plural['cacheUninflected'] = '(?:' . implode('|', self::$_plural['merged']['uninflected']) . ')';
self::$_plural['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$_plural['merged']['irregular'])) . ')';
}
- 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 124.
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 (!isset(self::$_singular['cacheUninflected']) || !isset(self::$_singular['cacheIrregular'])) {
self::$_singular['cacheUninflected'] = '(?:' . implode('|', self::$_singular['merged']['uninflected']) . ')';
self::$_singular['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$_singular['merged']['irregular'])) . ')';
}
- 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 124.
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
Function wordWrap
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public static function wordWrap($text, $width = 72, $break = "\n", $cut = false)
{
if ($cut) {
$parts = array();
while (mb_strlen($text) > 0) {
- 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 nest
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public static function nest(array $data, $options = array())
{
if (!$data) {
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
Method nest
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function nest(array $data, $options = array())
{
if (!$data) {
return $data;
}
Method sort
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function sort(array $data, $path, $dir = 'asc', $type = 'regular')
{
if (empty($data)) {
return array();
}
Method setCurrentLocaleByContext
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setCurrentLocaleByContext()
{
if (function_exists('apply_filters')) {
// Give a chance for plugins to override this decision
$locale = null;
Method input
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function input($name, $options = array())
{
$options += array(
"type" => "text",
"id" => $this->id($name),
Method combine
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function combine(array $data, $keyPath, $valuePath = null, $groupPath = null)
{
if (empty($data)) {
return array();
}
Function normalize
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public static function normalize(array $data, $assoc = true)
{
$keys = array_keys($data);
$count = count($keys);
$numeric = true;
- 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 remove
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public static function remove(array $data, $path)
{
if (strpos($path, '[') === false) {
$tokens = explode('.', $path);
} else {
- 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 registerTaxonomy
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function registerTaxonomy(Taxonomy $taxonomy)
{
$labelParser = new LabelParser($taxonomy);
$labelParser->parse();
$singular = $labelParser->singular();
Method insert
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function insert($str, $data, $options = array())
{
$defaults = array(
'before' => ':', 'after' => null, 'escape' => '\\', 'format' => null, 'clean' => false
);
Function test
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function test($value, $context)
{
if ($this->hasConfig("if") && !is_null($this->getConfig("if"))) {
$request = Strata::router()->getCurrentController()->request;
foreach ($this->getConfig("if") as $key => $expectedValue) {
- 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 contains
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function contains(array $data, array $needle)
{
if (empty($data) || empty($needle)) {
return false;
}
- 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"