PHPSocialNetwork/phpfastcache

View on GitHub

Showing 141 of 141 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

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

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

    public function getItem($key)
    {
        /** @var ExtendedCacheItemPoolInterface[] $poolsToResync */
        $poolsToResync = [];
        /** @var ExtendedCacheItemInterface $item */

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

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

class TestHelper
{
    /**
     * @var string
     */

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 TestHelper.php has 292 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

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

    Method getItem has 67 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

      ConfigurationOption has 24 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 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 runCRUDTests has 62 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function runCRUDTests(ExtendedCacheItemPoolInterface $pool)
            {
                $this->printInfoText('Running CRUD tests on the following backend: ' . get_class($pool));
                $pool->clear();
        
        
        Severity: Major
        Found in lib/Phpfastcache/Helper/TestHelper.php - About 2 hrs to fix

          Config has 22 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Config extends ConfigurationOption
          {
              /**
               * @var string
               */
          Severity: Minor
          Found in lib/Phpfastcache/Drivers/Mongodb/Config.php - About 2 hrs to fix

            TestHelper has 22 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class TestHelper
            {
                /**
                 * @var string
                 */
            Severity: Minor
            Found in lib/Phpfastcache/Helper/TestHelper.php - About 2 hrs to fix

              Method getPath has 57 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

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

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

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

                      public function getStats(): DriverStatistic
                      {
                          $serverStats = $this->instance->getManager()->executeCommand(
                              'phpFastCache',
                              new Command(
                  Severity: Major
                  Found in lib/Phpfastcache/Drivers/Mongodb/Driver.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(MemcachedSoftware::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

                      Method indexing has 52 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: Major
                      Found in lib/Phpfastcache/Drivers/Sqlite/Driver.php - About 2 hrs to fix

                        File CacheManager.php has 253 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 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language