vakata/cache

View on GitHub

Showing 8 of 72 total issues

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

    public function __construct(array|string $pool = '127.0.0.1', string $prefix = '')
    {
        parent::__construct($prefix);

        if (is_string($pool)) {
Severity: Minor
Found in src/Libmemcached.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

Function clean has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function clean(): void
    {
        $a = $this->acquire();
        foreach ($this->data['keys'] as $key => $id) {
            if (!shm_has_var($this->memory, $id)) {
Severity: Minor
Found in src/SHM.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 clean has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function clean(): void
    {
        $a = $this->acquire();
        foreach ($this->data['keys'] as $key => $id) {
            if (!shm_has_var($this->memory, $id)) {
Severity: Minor
Found in src/SHM.php - About 1 hr to fix

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

        protected function _read(): mixed
        {
            switch (fgetc($this->socket)) {
                case '+':
                    return trim(fgets($this->socket) ?: '', "\r\n");
    Severity: Minor
    Found in src/Redis.php - About 1 hr to fix

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

          public function getSet(string $key, callable $value, string|int|DateInterval|DateTime $expires = 0): mixed
          {
              $cnt = 0;
              do {
                  $temp = $this->get($key, chr(0));
      Severity: Minor
      Found in src/AbstractCache.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 $return;
      Severity: Major
      Found in src/Redis.php - About 30 mins to fix

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

            protected function keyID(string $key, bool $create = false): int
            {
                if (!isset($this->data['keys'][$key])) {
                    $this->readMaster();
                }
        Severity: Minor
        Found in src/SHM.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 getExpiresTimestamp has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function getExpiresTimestamp(int|string|DateInterval|DateTime $expires): int
            {
                if ($expires instanceof DateInterval) {
                    $expires = (new \DateTime())->add($expires)->getTimestamp();
                }
        Severity: Minor
        Found in src/AbstractCache.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