felixarntz/plugin-lib

View on GitHub
src/db-objects/storage.php

Summary

Maintainability
B
4 hrs
Test Coverage

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

        public static function retrieve( $cache_group, $model_id ) {
            if ( ! isset( self::$models[ $cache_group ] ) ) {
                return null;
            }

Severity: Minor
Found in src/db-objects/storage.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 store has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        public static function store( $cache_group, $model_id, $model ) {
            if ( ! isset( $models[ $cache_group ] ) ) {
                $models[ $cache_group ] = array();
            }

Severity: Minor
Found in src/db-objects/storage.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 is_stored has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        public static function is_stored( $cache_group, $model_id ) {
            if ( ! isset( self::$models[ $cache_group ] ) ) {
                return false;
            }

Severity: Minor
Found in src/db-objects/storage.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

Avoid too many return statements within this method.
Open

            return self::$models[ $cache_group ][ $model_id ];
Severity: Major
Found in src/db-objects/storage.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                    return null;
    Severity: Major
    Found in src/db-objects/storage.php - About 30 mins to fix

      Avoid using undefined variables such as '$models' which will lead to PHP notices.
      Open

                      $models[ $cache_group ] = array();
      Severity: Minor
      Found in src/db-objects/storage.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$models' which will lead to PHP notices.
      Open

                  if ( ! isset( $models[ $cache_group ] ) ) {
      Severity: Minor
      Found in src/db-objects/storage.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      There are no issues that match your filters.

      Category
      Status