PHPSocialNetwork/phpfastcache

View on GitHub

Showing 67 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

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

    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

    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

    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

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

      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

      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

      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

      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

          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

            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

              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

              Method getInstance has 38 lines of code (exceeds 25 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 1 hr to fix
                Severity
                Category
                Status
                Source
                Language