propelorm/Propel2

View on GitHub
src/Propel/Runtime/ActiveQuery/ModelCriteria.php

Summary

Maintainability
F
1 wk
Test Coverage

File ModelCriteria.php has 1184 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * MIT License. This file is part of the Propel package.
 * For the full copyright and license information, please view the LICENSE
Severity: Major
Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.php - About 3 days to fix

    ModelCriteria has 96 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ModelCriteria extends BaseModelCriteria
    {
        /**
         * @var string
         */
    Severity: Major
    Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.php - About 1 day to fix

      Function getCriterionForClause has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function getCriterionForClause(string $clause, $value, ?int $bindingType = null): AbstractCriterion
          {
              $origin = $clause = trim($clause);
              if ($this->replaceNames($clause)) {
                  // at least one column name was found and replaced in the clause
      Severity: Minor
      Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.php - About 3 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 doUpdate has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          public function doUpdate($updateValues, ConnectionInterface $con, bool $forceIndividualSaves = false): int
          {
              if ($forceIndividualSaves) {
                  if ($updateValues instanceof Criteria) {
                      throw new LogicException('Parameter #1 `$updateValues` must be an array while `$forceIndividualSaves = true`.');
      Severity: Minor
      Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.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 __call has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          public function __call(string $name, array $arguments)
          {
              // Maybe it's a magic call to one of the methods supporting it, e.g. 'findByTitle'
              static $methods = ['findBy', 'findOneBy', 'requireOneBy', 'filterBy', 'orderBy', 'groupBy'];
              foreach ($methods as $methodName) {
      Severity: Minor
      Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.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 getColumnFromName has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function getColumnFromName(string $columnName, bool $failSilently = true): array
          {
              if (strpos($columnName, '.') === false) {
                  $prefix = (string)$this->getModelAliasOrName();
              } else {
      Severity: Minor
      Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.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 __call has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function __call(string $name, array $arguments)
          {
              // Maybe it's a magic call to one of the methods supporting it, e.g. 'findByTitle'
              static $methods = ['findBy', 'findOneBy', 'requireOneBy', 'filterBy', 'orderBy', 'groupBy'];
              foreach ($methods as $methodName) {
      Severity: Minor
      Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.php - About 1 hr to fix

        Method getColumnFromName has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function getColumnFromName(string $columnName, bool $failSilently = true): array
            {
                if (strpos($columnName, '.') === false) {
                    $prefix = (string)$this->getModelAliasOrName();
                } else {
        Severity: Minor
        Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.php - About 1 hr to fix

          Method join has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function join(string $relation, string $joinType = Criteria::INNER_JOIN)
              {
                  // relation looks like '$leftName.$relationName $relationAlias'
                  [$fullName, $relationAlias] = self::getClassAndAlias($relation);
                  if (strpos($fullName, '.') === false) {
          Severity: Minor
          Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.php - About 1 hr to fix

            Method getCriterionForClause has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function getCriterionForClause(string $clause, $value, ?int $bindingType = null): AbstractCriterion
                {
                    $origin = $clause = trim($clause);
                    if ($this->replaceNames($clause)) {
                        // at least one column name was found and replaced in the clause
            Severity: Minor
            Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.php - About 1 hr to fix

              Function join has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function join(string $relation, string $joinType = Criteria::INNER_JOIN)
                  {
                      // relation looks like '$leftName.$relationName $relationAlias'
                      [$fullName, $relationAlias] = self::getClassAndAlias($relation);
                      if (strpos($fullName, '.') === false) {
              Severity: Minor
              Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.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 getParams has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getParams(): array
                  {
                      $params = [];
                      $dbMap = Propel::getServiceContainer()->getDatabaseMap($this->getDbName());
              
              
              Severity: Minor
              Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.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 doUpdate has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function doUpdate($updateValues, ConnectionInterface $con, bool $forceIndividualSaves = false): int
                  {
                      if ($forceIndividualSaves) {
                          if ($updateValues instanceof Criteria) {
                              throw new LogicException('Parameter #1 `$updateValues` must be an array while `$forceIndividualSaves = true`.');
              Severity: Minor
              Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.php - About 1 hr to fix

                Function convertValueForColumn has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function convertValueForColumn($value, ColumnMap $colMap)
                    {
                        if ($colMap->getType() === 'OBJECT' && is_object($value)) {
                            $value = serialize($value);
                        } elseif ($colMap->getType() === 'ARRAY' && is_array($value)) {
                Severity: Minor
                Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.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 getParams has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getParams(): array
                    {
                        $params = [];
                        $dbMap = Propel::getServiceContainer()->getDatabaseMap($this->getDbName());
                
                
                Severity: Minor
                Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.php - About 1 hr to fix

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

                      public function configureSelectColumns(): void
                      {
                          if (!$this->select) {
                              return;
                          }
                  Severity: Minor
                  Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.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 findOneOrCreate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function findOneOrCreate(?ConnectionInterface $con = null)
                      {
                          if ($this->joins) {
                              throw new PropelException(__METHOD__ . ' cannot be used on a query with a join, because Propel cannot transform a SQL JOIN into a subquery. You should split the query in two queries to avoid joins.');
                          }
                  Severity: Minor
                  Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.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 addJoinCondition has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public function addJoinCondition(string $name, string $clause, $value = null, ?string $operator = null, ?int $bindingType = null)
                  Severity: Minor
                  Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.php - About 35 mins to fix

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

                            string $abstractInnerQueryCriterionClass,
                            string $relationName,
                            ?string $modelAlias = null,
                            ?string $queryClass = null,
                            ?string $operatorDeclaration = null
                    Severity: Minor
                    Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.php - About 35 mins to fix

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

                          public function groupByClass(string $class)
                          {
                              if ($class == $this->getModelAliasOrName()) {
                                  // column of the Criteria's model
                                  $tableMap = $this->getTableMap();
                      Severity: Minor
                      Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.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 addSelectQuery has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function addSelectQuery(Criteria $subQueryCriteria, ?string $alias = null, bool $addAliasAndSelectColumns = true)
                          {
                              if (!$subQueryCriteria->hasSelectClause()) {
                                  $subQueryCriteria->addSelfSelectColumns();
                              }
                      Severity: Minor
                      Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.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 new BasicModelCriterion($this, $clause, $colMap, $value, $this->currentAlias);
                      Severity: Major
                      Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return new CustomCriterion($this, $clause);
                        Severity: Major
                        Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return [null, null];
                          Severity: Major
                          Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return new RawCriterion($this, $clause, $value, $bindingType);
                            Severity: Major
                            Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                              return new SeveralModelCriterion($this, $clause, $colMap, $value, $this->currentAlias);
                              Severity: Major
                              Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.php - About 30 mins to fix

                                There are no issues that match your filters.

                                Category
                                Status