propelorm/Propel2

View on GitHub
src/Propel/Generator/Builder/Om/QueryBuilder.php

Summary

Maintainability
F
1 wk
Test Coverage

File QueryBuilder.php has 1254 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/Generator/Builder/Om/QueryBuilder.php - About 3 days to fix

    QueryBuilder has 59 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class QueryBuilder extends AbstractOMBuilder
    {
        /**
         * Returns the package for the [base] object classes.
         *
    Severity: Major
    Found in src/Propel/Generator/Builder/Om/QueryBuilder.php - About 1 day to fix

      Method addFilterByCol has 139 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function addFilterByCol(string &$script, Column $col): void
          {
              $colPhpName = $col->getPhpName();
              $colName = $col->getName();
              $variableName = $col->getCamelCaseName();
      Severity: Major
      Found in src/Propel/Generator/Builder/Om/QueryBuilder.php - About 5 hrs to fix

        Method addFindPkSimple has 84 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function addFindPkSimple(string &$script): void
            {
                $table = $this->getTable();
        
                // this method is not needed if the table has no primary key
        Severity: Major
        Found in src/Propel/Generator/Builder/Om/QueryBuilder.php - About 3 hrs to fix

          Function addFilterByCol has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function addFilterByCol(string &$script, Column $col): void
              {
                  $colPhpName = $col->getPhpName();
                  $colName = $col->getName();
                  $variableName = $col->getCamelCaseName();
          Severity: Minor
          Found in src/Propel/Generator/Builder/Om/QueryBuilder.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 addClassBody has 62 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function addClassBody(string &$script): void
              {
                  $table = $this->getTable();
          
                  // namespaces
          Severity: Major
          Found in src/Propel/Generator/Builder/Om/QueryBuilder.php - About 2 hrs to fix

            Function addFindPkSimple has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function addFindPkSimple(string &$script): void
                {
                    $table = $this->getTable();
            
                    // this method is not needed if the table has no primary key
            Severity: Minor
            Found in src/Propel/Generator/Builder/Om/QueryBuilder.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 addFilterByFk has 53 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function addFilterByFk(string &$script, ForeignKey $fk): void
                {
                    $this->declareClasses(
                        '\Propel\Runtime\Collection\ObjectCollection',
                        '\Propel\Runtime\Exception\PropelException',
            Severity: Major
            Found in src/Propel/Generator/Builder/Om/QueryBuilder.php - About 2 hrs to fix

              Method addFilterByRefFk has 52 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function addFilterByRefFk(string &$script, ForeignKey $fk): void
                  {
                      $this->declareClasses(
                          '\Propel\Runtime\Collection\ObjectCollection',
                          '\Propel\Runtime\Exception\PropelException',
              Severity: Major
              Found in src/Propel/Generator/Builder/Om/QueryBuilder.php - About 2 hrs to fix

                Method addFilterByPrimaryKeys has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function addFilterByPrimaryKeys(string &$script): void
                    {
                        $script .= "
                    /**
                     * Filter the query by a list of primary keys
                Severity: Minor
                Found in src/Propel/Generator/Builder/Om/QueryBuilder.php - About 1 hr to fix

                  Method addFindPk has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function addFindPk(string &$script): void
                      {
                          $class = $this->getObjectClassName();
                          $tableMapClassName = $this->getTableMapClassName();
                          $table = $this->getTable();
                  Severity: Minor
                  Found in src/Propel/Generator/Builder/Om/QueryBuilder.php - About 1 hr to fix

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

                        protected function addClassBody(string &$script): void
                        {
                            $table = $this->getTable();
                    
                            // namespaces
                    Severity: Minor
                    Found in src/Propel/Generator/Builder/Om/QueryBuilder.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 addPrune has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function addPrune(string &$script): void
                        {
                            $table = $this->getTable();
                            $class = $this->getObjectClassName();
                            $objectName = '$' . $table->getCamelCaseName();
                    Severity: Minor
                    Found in src/Propel/Generator/Builder/Om/QueryBuilder.php - About 1 hr to fix

                      Method addDoOnDeleteCascade has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function addDoOnDeleteCascade(string &$script): void
                          {
                              $table = $this->getTable();
                              $script .= "
                          /**
                      Severity: Minor
                      Found in src/Propel/Generator/Builder/Om/QueryBuilder.php - About 1 hr to fix

                        Method addDoOnDeleteSetNull has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function addDoOnDeleteSetNull(string &$script): void
                            {
                                $table = $this->getTable();
                                $script .= "
                            /**
                        Severity: Minor
                        Found in src/Propel/Generator/Builder/Om/QueryBuilder.php - About 1 hr to fix

                          Method addDelete has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function addDelete(string &$script): void
                              {
                                  $script .= "
                              /**
                               * Performs a DELETE on the database based on the current ModelCriteria
                          Severity: Minor
                          Found in src/Propel/Generator/Builder/Om/QueryBuilder.php - About 1 hr to fix

                            Method addFilterByPrimaryKey has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                protected function addFilterByPrimaryKey(string &$script): void
                                {
                                    $script .= "
                                /**
                                 * Filter the query by primary key
                            Severity: Minor
                            Found in src/Propel/Generator/Builder/Om/QueryBuilder.php - About 1 hr to fix

                              Method addFindPks has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  protected function addFindPks(string &$script): void
                                  {
                                      $this->declareClasses(
                                          '\Propel\Runtime\Collection\Collection',
                                          '\Propel\Runtime\Connection\ConnectionInterface',
                              Severity: Minor
                              Found in src/Propel/Generator/Builder/Om/QueryBuilder.php - About 1 hr to fix

                                Method addFilterByArrayCol has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    protected function addFilterByArrayCol(string &$script, Column $col): void
                                    {
                                        $singularPhpName = $col->getPhpSingularName();
                                        $colName = $col->getName();
                                        $variableName = $col->getCamelCaseName();
                                Severity: Minor
                                Found in src/Propel/Generator/Builder/Om/QueryBuilder.php - About 1 hr to fix

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

                                      protected function addDoOnDeleteSetNull(string &$script): void
                                      {
                                          $table = $this->getTable();
                                          $script .= "
                                      /**
                                  Severity: Minor
                                  Found in src/Propel/Generator/Builder/Om/QueryBuilder.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 addDoOnDeleteCascade has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      protected function addDoOnDeleteCascade(string &$script): void
                                      {
                                          $table = $this->getTable();
                                          $script .= "
                                      /**
                                  Severity: Minor
                                  Found in src/Propel/Generator/Builder/Om/QueryBuilder.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 addFilterByFk has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      protected function addFilterByFk(string &$script, ForeignKey $fk): void
                                      {
                                          $this->declareClasses(
                                              '\Propel\Runtime\Collection\ObjectCollection',
                                              '\Propel\Runtime\Exception\PropelException',
                                  Severity: Minor
                                  Found in src/Propel/Generator/Builder/Om/QueryBuilder.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 isDeleteCascadeEmulationNeeded has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      protected function isDeleteCascadeEmulationNeeded(): bool
                                      {
                                          $table = $this->getTable();
                                          if ((!$this->getPlatform()->supportsNativeDeleteTrigger() || $this->getBuildProperty('generator.objectModel.emulateForeignKeyConstraints')) && count($table->getReferrers()) > 0) {
                                              foreach ($table->getReferrers() as $fk) {
                                  Severity: Minor
                                  Found in src/Propel/Generator/Builder/Om/QueryBuilder.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 isDeleteSetNullEmulationNeeded has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      protected function isDeleteSetNullEmulationNeeded(): bool
                                      {
                                          $table = $this->getTable();
                                          if ((!$this->getPlatform()->supportsNativeDeleteTrigger() || $this->getBuildProperty('generator.objectModel.emulateForeignKeyConstraints')) && count($table->getReferrers()) > 0) {
                                              foreach ($table->getReferrers() as $fk) {
                                  Severity: Minor
                                  Found in src/Propel/Generator/Builder/Om/QueryBuilder.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 addFilterByPrimaryKeys has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      protected function addFilterByPrimaryKeys(string &$script): void
                                      {
                                          $script .= "
                                      /**
                                       * Filter the query by a list of primary keys
                                  Severity: Minor
                                  Found in src/Propel/Generator/Builder/Om/QueryBuilder.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 addUseRelatedQuery has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      protected function addUseRelatedQuery(string &$script, Table $fkTable, string $queryClass, string $relationName, string $joinType): void
                                  Severity: Minor
                                  Found in src/Propel/Generator/Builder/Om/QueryBuilder.php - About 35 mins to fix

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

                                        protected function addWithRelatedQuery(string &$script, Table $fkTable, string $queryClass, string $relationName, string $joinType): void
                                    Severity: Minor
                                    Found in src/Propel/Generator/Builder/Om/QueryBuilder.php - About 35 mins to fix

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

                                              string &$script,
                                              Table $fkTable,
                                              string $queryClass,
                                              string $relationName,
                                              string $joinType
                                      Severity: Minor
                                      Found in src/Propel/Generator/Builder/Om/QueryBuilder.php - About 35 mins to fix

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

                                            protected function addFindPk(string &$script): void
                                            {
                                                $class = $this->getObjectClassName();
                                                $tableMapClassName = $this->getTableMapClassName();
                                                $table = $this->getTable();
                                        Severity: Minor
                                        Found in src/Propel/Generator/Builder/Om/QueryBuilder.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 addFilterByRefFk has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                            protected function addFilterByRefFk(string &$script, ForeignKey $fk): void
                                            {
                                                $this->declareClasses(
                                                    '\Propel\Runtime\Collection\ObjectCollection',
                                                    '\Propel\Runtime\Exception\PropelException',
                                        Severity: Minor
                                        Found in src/Propel/Generator/Builder/Om/QueryBuilder.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

                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                        Open

                                            protected function isDeleteCascadeEmulationNeeded(): bool
                                            {
                                                $table = $this->getTable();
                                                if ((!$this->getPlatform()->supportsNativeDeleteTrigger() || $this->getBuildProperty('generator.objectModel.emulateForeignKeyConstraints')) && count($table->getReferrers()) > 0) {
                                                    foreach ($table->getReferrers() as $fk) {
                                        Severity: Minor
                                        Found in src/Propel/Generator/Builder/Om/QueryBuilder.php and 1 other location - About 30 mins to fix
                                        src/Propel/Generator/Builder/Om/QueryBuilder.php on lines 304..316

                                        Duplicated Code

                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                        Tuning

                                        This issue has a mass of 91.

                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                        Refactorings

                                        Further Reading

                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                        Open

                                            protected function isDeleteSetNullEmulationNeeded(): bool
                                            {
                                                $table = $this->getTable();
                                                if ((!$this->getPlatform()->supportsNativeDeleteTrigger() || $this->getBuildProperty('generator.objectModel.emulateForeignKeyConstraints')) && count($table->getReferrers()) > 0) {
                                                    foreach ($table->getReferrers() as $fk) {
                                        Severity: Minor
                                        Found in src/Propel/Generator/Builder/Om/QueryBuilder.php and 1 other location - About 30 mins to fix
                                        src/Propel/Generator/Builder/Om/QueryBuilder.php on lines 285..297

                                        Duplicated Code

                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                        Tuning

                                        This issue has a mass of 91.

                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                        Refactorings

                                        Further Reading

                                        There are no issues that match your filters.

                                        Category
                                        Status