Showing 11 of 11 total issues
Function validate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function validate()
{
if (empty($this->path)) {
throw new PathValidationException('Paths must not be empty.');
}
- 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
Avoid using static access to class '\WPZAPP\Config\Path\PathWalker' in method 'getKey'. Open
$result = PathWalker::walk($this->getArrayCopy(), $path);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\WPZAPP\Config\Path\PathWalker' in method 'hasKey'. Open
return PathWalker::canWalk($this->getArrayCopy(), $path);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using WPZAPP\Config\Path\count() function in while loops. Open
while (count($segments) > 0) {
$key = array_shift($segments);
if (!isset($result[$key])) {
return false;
- Read upRead up
- Exclude checks
CountInLoopExpression
Since: 2.7.0
Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.
Example
class Foo {
public function bar()
{
$array = array();
for ($i = 0; count($array); $i++) {
// ...
}
}
}
Source https://phpmd.org/rules/design.html#countinloopexpression
Avoid using WPZAPP\Config\Path\count() function in while loops. Open
while (count($segments) > 0) {
$key = array_shift($segments);
if (!isset($result[$key])) {
throw new PathSegmentNotFoundException(sprintf('Segment %1$s of path %2$s does not exist on the input array.', $key, (string) $path));
- Read upRead up
- Exclude checks
CountInLoopExpression
Since: 2.7.0
Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.
Example
class Foo {
public function bar()
{
$array = array();
for ($i = 0; count($array); $i++) {
// ...
}
}
}
Source https://phpmd.org/rules/design.html#countinloopexpression
Expected 1 space after CATCH keyword; 0 found Open
} catch(ConfigValidationException $e) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
throw new PathValidationException(sprintf( 'Invalid segment %1$s of path %2$s.', $segment, $this->__toString()));
- Exclude checks
Expected 1 space after CATCH keyword; 0 found Open
} catch(ConfigValidationException $e) {
- Exclude checks
Expected 1 space after CATCH keyword; 0 found Open
} catch(PathSegmentNotFoundException $e) {
- Exclude checks
TODO found Open
// TODO: Handle the config schema.
- Exclude checks
TODO found Open
// TODO: Validate.
- Exclude checks