RebelCode/wp-cqrs-resource-models

View on GitHub

Showing 47 of 47 total issues

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

            $this->_mapIterable($postFieldKeyMap, [$this, '_validatePostFieldKeyMapping'], null, null, $map);

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

Method _buildSelectSql has 9 arguments (exceeds 4 allowed). Consider refactoring.
Open

        $columns,
        $tables,
        $joins = [],
        LogicalExpressionInterface $where = null,
        $ordering = null,
Severity: Major
Found in src/Wpdb/SelectCapableWpdbTrait.php - About 1 hr to fix

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

        protected function _extractPostIdsFromInExpression(LogicalExpressionInterface $expression)
        {
            $postIds       = [];
            $isPostIdField = false;
            $pEntity       = $this->_getPostEntityName();
    Severity: Minor
    Found in src/Posts/ExtractPostIdsFromExpressionCapableTrait.php - About 1 hr to fix

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

          protected function _extractPostIdsFromBetweenExpression(LogicalExpressionInterface $expression)
          {
              $isPostIdField = false;
              $pEntity       = $this->_getPostEntityName();
              $pIdField      = $this->_getPostIdFieldName();
      Severity: Minor
      Found in src/Posts/ExtractPostIdsFromExpressionCapableTrait.php - About 1 hr to fix

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

            protected function _normalizeWpPostDataArray($postData)
            {
                // If an array or traversable, then meta data can be extracted. Forward to the other method
                if (is_array($postData) || $postData instanceof Traversable) {
                    return $this->_normalizeWpPostDataAndMeta($postData);
        Severity: Minor
        Found in src/Posts/NormalizeWpPostDataArrayCapableTrait.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 _extractPostIdsFromBetweenExpression has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function _extractPostIdsFromBetweenExpression(LogicalExpressionInterface $expression)
            {
                $isPostIdField = false;
                $pEntity       = $this->_getPostEntityName();
                $pIdField      = $this->_getPostIdFieldName();
        Severity: Minor
        Found in src/Posts/ExtractPostIdsFromExpressionCapableTrait.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 _extractPostIdsFromInExpression has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function _extractPostIdsFromInExpression(LogicalExpressionInterface $expression)
            {
                $postIds       = [];
                $isPostIdField = false;
                $pEntity       = $this->_getPostEntityName();
        Severity: Minor
        Found in src/Posts/ExtractPostIdsFromExpressionCapableTrait.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

        Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                wpdb $wpdb,
                TemplateInterface $expressionTemplate,
                MapFactoryInterface $factory,
                $tables,
                $fieldColumnMap,
        Severity: Minor
        Found in src/Wpdb/WpdbSelectResourceModel.php - About 45 mins to fix

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

              protected function _normalizeWpPostDataValue($value)
              {
                  if ($value instanceof TermInterface && !($value instanceof LiteralTermInterface)) {
                      throw $this->_createInvalidArgumentException(
                          $this->__('Only literal terms are supported for native WP operations'),
          Severity: Minor
          Found in src/Posts/NormalizeWpPostDataArrayCapableTrait.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 _extractPostIdsFromEqualsExpression has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function _extractPostIdsFromEqualsExpression(LogicalExpressionInterface $expression = null)
              {
                  $postIds       = [];
                  $isPostIdField = false;
                  $pEntity       = $this->_getPostEntityName();
          Severity: Minor
          Found in src/Posts/ExtractPostIdsFromExpressionCapableTrait.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 _init has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  wpdb $wpdb,
                  TemplateInterface $expressionTemplate,
                  MapFactoryInterface $factory,
                  $tables,
                  $fieldColumnMap,
          Severity: Minor
          Found in src/Wpdb/AbstractBaseWpdbSelectResourceModel.php - About 45 mins to fix

            Method _buildDeleteSql has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    $table,
                    LogicalExpressionInterface $condition = null,
                    $ordering = null,
                    $limit = null,
                    $offset = null,
            Severity: Minor
            Found in src/Wpdb/DeleteCapableWpdbTrait.php - About 45 mins to fix

              Method _buildUpdateSql has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      $table,
                      $changeSet,
                      LogicalExpressionInterface $condition = null,
                      $ordering = null,
                      $limit = null,
              Severity: Minor
              Found in src/Wpdb/UpdateCapableWpdbTrait.php - About 45 mins to fix

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

                    protected function _preProcessChangeSet($changeSet, &$hashMap = [])
                    {
                        if ($hashMap === null) {
                            $hashMap = [];
                        }
                Severity: Minor
                Found in src/Wpdb/UpdateCapableWpdbTrait.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 _mapIterable has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        $iterable,
                        $callback,
                        $start = null,
                        $count = null,
                        array &$results = null
                Severity: Minor
                Found in src/Posts/PostFieldKeyMapAwareTrait.php - About 35 mins to fix

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

                          $iterable,
                          $callback,
                          $start = null,
                          $count = null,
                          array &$results = null
                  Severity: Minor
                  Found in src/Posts/SearchExpressionTermsCapableTrait.php - About 35 mins to fix

                    The method __construct has a boolean flag argument $insertBulk, which is a certain sign of a Single Responsibility Principle violation.
                    Open

                        public function __construct(wpdb $wpdb, $table, $fieldColumnMap, $insertBulk = true)
                    Severity: Minor
                    Found in src/Wpdb/WpdbInsertResourceModel.php by phpmd

                    BooleanArgumentFlag

                    Since: 1.4.0

                    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

                    Example

                    class Foo {
                        public function bar($flag = true) {
                        }
                    }

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

                    The method _init has a boolean flag argument $insertBulk, which is a certain sign of a Single Responsibility Principle violation.
                    Open

                        protected function _init(wpdb $wpdb, $table, $fieldColumnMap, $insertBulk = true)

                    BooleanArgumentFlag

                    Since: 1.4.0

                    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

                    Example

                    class Foo {
                        public function bar($flag = true) {
                        }
                    }

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

                    Avoid unused local variables such as '$_idx'.
                    Open

                            foreach ($condition->getTerms() as $_idx => $_term) {

                    UnusedLocalVariable

                    Since: 0.2

                    Detects when a local variable is declared and/or assigned, but not used.

                    Example

                    class Foo {
                        public function doSomething()
                        {
                            $i = 5; // Unused
                        }
                    }

                    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

                    The method __ is not named in camelCase.
                    Open

                        abstract protected function __($string, $args = [], $context = null);
                    Severity: Minor
                    Found in src/Wpdb/UpdateCapableWpdbTrait.php by phpmd

                    CamelCaseMethodName

                    Since: 0.2

                    It is considered best practice to use the camelCase notation to name methods.

                    Example

                    class ClassName {
                        public function get_name() {
                        }
                    }

                    Source

                    Severity
                    Category
                    Status
                    Source
                    Language