Function _curry2
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Invalid
function _curry2($fn) {
return function($a = null, $b = null) use ($fn) {
$a__ = _isPlaceholder($a);
$b__ = _isPlaceholder($b);
$args = func_get_args();
- 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
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 6 and the first side effect is on line 3. Open
<?php
- Exclude checks
Avoid variables with short names like $fn. Configured minimum length is 3. Open
function _curry2($fn) {
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $_b. Configured minimum length is 3. Open
return $a__ ? $fn : _curry1(function ($_b) use ($fn, $a) {
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $_a. Configured minimum length is 3. Open
return _curry1(function ($_a) use($fn, $b) { return $fn($_a, $b); });
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $a. Configured minimum length is 3. Open
return function($a = null, $b = null) use ($fn) {
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $b. Configured minimum length is 3. Open
return function($a = null, $b = null) use ($fn) {
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Expected 1 space after FUNCTION keyword; 0 found Open
return function(...$args) use ($fn) { return _curry2($fn)(...$args); };
- Exclude checks
Each PHP statement must be on a line by itself Open
return _curry1(function ($_b) use($fn, $a) { return $fn($a, $_b); });
- Exclude checks
Each PHP statement must be on a line by itself Open
return function(...$args) use ($fn) { return _curry2($fn)(...$args); };
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
return $a__ ? $fn : _curry1(function ($_b) use ($fn, $a) {
- Exclude checks
Each PHP statement must be on a line by itself Open
return _curry1(function ($_a) use($fn, $b) { return $fn($_a, $b); });
- Exclude checks
Expected 1 space after USE keyword; found 0 Open
return _curry1(function ($_a) use($fn, $b) { return $fn($_a, $b); });
- Exclude checks
Expected 1 space after USE keyword; found 0 Open
return _curry1(function ($_b) use($fn, $a) { return $fn($a, $_b); });
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
return function(...$args) use ($fn) { return _curry2($fn)(...$args); };
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
return function($a = null, $b = null) use ($fn) {
- Exclude checks
Inline control structures are not allowed Open
} else
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 12 Open
if ($a__ && $b__) {
- Exclude checks
Expected 1 space after ELSE keyword; newline found Open
} else
- Exclude checks
Opening brace should be on a new line Open
function _curry2($fn) {
- Exclude checks
Usage of ELSE IF is discouraged; use ELSEIF instead Open
} else if ($a__) {
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 12 Open
} else if($b__) {
- Exclude checks
Line indented incorrectly; expected at least 20 spaces, found 16 Open
return _curry1(function ($_a) use($fn, $b) { return $fn($_a, $b); });
- Exclude checks
Usage of ELSE IF is discouraged; use ELSEIF instead Open
} else if($b__) {
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
} else if($b__) {
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 8 Open
default:
- Exclude checks
Opening brace must be the last content on the line Open
return function(...$args) use ($fn) { return _curry2($fn)(...$args); };
- Exclude checks
Line indented incorrectly; expected at least 20 spaces, found 16 Open
return $fn;
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 8 Open
case 1:
- Exclude checks
Closing brace must be on a line by itself Open
return _curry1(function ($_a) use($fn, $b) { return $fn($_a, $b); });
- Exclude checks
Opening brace must be the last content on the line Open
return _curry1(function ($_b) use($fn, $a) { return $fn($a, $_b); });
- Exclude checks
Closing brace must be on a line by itself Open
return _curry1(function ($_b) use($fn, $a) { return $fn($a, $_b); });
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 12 Open
} else if ($a__) {
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 8 Open
case 0:
- Exclude checks
Closing brace must be on a line by itself Open
return function(...$args) use ($fn) { return _curry2($fn)(...$args); };
- Exclude checks
Line indented incorrectly; expected at least 20 spaces, found 16 Open
return _curry1(function ($_b) use($fn, $a) { return $fn($a, $_b); });
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 12 Open
} else
- Exclude checks
Opening brace must be the last content on the line Open
return _curry1(function ($_a) use($fn, $b) { return $fn($_a, $b); });
- Exclude checks
The variable $_a is not named in camelCase. Open
function _curry2($fn) {
return function($a = null, $b = null) use ($fn) {
$a__ = _isPlaceholder($a);
$b__ = _isPlaceholder($b);
$args = func_get_args();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $a__ is not named in camelCase. Open
function _curry2($fn) {
return function($a = null, $b = null) use ($fn) {
$a__ = _isPlaceholder($a);
$b__ = _isPlaceholder($b);
$args = func_get_args();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $b__ is not named in camelCase. Open
function _curry2($fn) {
return function($a = null, $b = null) use ($fn) {
$a__ = _isPlaceholder($a);
$b__ = _isPlaceholder($b);
$args = func_get_args();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $a__ is not named in camelCase. Open
function _curry2($fn) {
return function($a = null, $b = null) use ($fn) {
$a__ = _isPlaceholder($a);
$b__ = _isPlaceholder($b);
$args = func_get_args();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $a__ is not named in camelCase. Open
function _curry2($fn) {
return function($a = null, $b = null) use ($fn) {
$a__ = _isPlaceholder($a);
$b__ = _isPlaceholder($b);
$args = func_get_args();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $b__ is not named in camelCase. Open
function _curry2($fn) {
return function($a = null, $b = null) use ($fn) {
$a__ = _isPlaceholder($a);
$b__ = _isPlaceholder($b);
$args = func_get_args();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $a__ is not named in camelCase. Open
function _curry2($fn) {
return function($a = null, $b = null) use ($fn) {
$a__ = _isPlaceholder($a);
$b__ = _isPlaceholder($b);
$args = func_get_args();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_b is not named in camelCase. Open
function _curry2($fn) {
return function($a = null, $b = null) use ($fn) {
$a__ = _isPlaceholder($a);
$b__ = _isPlaceholder($b);
$args = func_get_args();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_b is not named in camelCase. Open
function _curry2($fn) {
return function($a = null, $b = null) use ($fn) {
$a__ = _isPlaceholder($a);
$b__ = _isPlaceholder($b);
$args = func_get_args();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $b__ is not named in camelCase. Open
function _curry2($fn) {
return function($a = null, $b = null) use ($fn) {
$a__ = _isPlaceholder($a);
$b__ = _isPlaceholder($b);
$args = func_get_args();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}