PHPSocialNetwork/phpfastcache

View on GitHub

Showing 142 of 142 total issues

Function getItem has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

    public function getItem($key)
    {
        if (\is_string($key)) {
            /**
             * Replace array_key_exists by isset
Severity: Minor
Found in lib/Phpfastcache/Core/Pool/CacheItemPoolTrait.php - About 7 hrs 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

Function getPath has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

    public function getPath($readonly = false): string
    {
        /**
         * Get the base system temporary directory
         */
Severity: Minor
Found in lib/Phpfastcache/Core/Pool/IO/IOHelperTrait.php - About 6 hrs 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

ActOnAll has 44 functions (exceeds 20 allowed). Consider refactoring.
Open

class ActOnAll
{
    /**
     * @var ExtendedCacheItemPoolInterface[]
     */
Severity: Minor
Found in lib/Phpfastcache/Helper/ActOnAll.php - About 6 hrs to fix

    Function findClasses has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

        protected static function findClasses(string $path): array
        {
            $contents = \file_get_contents($path);
            $tokens = \token_get_all($contents);
            $classes = [];
    Severity: Minor
    Found in lib/Phpfastcache/Util/ClassNamespaceResolverTrait.php - About 5 hrs 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

    File CacheManager.php has 327 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     *
     * This file is part of phpFastCache.
     *
    Severity: Minor
    Found in lib/Phpfastcache/CacheManager.php - About 3 hrs to fix

      ConfigurationOption has 31 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class ConfigurationOption extends ArrayObject implements ConfigurationOptionInterface
      {
          /**
           * @var bool
           */
      Severity: Minor
      Found in lib/Phpfastcache/Config/ConfigurationOption.php - About 3 hrs to fix

        The class ConfigurationOption has an overall complexity of 50 which is very high. The configured complexity threshold is 50.
        Open

        class ConfigurationOption extends ArrayObject implements ConfigurationOptionInterface
        {
            /**
             * @var bool
             */

        Since: PHPMD 0.2.5

        The Weighted Method Count (WMC) of a class is a good indicator of how much time and effort is required to modify and maintain this class. The WMC metric is defined as the sum of complexities of all methods declared in a class. A large number of methods also means that this class has a greater potential impact on derived classes.

        Example:

        class Foo {
              public function bar() {
                  if ($a == $b)  {
                      if ($a1 == $b1) {
                          fiddle();
                      } elseif ($a2 == $b2) {
                          fiddle();
                      } else {
                      }
                  }
              }
              public function baz() {
                  if ($a == $b) {
                      if ($a1 == $b1) {
                          fiddle();
                      } elseif ($a2 == $b2) {
                          fiddle();
                      } else {
                      }
                  }
              }
              // Several other complex methods
          }

        Source: http://phpmd.org/rules/codesize.txt

        The class ActOnAll has 28 non-getter- and setter-methods. Consider refactoring ActOnAll to keep number of methods under 25.
        Open

        class ActOnAll
        {
            /**
             * @var ExtendedCacheItemPoolInterface[]
             */
        Severity: Minor
        Found in lib/Phpfastcache/Helper/ActOnAll.php by phpmd

        Since: PHPMD 0.1

        A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects. By default it ignores methods starting with 'get' or 'set'. The default was changed from 10 to 25 in PHPMD 2.3.

        Source: http://phpmd.org/rules/codesize.txt

        The class CacheManager has an overall complexity of 70 which is very high. The configured complexity threshold is 50.
        Open

        class CacheManager
        {
            const AUTOMATIC_DRIVER_CLASS = 'Auto';
            const CORE_DRIVER_NAMESPACE = 'Phpfastcache\Drivers\\';
        
        
        Severity: Minor
        Found in lib/Phpfastcache/CacheManager.php by phpmd

        Since: PHPMD 0.2.5

        The Weighted Method Count (WMC) of a class is a good indicator of how much time and effort is required to modify and maintain this class. The WMC metric is defined as the sum of complexities of all methods declared in a class. A large number of methods also means that this class has a greater potential impact on derived classes.

        Example:

        class Foo {
              public function bar() {
                  if ($a == $b)  {
                      if ($a1 == $b1) {
                          fiddle();
                      } elseif ($a2 == $b2) {
                          fiddle();
                      } else {
                      }
                  }
              }
              public function baz() {
                  if ($a == $b) {
                      if ($a1 == $b1) {
                          fiddle();
                      } elseif ($a2 == $b2) {
                          fiddle();
                      } else {
                      }
                  }
              }
              // Several other complex methods
          }

        Source: http://phpmd.org/rules/codesize.txt

        File ExtendedCacheItemPoolTrait.php has 302 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         *
         * This file is part of phpFastCache.
         *
        Severity: Minor
        Found in lib/Phpfastcache/Core/Pool/ExtendedCacheItemPoolTrait.php - About 3 hrs to fix

          CacheManager has 25 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class CacheManager
          {
              const AUTOMATIC_DRIVER_CLASS = 'Auto';
              const CORE_DRIVER_NAMESPACE = 'Phpfastcache\Drivers\\';
          
          
          Severity: Minor
          Found in lib/Phpfastcache/CacheManager.php - About 2 hrs to fix

            Function createClassMap has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

                protected static function createClassMap($dir): array
                {
                    if (\is_string($dir)) {
                        $dir = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir));
                    }
            Severity: Minor
            Found in lib/Phpfastcache/Util/ClassNamespaceResolverTrait.php - About 2 hrs 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 getItem has 61 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getItem($key)
                {
                    if (\is_string($key)) {
                        /**
                         * Replace array_key_exists by isset
            Severity: Major
            Found in lib/Phpfastcache/Core/Pool/CacheItemPoolTrait.php - About 2 hrs to fix

              Method getPath has 55 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getPath($readonly = false): string
                  {
                      /**
                       * Get the base system temporary directory
                       */
              Severity: Major
              Found in lib/Phpfastcache/Core/Pool/IO/IOHelperTrait.php - About 2 hrs to fix

                Method findClasses has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected static function findClasses(string $path): array
                    {
                        $contents = \file_get_contents($path);
                        $tokens = \token_get_all($contents);
                        $classes = [];
                Severity: Major
                Found in lib/Phpfastcache/Util/ClassNamespaceResolverTrait.php - About 2 hrs to fix

                  Function driverConnect has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function driverConnect(): bool
                      {
                          $this->instance = new MemcachedSoftware();
                          $this->instance->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
                          $servers = $this->getConfig()->getServers();
                  Severity: Minor
                  Found in lib/Phpfastcache/Drivers/Memcached/Driver.php - About 2 hrs 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

                  Function driverConnect has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function driverConnect(): bool
                      {
                          $this->instance = new MemcacheSoftware();
                          $servers = $this->getConfig()->getServers();
                  
                  
                  Severity: Minor
                  Found in lib/Phpfastcache/Drivers/Memcache/Driver.php - About 2 hrs 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

                  Function rrmdir has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function rrmdir(string $source, bool $removeOnlyChildren = false): bool
                      {
                          if (empty($source) || \file_exists($source) === false) {
                              return false;
                          }
                  Severity: Minor
                  Found in lib/Phpfastcache/Util/Directory.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 indexing has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function indexing($keyword)
                      {
                          if ($this->indexing == null) {
                              $tableCreated = false;
                              if (!\file_exists($this->SqliteDir . '/indexing')) {
                  Severity: Minor
                  Found in lib/Phpfastcache/Drivers/Sqlite/Driver.php - About 1 hr to fix

                    Method errorHandler has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function errorHandler(int $errno, string $errstr, string $errfile, int $errline)
                        {
                            $errorType = '';
                    
                            switch ($errno) {
                    Severity: Minor
                    Found in lib/Phpfastcache/Helper/TestHelper.php - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language