Function runFor
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
public function runFor(ItemFlowRepresentation $flow, Item $item) {
//
// Default values.
$continue = true;
$logParams = 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 runFor
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function runFor(ItemFlowRepresentation $flow, Item $item) {
//
// Default values.
$continue = true;
$logParams = array(
Function load
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected function load() {
//
// Avoiding multipe loads of configurations.
if($this->_config === 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"
Further reading
The method runFor() has an NPath complexity of 1184. The configured NPath complexity threshold is 200. Open
public function runFor(ItemFlowRepresentation $flow, Item $item) {
//
// Default values.
$continue = true;
$logParams = array(
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method runFor() has 139 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function runFor(ItemFlowRepresentation $flow, Item $item) {
//
// Default values.
$continue = true;
$logParams = array(
- Exclude checks
Avoid using undefined variables such as '$info' which will lead to PHP notices. Open
if(!$Defaults[GC_DEFAULTS_INSTALLED] && !self::GetValidator()->validate($jsonString, $info)) {
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$info' which will lead to PHP notices. Open
$this->_log->log(LGGR_LOG_LEVEL_ERROR, "Workflow '{$this->name()}' specification is not well formed. {$info[JV_FIELD_ERROR][JV_FIELD_MESSAGE]}");
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid unused local variables such as '$Directories'. Open
global $Directories;
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}