bnomei/kirby3-redis-cachedriver

View on GitHub

Showing 9 of 9 total issues

File Redis.php has 283 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace Bnomei;
Severity: Minor
Found in classes/Redis.php - About 2 hrs to fix

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

        public function benchmark(int $count = 10): void
        {
            $prefix = 'redis-benchmark-';
            $redis = $this;
            $file = kirby()->cache('bnomei.redis-cachedriver'); // neat, right? ;-)
    Severity: Minor
    Found in classes/Redis.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 preload has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        private function preload(): void
        {
            $this->preload = [];
            $expire = $this->options['preload'];
            if ($expire === false) {
    Severity: Minor
    Found in classes/Redis.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 preload has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function preload(): void
        {
            $this->preload = [];
            $expire = $this->options['preload'];
            if ($expire === false) {
    Severity: Minor
    Found in classes/Redis.php - About 1 hr to fix

      Method benchmark has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function benchmark(int $count = 10): void
          {
              $prefix = 'redis-benchmark-';
              $redis = $this;
              $file = kirby()->cache('bnomei.redis-cachedriver'); // neat, right? ;-)
      Severity: Minor
      Found in classes/Redis.php - About 1 hr to fix

        Method __construct has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function __construct(array $options = [], array $optionsClient = [])
            {
                $this->options = array_merge([
                    'debug' => \option('debug'),
                    'store' => \option('bnomei.redis-cachedriver.store'),
        Severity: Minor
        Found in classes/Redis.php - About 1 hr to fix

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

              public function set(string $key, mixed $value, int $minutes = 0): bool
              {
                  /* SHOULD SET EVEN IN DEBUG
                  if ($this->options['debug')) {
                      return true;
          Severity: Minor
          Found in classes/Redis.php - About 1 hr to fix

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

                public function __destruct()
                {
                    foreach ($this->shutdownCallbacks as $callback) {
                        if (! is_string($callback) && is_callable($callback)) {
                            $callback();
            Severity: Minor
            Found in classes/Redis.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 set has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function set(string $key, mixed $value, int $minutes = 0): bool
                {
                    /* SHOULD SET EVEN IN DEBUG
                    if ($this->options['debug')) {
                        return true;
            Severity: Minor
            Found in classes/Redis.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