Showing 28 of 28 total issues
The class ObjectCache has an overall complexity of 76 which is very high. The configured complexity threshold is 50. Open
final class ObjectCache
{
const DEFAULT_GROUP = 'default';
- Exclude checks
File ObjectCache.php
has 299 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Class ObjectCache
*
* @package LeavesAndLove\WpPsrCache
ObjectCache
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
final class ObjectCache
{
const DEFAULT_GROUP = 'default';
Avoid using undefined variables such as '$found' which will lead to PHP notices. Open
$value = $this->get($key, $group, false, $found);
- 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 '$found' which will lead to PHP notices. Open
$value = $this->get($key, $group, false, $found);
- 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 '$found' which will lead to PHP notices. Open
if (!$found) {
- 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 '$found' which will lead to PHP notices. Open
if (!$found) {
- 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 getMultiple
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getMultiple(array $keys, string $group = self::DEFAULT_GROUP, bool $force = false): array
{
$group = $this->parseDefaultGroup($group);
$fullKeys = $this->buildKeys($keys, $group);
Function getMultiple
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getMultiple(array $keys, string $group = self::DEFAULT_GROUP, bool $force = false): array
{
$group = $this->parseDefaultGroup($group);
$fullKeys = $this->buildKeys($keys, $group);
- 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 get
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get(string $key, string $group = self::DEFAULT_GROUP, bool $force = false, bool &$found = false)
{
$group = $this->parseDefaultGroup($group);
$key = $this->keygen->generate($key, $group);
Expected 1 space after FUNCTION keyword; 0 found Open
$foundValues = array_filter($values, function($value) {
- Exclude checks
Function get
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function get(string $key, string $group = self::DEFAULT_GROUP, bool $force = false, bool &$found = false)
{
$group = $this->parseDefaultGroup($group);
$key = $this->keygen->generate($key, $group);
- 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
Space after opening parenthesis of function call prohibited Open
$out[] = '<strong>Non-Persistent Cache Client:</strong> <code>' . get_class( $this->selector->selectNonPersistentCache( '' )->getClient() ) . '</code>';
- Exclude checks
Space after opening parenthesis of function call prohibited Open
$out[] = '<strong>Non-Persistent Cache Client:</strong> <code>' . get_class( $this->selector->selectNonPersistentCache( '' )->getClient() ) . '</code>';
- Exclude checks
Expected 1 space after SWITCH keyword; 0 found Open
switch($name) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
$out[] = '<strong>Persistent Cache Client:</strong> <code>' . get_class( $this->selector->selectPersistentCache( '' )->getClient() ) . '</code><br>';
- Exclude checks
There must be a comment when fall-through is intentional in a non-empty case body Open
case 'global_groups':
- Exclude checks
Expected 1 space after SWITCH keyword; 0 found Open
switch($name) {
- Exclude checks
There must be a comment when fall-through is intentional in a non-empty case body Open
case 'cache_misses':
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
$out[] = '<strong>Non-Persistent Cache Client:</strong> <code>' . get_class( $this->selector->selectNonPersistentCache( '' )->getClient() ) . '</code>';
- Exclude checks