bnomei/kirby3-mysql-cachedriver

View on GitHub

Showing 10 of 10 total issues

File MySQLCache.php has 302 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

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

    MySQLCache has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    final class MySQLCache extends FileCache
    {
        public const DB_VERSION = '2';
    
        private $shutdownCallbacks = [];
    Severity: Minor
    Found in classes/MySQLCache.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)
          {
              $prefix = "mysql-benchmark-";
              $mysql = $this;
              $file = kirby()->cache('bnomei.mysql-cachedriver'); // neat, right? ;-)
      Severity: Minor
      Found in classes/MySQLCache.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 setOptions has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function setOptions(array $options)
          {
              $root = null;
              $cache = kirby()->cache('bnomei.mysql-cachedriver');
              if (is_a($cache, FileCache::class)) {
      Severity: Minor
      Found in classes/MySQLCache.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)
            {
                $prefix = "mysql-benchmark-";
                $mysql = $this;
                $file = kirby()->cache('bnomei.mysql-cachedriver'); // neat, right? ;-)
        Severity: Minor
        Found in classes/MySQLCache.php - About 1 hr to fix

          Method loadDatabase has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function loadDatabase()
              {
                  try {
                      $username = $this->option('username');
                      $password = $this->option('password');
          Severity: Minor
          Found in classes/MySQLCache.php - About 1 hr to fix

            Method updateOrInsert has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function updateOrInsert(string $key, $value, int $minutes = 0): bool
                {
                    $rawKey = $key;
                    $key = $this->key($key);
                    $value = new Value($value, $minutes);
            Severity: Minor
            Found in classes/MySQLCache.php - About 1 hr to fix

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

                  private function setOptions(array $options)
                  {
                      $root = null;
                      $cache = kirby()->cache('bnomei.mysql-cachedriver');
                      if (is_a($cache, FileCache::class)) {
              Severity: Minor
              Found in classes/MySQLCache.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 updateOrInsert has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function updateOrInsert(string $key, $value, int $minutes = 0): bool
                  {
                      $rawKey = $key;
                      $key = $this->key($key);
                      $value = new Value($value, $minutes);
              Severity: Minor
              Found in classes/MySQLCache.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 retrieve has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function retrieve(string $key): ?Value
                  {
                      $key = $this->key($key);
              
                      $value = A::get($this->store, $key);
              Severity: Minor
              Found in classes/MySQLCache.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

              Severity
              Category
              Status
              Source
              Language