PHPSocialNetwork/phpfastcache

View on GitHub

Showing 66 of 67 total issues

Function getItems has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    public function getItems(array $keys = []): iterable
    {
        $items = [];

        /**
Severity: Minor
Found in lib/Phpfastcache/Core/Pool/CacheItemPoolTrait.php - About 4 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 CacheItemPoolTrait.php has 350 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 *
 * This file is part of Phpfastcache.
Severity: Minor
Found in lib/Phpfastcache/Core/Pool/CacheItemPoolTrait.php - About 4 hrs to fix

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

        public function setServers(array $servers): static
        {
            foreach ($servers as $server) {
                if ($diff = array_diff(array_keys($server), ['host', 'port', 'saslUser', 'saslPassword', 'path'])) {
                    throw new PhpfastcacheInvalidConfigurationException('Unknown keys for memcached server: ' . implode(', ', $diff));
    Severity: Minor
    Found in lib/Phpfastcache/Drivers/Memcached/Config.php - About 3 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 setServers has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        public function setServers(array $servers): static
        {
            foreach ($servers as $server) {
                if (\array_key_exists('saslUser', $server) || array_key_exists('saslPassword', $server)) {
                    throw new PhpfastcacheInvalidConfigurationException('Unlike Memcached, Memcache does not support SASL authentication');
    Severity: Minor
    Found in lib/Phpfastcache/Drivers/Memcache/Config.php - About 3 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 22 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getItem(string $key): ExtendedCacheItemInterface
        {
            /**
             * Replace array_key_exists by isset
             * due to performance issue on huge
    Severity: Minor
    Found in lib/Phpfastcache/Core/Pool/CacheItemPoolTrait.php - About 3 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 21 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getItem(string $key): ExtendedCacheItemInterface
        {
            /** @var ExtendedCacheItemPoolInterface[] $poolsToResync */
            $poolsToResync = [];
            /** @var ?ExtendedCacheItemInterface $item */
    Severity: Minor
    Found in lib/Phpfastcache/Cluster/Drivers/FullReplication/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

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

    class ConfigurationOption extends AbstractConfigurationOption implements ConfigurationOptionInterface
    {
        protected bool $itemDetailedDate = false;
    
        protected bool $autoTmpFallback = false;
    Severity: Minor
    Found in lib/Phpfastcache/Config/ConfigurationOption.php - About 2 hrs to fix

      Function getInstance has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function getInstance(string $driver, ?ConfigurationOptionInterface $config = null, ?string $instanceId = null): ExtendedCacheItemPoolInterface
          {
              if (\class_exists($driver) && \str_starts_with($driver, 'Phpfastcache')) {
                  $driverClass = $driver;
              } else {
      Severity: Minor
      Found in lib/Phpfastcache/CacheManager.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 mkdir has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function mkdir(string $fullPath, string $fullPathTmp): void
          {
              $fullPathHash = $this->getConfig()->getDefaultFileNameHashFunction()($fullPath);
      
              if (!isset($this->tmp[$fullPathHash]) || (!@\file_exists($fullPath) || !@\is_writable($fullPath))) {
      Severity: Minor
      Found in lib/Phpfastcache/Core/Pool/IO/IOHelperTrait.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 buildTokenClasses has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          protected static function buildTokenClasses(string $namespace, string $class, array $classes, int $index, array $tokens): array
          {
              // Skip usage of ::class constant
              $isClassConstant = false;
              for ($j = $index - 1; $j > 0; --$j) {
      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

      Function rrmdir has a Cognitive Complexity of 17 (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 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 getItems has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getItems(array $keys = []): iterable
          {
              $items = [];
      
              /**
      Severity: Major
      Found in lib/Phpfastcache/Core/Pool/CacheItemPoolTrait.php - About 2 hrs to fix

        File CacheManager.php has 256 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

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

              public function deleteItems(array $keys): bool
              {
                  if (count($keys) > 1) {
                      $return = true;
                      try {
          Severity: Minor
          Found in lib/Phpfastcache/Core/Pool/CacheItemPoolTrait.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 getDbIndex has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getDbIndex(string $keyword)
              {
                  if (!isset($this->indexing)) {
                      $tableCreated = false;
                      if (!file_exists($this->sqliteDir . '/indexing')) {
          Severity: Major
          Found in lib/Phpfastcache/Drivers/Sqlite/Driver.php - About 2 hrs to fix

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

                public static function getPhpfastcacheVersion(bool $fallbackOnChangelog = true, bool $cacheable = true): string
                {
                    /**
                     * Cache the version statically to improve
                     * performances on multiple calls
            Severity: Minor
            Found in lib/Phpfastcache/Api.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 driverConnect has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function driverConnect(): bool
                {
                    $clientConfig = $this->getConfig();
            
                    $clusterBuilder = Cassandra::cluster()
            Severity: Minor
            Found in lib/Phpfastcache/Drivers/Cassandra/Driver.php - About 1 hr to fix

              Function getDbIndex has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getDbIndex(string $keyword)
                  {
                      if (!isset($this->indexing)) {
                          $tableCreated = false;
                          if (!file_exists($this->sqliteDir . '/indexing')) {
              Severity: Minor
              Found in lib/Phpfastcache/Drivers/Sqlite/Driver.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

              Function buildTokenNamespace has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected static function buildTokenNamespace(int $index, array $tokens): string
                  {
                      $namespace = '';
              
                      // If there is a namespace, extract it (PHP 8 test)
              Severity: Minor
              Found in lib/Phpfastcache/Util/ClassNamespaceResolverTrait.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 getItem has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getItem(string $key): ExtendedCacheItemInterface
                  {
                      /**
                       * Replace array_key_exists by isset
                       * due to performance issue on huge
              Severity: Minor
              Found in lib/Phpfastcache/Core/Pool/CacheItemPoolTrait.php - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language