PHPSocialNetwork/phpfastcache

View on GitHub

Showing 66 of 67 total issues

Method addCoreDriverOverride has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function addCoreDriverOverride(string $driverName, string $className): void
    {
        $driverName = self::normalizeDriverName($driverName);

        if (empty($driverName)) {
Severity: Minor
Found in lib/Phpfastcache/CacheManager.php - About 1 hr to fix

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

        protected static function createClassMap(string $dir): array
        {
            $dirIterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir));
    
            $map = [];
    Severity: Minor
    Found in lib/Phpfastcache/Util/ClassNamespaceResolverTrait.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 save has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function save(CacheItemInterface $item): bool
        {
            $this->assertCacheItemType($item, self::getItemClass());
            /**
             * @var ExtendedCacheItemInterface $item
    Severity: Minor
    Found in lib/Phpfastcache/Core/Pool/CacheItemPoolTrait.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 getItem has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getItem(string $key): ExtendedCacheItemInterface
        {
            /** @var ?ExtendedCacheItemInterface $item */
            $item = null;
            $eCount = 0;
    Severity: Minor
    Found in lib/Phpfastcache/Cluster/Drivers/SemiReplication/Driver.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 driverConnect has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function driverConnect(): bool
        {
            if (isset($this->instance) && $this->instance instanceof RedisClient) {
                throw new PhpfastcacheLogicException('Already connected to Redis server');
            }
    Severity: Minor
    Found in lib/Phpfastcache/Drivers/Redis/Driver.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 writeFile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function writeFile(string $file, string $data, bool $secureFileManipulation = false): bool
        {
            $this->eventManager->dispatch(Event::CACHE_WRITE_FILE_ON_DISK, $this, $file, $secureFileManipulation);
    
            if ($secureFileManipulation) {
    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

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

        protected function driverWriteTags(ExtendedCacheItemInterface $item): bool
        {
            /**
             * Do not attempt to write tags
             * on tags item, it can lead
    Severity: Minor
    Found in lib/Phpfastcache/Core/Pool/TaggableCacheItemPoolTrait.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 findClasses has a Cognitive Complexity of 8 (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 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

    Method buildTokenClasses has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        protected static function buildTokenClasses(string $namespace, string $class, array $classes, int $index, array $tokens): array
    Severity: Minor
    Found in lib/Phpfastcache/Util/ClassNamespaceResolverTrait.php - About 35 mins to fix

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

          public function getPath(bool $readonly = false): string
          {
              $tmpDir = \rtrim(\ini_get('upload_tmp_dir') ?: \sys_get_temp_dir(), '\\/') . DIRECTORY_SEPARATOR . 'phpfastcache';
              $httpHost = $this->getConfig()->getSuperGlobalAccessor()('SERVER', 'HTTP_HOST');
              $securityKey = $this->buildSecurityKey($httpHost);
      Severity: Minor
      Found in lib/Phpfastcache/Core/Pool/IO/IOHelperTrait.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 driverConnect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function driverConnect(): bool
          {
              /**
               * In case of a user-provided
               * Predis client just return here
      Severity: Minor
      Found in lib/Phpfastcache/Drivers/Predis/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 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

      Avoid too many return statements within this method.
      Open

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

        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/Util/Directory.php - About 30 mins to fix

            Function __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function __construct(array $parameters = [])
                {
                    foreach ($parameters as $configKey => $configVal) {
                        try {
                            if (\property_exists($this, $configKey)) {
            Severity: Minor
            Found in lib/Phpfastcache/Config/ConfigurationOption.php - About 25 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 commit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function commit(): bool
                {
                    $this->eventManager->dispatch(Event::CACHE_COMMIT_ITEM, $this, new EventReferenceParameter($this->deferredList));
            
                    if (\count($this->deferredList)) {
            Severity: Minor
            Found in lib/Phpfastcache/Core/Pool/CacheItemPoolTrait.php - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function save(CacheItemInterface $item): bool
                {
                    /** @var ExtendedCacheItemInterface $item */
                    $hasSavedOnce = false;
                    $eCount = 0;
            Severity: Minor
            Found in lib/Phpfastcache/Cluster/Drivers/SemiReplication/Driver.php - About 25 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 clear has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function clear(): bool
                {
                    $hasClearedOnce = false;
                    $eCount = 0;
            
            
            Severity: Minor
            Found in lib/Phpfastcache/Cluster/Drivers/SemiReplication/Driver.php - About 25 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 getDb has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getDb(string $keyword, bool $reset = false): PDO
                {
                    /**
                     * Default is phpfastcache
                     */
            Severity: Minor
            Found in lib/Phpfastcache/Drivers/Sqlite/Driver.php - About 25 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

            Severity
            Category
            Status
            Source
            Language