felixarntz/wp-psr-cache

View on GitHub

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';

Severity: Minor
Found in src/ObjectCache.php by phpmd

File ObjectCache.php has 299 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Class ObjectCache
 *
 * @package LeavesAndLove\WpPsrCache
Severity: Minor
Found in src/ObjectCache.php - About 3 hrs to fix

    ObjectCache has 24 functions (exceeds 20 allowed). Consider refactoring.
    Open

    final class ObjectCache
    {
    
        const DEFAULT_GROUP = 'default';
    
    
    Severity: Minor
    Found in src/ObjectCache.php - About 2 hrs to fix

      Avoid using undefined variables such as '$found' which will lead to PHP notices.
      Open

              $value = $this->get($key, $group, false, $found);
      Severity: Minor
      Found in src/ObjectCache.php by phpmd

      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);
      Severity: Minor
      Found in src/ObjectCache.php by phpmd

      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) {
      Severity: Minor
      Found in src/ObjectCache.php by phpmd

      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) {
      Severity: Minor
      Found in src/ObjectCache.php by phpmd

      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);
      
      
      Severity: Minor
      Found in src/ObjectCache.php - About 1 hr to fix

        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);
        
        
        Severity: Minor
        Found in src/ObjectCache.php - About 1 hr to fix

        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);
        
        
        Severity: Minor
        Found in src/ObjectCache.php - About 1 hr to fix

          Expected 1 space after FUNCTION keyword; 0 found
          Open

                  $foundValues = array_filter($values, function($value) {
          Severity: Minor
          Found in src/ObjectCache.php by phpcodesniffer

          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);
          
          
          Severity: Minor
          Found in src/ObjectCache.php - About 35 mins to fix

          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>';
          Severity: Minor
          Found in src/ObjectCache.php by phpcodesniffer

          Space after opening parenthesis of function call prohibited
          Open

                  $out[] = '<strong>Non-Persistent Cache Client:</strong> <code>' . get_class( $this->selector->selectNonPersistentCache( '' )->getClient() ) . '</code>';
          Severity: Minor
          Found in src/ObjectCache.php by phpcodesniffer

          Expected 1 space after SWITCH keyword; 0 found
          Open

                  switch($name) {
          Severity: Minor
          Found in src/ObjectCache.php by phpcodesniffer

          Expected 0 spaces before closing bracket; 1 found
          Open

                  $out[] = '<strong>Persistent Cache Client:</strong> <code>' . get_class( $this->selector->selectPersistentCache( '' )->getClient() ) . '</code><br>';
          Severity: Minor
          Found in src/ObjectCache.php by phpcodesniffer

          There must be a comment when fall-through is intentional in a non-empty case body
          Open

                      case 'global_groups':
          Severity: Minor
          Found in src/ObjectCache.php by phpcodesniffer

          Expected 1 space after SWITCH keyword; 0 found
          Open

                  switch($name) {
          Severity: Minor
          Found in src/ObjectCache.php by phpcodesniffer

          There must be a comment when fall-through is intentional in a non-empty case body
          Open

                      case 'cache_misses':
          Severity: Minor
          Found in src/ObjectCache.php by phpcodesniffer

          Expected 0 spaces before closing bracket; 1 found
          Open

                  $out[] = '<strong>Non-Persistent Cache Client:</strong> <code>' . get_class( $this->selector->selectNonPersistentCache( '' )->getClient() ) . '</code>';
          Severity: Minor
          Found in src/ObjectCache.php by phpcodesniffer
          Severity
          Category
          Status
          Source
          Language