PHPSocialNetwork/phpfastcache

View on GitHub

Showing 65 of 143 total issues

Function __call has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function __call(string $name, array $arguments)
    {
        if (\strpos($name, 'on') === 0) {
            $name = \substr($name, 2);
            if (\is_callable($arguments[0])) {
Severity: Minor
Found in lib/Phpfastcache/EventManager.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 rrmdir has 27 lines of code (exceeds 25 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

    Function errorHandler has a Cognitive Complexity of 9 (exceeds 5 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 55 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

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

        public function setServers(array $servers): self
        {
            foreach ($servers as $server) {
                if($diff = \array_diff(['host', 'port', 'saslUser', 'saslPassword'], \array_keys($server))){
                    throw new PhpfastcacheInvalidConfigurationException('Missing keys for memcached server: '. \implode(', ', $diff));
    Severity: Minor
    Found in lib/Phpfastcache/Drivers/Memcached/Config.php - About 55 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

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

        public function setServers(array $servers): self
        {
            foreach ($servers as $server) {
                if($diff = \array_diff(['host', 'port', 'saslUser', 'saslPassword'], \array_keys($server))){
                    throw new PhpfastcacheInvalidConfigurationException('Missing keys for memcached server: '. \implode(', ', $diff));
    Severity: Minor
    Found in lib/Phpfastcache/Drivers/Memcache/Config.php - About 55 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

    Function checkCollision has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function checkCollision($driverName): bool
        {
            $CONSTANT_NAME = __NAMESPACE__ . '\MEMCACHE_DRIVER_USED';
    
            if ($driverName && \is_string($driverName)) {
    Severity: Minor
    Found in lib/Phpfastcache/Util/MemcacheDriverCollisionDetectorTrait.php - About 45 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

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

        protected function driverConnect(): bool
        {
            if ($this->instance instanceof PredisClient) {
                throw new PhpfastcacheLogicException('Already connected to Predis server');
            }
    Severity: Minor
    Found in lib/Phpfastcache/Drivers/Predis/Driver.php - About 45 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

    Function writefile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function writefile($file, $data, $secureFileManipulation = false): bool
        {
            /**
             * @eventName CacheWriteFileOnDisk
             * @param ExtendedCacheItemPoolInterface $this
    Severity: Minor
    Found in lib/Phpfastcache/Core/Pool/IO/IOHelperTrait.php - About 45 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

    Avoid deeply nested control flow statements.
    Open

                                if(@mkdir($full_path, $this->getDefaultChmod(), true) &&  !\is_dir($full_path)){
                                    throw new PhpfastcacheIOException('The directory '.$full_path.' could not be created.');
                                }
    Severity: Major
    Found in lib/Phpfastcache/Core/Pool/IO/IOHelperTrait.php - About 45 mins to fix

      Function dirSize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function dirSize(string $directory, bool $includeDirAllocSize = false): int
          {
              $size = 0;
              foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file) {
                  /**
      Severity: Minor
      Found in lib/Phpfastcache/Util/Directory.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

      Function save has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function save(CacheItemInterface $item)
          {
              /**
               * @var ExtendedCacheItemInterface $item
               *
      Severity: Minor
      Found in lib/Phpfastcache/Core/Pool/CacheItemPoolTrait.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

      Function expiresAfter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function expiresAfter($time)
          {
              if (\is_numeric($time)) {
                  if ($time <= 0) {
                      /**
      Severity: Minor
      Found in lib/Phpfastcache/Core/Item/ItemBaseTrait.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

      Function getAbsolutePath has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function getAbsolutePath(string $path): string
          {
              $parts = \preg_split('~[/\\\\]+~', $path, 0, \PREG_SPLIT_NO_EMPTY);
              $absolutes = [];
              foreach ($parts as $part) {
      Severity: Minor
      Found in lib/Phpfastcache/Util/Directory.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

      Function driverDelete has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function driverDelete(CacheItemInterface $item): bool
          {
              /**
               * Check for Cross-Driver type confusion
               */
      Severity: Minor
      Found in lib/Phpfastcache/Drivers/Files/Driver.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

      Function setMultiple has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function setMultiple($values, $ttl = null): bool
          {
              try {
                  foreach ($values as $key => $value) {
                      $cacheItem = $this->internalCacheInstance->getItem($key)->set($value);
      Severity: Minor
      Found in lib/Phpfastcache/Helper/Psr16Adapter.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

      Function saveMultiple has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function saveMultiple(...$items): bool
          {
              if (isset($items[0]) && \is_array($items[0])) {
                  foreach ($items[0] as $item) {
                      $this->save($item);
      Severity: Minor
      Found in lib/Phpfastcache/Core/Pool/ExtendedCacheItemPoolTrait.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

      Avoid too many return statements within this method.
      Open

                  return \rmdir($source);
      Severity: Major
      Found in lib/Phpfastcache/Util/Directory.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return true;
        Severity: Major
        Found in lib/Phpfastcache/Helper/TestHelper.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return false;
          Severity: Major
          Found in lib/Phpfastcache/Helper/TestHelper.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return true;
            Severity: Major
            Found in lib/Phpfastcache/Util/Directory.php - About 30 mins to fix
              Severity
              Category
              Status
              Source
              Language