propelorm/Propel2

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

Summary

Maintainability
F
1 wk
Test Coverage

File TableMapBuilder.php has 889 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * 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/TableMapBuilder.php - About 2 days to fix

    TableMapBuilder has 40 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class TableMapBuilder extends AbstractOMBuilder
    {
        /**
         * Gets the package for the map builder classes.
         * @return string
    Severity: Minor
    Found in src/Propel/Generator/Builder/Om/TableMapBuilder.php - About 5 hrs to fix

      Function addInitialize has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function addInitialize(&$script)
          {
      
              $table = $this->getTable();
              $platform = $this->getPlatform();
      Severity: Minor
      Found in src/Propel/Generator/Builder/Om/TableMapBuilder.php - About 5 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 addInitialize has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function addInitialize(&$script)
          {
      
              $table = $this->getTable();
              $platform = $this->getPlatform();
      Severity: Major
      Found in src/Propel/Generator/Builder/Om/TableMapBuilder.php - About 3 hrs to fix

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

            protected function addGetPrimaryKeyFromRow(&$script)
            {
                $script .= "
            /**
             * Retrieves the primary key from the DB resultset row
        Severity: Minor
        Found in src/Propel/Generator/Builder/Om/TableMapBuilder.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 addDoDelete has 68 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function addDoDelete(&$script)
            {
                $table = $this->getTable();
                $script .= "
            /**
        Severity: Major
        Found in src/Propel/Generator/Builder/Om/TableMapBuilder.php - About 2 hrs to fix

          Method addDoInsert has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function addDoInsert(&$script)
              {
                  $table = $this->getTable();
                  $tableMapClass = $this->getTableMapClass();
          
          
          Severity: Minor
          Found in src/Propel/Generator/Builder/Om/TableMapBuilder.php - About 2 hrs to fix

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

                protected function addDoDelete(&$script)
                {
                    $table = $this->getTable();
                    $script .= "
                /**
            Severity: Minor
            Found in src/Propel/Generator/Builder/Om/TableMapBuilder.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 addGetPrimaryKeyFromRow has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function addGetPrimaryKeyFromRow(&$script)
                {
                    $script .= "
                /**
                 * Retrieves the primary key from the DB resultset row
            Severity: Minor
            Found in src/Propel/Generator/Builder/Om/TableMapBuilder.php - About 1 hr to fix

              Method addClassBody has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function addClassBody(&$script)
                  {
                      $table = $this->getTable();
              
                      $this->declareClasses(
              Severity: Minor
              Found in src/Propel/Generator/Builder/Om/TableMapBuilder.php - About 1 hr to fix

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

                    protected function addFieldsAttributes()
                    {
                        $tableColumns = $this->getTable()->getColumns();
                
                        $fieldNamesPhpName       = '';
                Severity: Minor
                Found in src/Propel/Generator/Builder/Om/TableMapBuilder.php - About 1 hr to fix

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

                      protected function addGetOMClass_Inheritance(&$script)
                      {
                          $col = $this->getTable()->getChildrenColumn();
                          $script .= "
                      /**
                  Severity: Minor
                  Found in src/Propel/Generator/Builder/Om/TableMapBuilder.php - About 1 hr to fix

                    Method addBuildRelations has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function addBuildRelations(&$script)
                        {
                            $script .= "
                        /**
                         * Build the RelationMap objects for this table relationships
                    Severity: Minor
                    Found in src/Propel/Generator/Builder/Om/TableMapBuilder.php - About 1 hr to fix

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

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

                        Consider simplifying this complex logical expression.
                        Open

                                    if ($col->isPrimaryKey()
                                        && $col->isAutoIncrement()
                                        && 'none' !== $table->getIdMethod()
                                        && !$table->isAllowPkInsert()
                                    ) {
                        Severity: Critical
                        Found in src/Propel/Generator/Builder/Om/TableMapBuilder.php - About 1 hr to fix

                          Function addGetBehaviors has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                              protected function addGetBehaviors(&$script)
                              {
                                  $behaviors = $this->getTable()->getBehaviors();
                                  if ($behaviors) {
                                      $script .= "
                          Severity: Minor
                          Found in src/Propel/Generator/Builder/Om/TableMapBuilder.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 addPopulateObject has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

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

                            Method addGetPrimaryKeyHash has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                protected function addGetPrimaryKeyHash(&$script)
                                {
                                    // We have to iterate through all the columns so that we know the offset of the primary
                                    // key columns.
                                    $n = 0;
                            Severity: Minor
                            Found in src/Propel/Generator/Builder/Om/TableMapBuilder.php - About 1 hr to fix

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

                                  public function addInstancePool()
                                  {
                                      // No need to override instancePool if the PK is not composite
                                      if (!$this->getTable()->hasCompositePrimaryKey()) {
                                          return '';
                              Severity: Minor
                              Found in src/Propel/Generator/Builder/Om/TableMapBuilder.php - About 1 hr to fix

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

                                    protected function addGetBehaviors(&$script)
                                    {
                                        $behaviors = $this->getTable()->getBehaviors();
                                        if ($behaviors) {
                                            $script .= "
                                Severity: Minor
                                Found in src/Propel/Generator/Builder/Om/TableMapBuilder.php - About 1 hr to fix

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

                                      protected function addBuildRelations(&$script)
                                      {
                                          $script .= "
                                      /**
                                       * Build the RelationMap objects for this table relationships
                                  Severity: Minor
                                  Found in src/Propel/Generator/Builder/Om/TableMapBuilder.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 addClearRelatedInstancePool has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function addClearRelatedInstancePool()
                                      {
                                          $table = $this->getTable();
                                          $relatedClassNames = [];
                                  
                                  
                                  Severity: Minor
                                  Found in src/Propel/Generator/Builder/Om/TableMapBuilder.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 addDoInsert has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      protected function addDoInsert(&$script)
                                      {
                                          $table = $this->getTable();
                                          $tableMapClass = $this->getTableMapClass();
                                  
                                  
                                  Severity: Minor
                                  Found in src/Propel/Generator/Builder/Om/TableMapBuilder.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 addGetPrimaryKeyHash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      protected function addGetPrimaryKeyHash(&$script)
                                      {
                                          // We have to iterate through all the columns so that we know the offset of the primary
                                          // key columns.
                                          $n = 0;
                                  Severity: Minor
                                  Found in src/Propel/Generator/Builder/Om/TableMapBuilder.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 addAddSelectColumns has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      protected function addAddSelectColumns(&$script)
                                      {
                                          $script .= "
                                      /**
                                       * Add all the columns needed to create a new object.
                                  Severity: Minor
                                  Found in src/Propel/Generator/Builder/Om/TableMapBuilder.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 addValueSetColumnConstants has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      protected function addValueSetColumnConstants(&$script)
                                      {
                                          foreach ($this->getTable()->getColumns() as $col) {
                                              if ($col->isValueSetType()) {
                                                  $script .= "
                                  Severity: Minor
                                  Found in src/Propel/Generator/Builder/Om/TableMapBuilder.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 addValueSetColumnAttributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      protected function addValueSetColumnAttributes(&$script)
                                      {
                                          $script .= "
                                      /** The enumerated values for this table */
                                      protected static \$enumValueSets = array(";
                                  Severity: Minor
                                  Found in src/Propel/Generator/Builder/Om/TableMapBuilder.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

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

                                              if ($col->isPrimaryKey()) {
                                                  if ($col->isForeignKey()) {
                                                      foreach ($col->getForeignKeys() as $fk) {
                                                          $script .= "
                                          \$this->addForeignPrimaryKey('$columnName', '$cfc', '".$col->getType()."' , '".$fk->getForeignTableName()."', '".$fk->getMappedForeignColumn($col->getName())."', ".($col->isNotNull() ? 'true' : 'false').", ".$size.", $default);";
                                  Severity: Major
                                  Found in src/Propel/Generator/Builder/Om/TableMapBuilder.php and 1 other location - About 5 hrs to fix
                                  src/Propel/Generator/Builder/Om/TableMapBuilder.php on lines 517..527

                                  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 158.

                                  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

                                              } else {
                                                  if ($col->isForeignKey()) {
                                                      foreach ($col->getForeignKeys() as $fk) {
                                                          $script .= "
                                          \$this->addForeignKey('$columnName', '$cfc', '".$col->getType()."', '".$fk->getForeignTableName()."', '".$fk->getMappedForeignColumn($col->getName())."', ".($col->isNotNull() ? 'true' : 'false').", ".$size.", $default);";
                                  Severity: Major
                                  Found in src/Propel/Generator/Builder/Om/TableMapBuilder.php and 1 other location - About 5 hrs to fix
                                  src/Propel/Generator/Builder/Om/TableMapBuilder.php on lines 507..527

                                  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 158.

                                  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