Showing 47 of 47 total issues
Avoid using undefined variables such as '$map' which will lead to PHP notices. Open
$this->_mapIterable($postFieldKeyMap, [$this, '_validatePostFieldKeyMapping'], null, null, $map);
- 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
Method _buildSelectSql
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
$columns,
$tables,
$joins = [],
LogicalExpressionInterface $where = null,
$ordering = null,
Method _extractPostIdsFromInExpression
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _extractPostIdsFromInExpression(LogicalExpressionInterface $expression)
{
$postIds = [];
$isPostIdField = false;
$pEntity = $this->_getPostEntityName();
Method _extractPostIdsFromBetweenExpression
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _extractPostIdsFromBetweenExpression(LogicalExpressionInterface $expression)
{
$isPostIdField = false;
$pEntity = $this->_getPostEntityName();
$pIdField = $this->_getPostIdFieldName();
Function _normalizeWpPostDataArray
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function _normalizeWpPostDataArray($postData)
{
// If an array or traversable, then meta data can be extracted. Forward to the other method
if (is_array($postData) || $postData instanceof Traversable) {
return $this->_normalizeWpPostDataAndMeta($postData);
- 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 _extractPostIdsFromBetweenExpression
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function _extractPostIdsFromBetweenExpression(LogicalExpressionInterface $expression)
{
$isPostIdField = false;
$pEntity = $this->_getPostEntityName();
$pIdField = $this->_getPostIdFieldName();
- 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 _extractPostIdsFromInExpression
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function _extractPostIdsFromInExpression(LogicalExpressionInterface $expression)
{
$postIds = [];
$isPostIdField = false;
$pEntity = $this->_getPostEntityName();
- 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 __construct
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
wpdb $wpdb,
TemplateInterface $expressionTemplate,
MapFactoryInterface $factory,
$tables,
$fieldColumnMap,
Function _normalizeWpPostDataValue
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function _normalizeWpPostDataValue($value)
{
if ($value instanceof TermInterface && !($value instanceof LiteralTermInterface)) {
throw $this->_createInvalidArgumentException(
$this->__('Only literal terms are supported for native WP operations'),
- 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 _extractPostIdsFromEqualsExpression
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function _extractPostIdsFromEqualsExpression(LogicalExpressionInterface $expression = null)
{
$postIds = [];
$isPostIdField = false;
$pEntity = $this->_getPostEntityName();
- 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 _init
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
wpdb $wpdb,
TemplateInterface $expressionTemplate,
MapFactoryInterface $factory,
$tables,
$fieldColumnMap,
Method _buildDeleteSql
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
$table,
LogicalExpressionInterface $condition = null,
$ordering = null,
$limit = null,
$offset = null,
Method _buildUpdateSql
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
$table,
$changeSet,
LogicalExpressionInterface $condition = null,
$ordering = null,
$limit = null,
Function _preProcessChangeSet
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function _preProcessChangeSet($changeSet, &$hashMap = [])
{
if ($hashMap === null) {
$hashMap = [];
}
- 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 _mapIterable
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$iterable,
$callback,
$start = null,
$count = null,
array &$results = null
Method _mapIterable
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$iterable,
$callback,
$start = null,
$count = null,
array &$results = null
The method __construct has a boolean flag argument $insertBulk, which is a certain sign of a Single Responsibility Principle violation. Open
public function __construct(wpdb $wpdb, $table, $fieldColumnMap, $insertBulk = true)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method _init has a boolean flag argument $insertBulk, which is a certain sign of a Single Responsibility Principle violation. Open
protected function _init(wpdb $wpdb, $table, $fieldColumnMap, $insertBulk = true)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Avoid unused local variables such as '$_idx'. Open
foreach ($condition->getTerms() as $_idx => $_term) {
- 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
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
The method __ is not named in camelCase. Open
abstract protected function __($string, $args = [], $context = null);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}