propelorm/Propel2

View on GitHub

Showing 740 of 740 total issues

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

    protected function addGetNext(string &$script): void
    {
        $useScope = $this->behavior->useScope();
        // The generateScopePhp() method below contains the following list of variables:
        // list($methodSignature, $paramsDoc, $buildScope, $buildScopeVars)
src/Propel/Generator/Behavior/Sortable/SortableBehaviorObjectBuilderModifier.php on lines 525..567

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

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

Method hydratePropelObjectCollection has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function &hydratePropelObjectCollection(array $row): array
    {
        $col = 0;

        // hydrate main object or take it from registry
Severity: Major
Found in src/Propel/Runtime/Formatter/AbstractFormatterWithHydration.php - About 2 hrs to fix

    Method addFKAccessor has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function addFKAccessor(string &$script, ForeignKey $fk): void
        {
            $varName = $this->getFKVarName($fk);
            $fkQueryBuilder = $this->getNewStubQueryBuilder($fk->getForeignTable());
            $fkObjectBuilder = $this->getNewObjectBuilder($fk->getForeignTable())->getStubObjectBuilder();
    Severity: Major
    Found in src/Propel/Generator/Builder/Om/ObjectBuilder.php - About 2 hrs to fix

      Method getReverseDiff has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getReverseDiff(): self
          {
              $diff = new self();
      
              // tables
      Severity: Major
      Found in src/Propel/Generator/Model/Diff/TableDiff.php - About 2 hrs to fix

        CollectionIterator has 23 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class CollectionIterator extends ArrayIterator implements IteratorInterface
        {
            /**
             * @var \Propel\Runtime\Collection\Collection
             */
        Severity: Minor
        Found in src/Propel/Runtime/Collection/CollectionIterator.php - About 2 hrs to fix

          OraclePlatform has 23 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class OraclePlatform extends DefaultPlatform
          {
              /**
               * Initializes db specific domain mapping.
               *
          Severity: Minor
          Found in src/Propel/Generator/Platform/OraclePlatform.php - About 2 hrs to fix

            Method addColumns has 62 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function addColumns(Table $table): void
                {
                    $tableName = $table->getName();
            
                    /** @var \PDOStatement $stmt */
            Severity: Major
            Found in src/Propel/Generator/Reverse/SqliteSchemaParser.php - About 2 hrs to fix

              Method addLazyLoaderBody has 62 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function addLazyLoaderBody(string &$script, Column $column): void
                  {
                      $platform = $this->getPlatform();
                      $clo = $column->getLowercasedName();
              
              
              Severity: Major
              Found in src/Propel/Generator/Builder/Om/ObjectBuilder.php - About 2 hrs to fix

                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

                  Method setupObject has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function setupObject(): void
                      {
                          try {
                              $database = $this->getDatabase();
                              $platform = ($this->hasPlatform()) ? $this->getPlatform() : null;
                  Severity: Major
                  Found in src/Propel/Generator/Model/Column.php - About 2 hrs to fix

                    File ObjectCollection.php has 269 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: Minor
                    Found in src/Propel/Runtime/Collection/ObjectCollection.php - About 2 hrs to fix

                      Function arrayToDOM has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function arrayToDOM(array $array, DOMElement $rootElement, ?string $charset = null): DOMElement
                          {
                              foreach ($array as $key => $value) {
                                  if (is_numeric($key)) {
                                      $key = $rootElement->nodeName;
                      Severity: Minor
                      Found in src/Propel/Runtime/Parser/XmlParser.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 addForeignKeys has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function addForeignKeys(Table $table): void
                          {
                              $database = $table->getDatabase();
                      
                              /** @var \PDOStatement $stmt */
                      Severity: Minor
                      Found in src/Propel/Generator/Reverse/SqliteSchemaParser.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 addMutatorCloseBody has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function addMutatorCloseBody(string &$script, Column $column): void
                          {
                              $table = $this->getTable();
                      
                              if ($column->isForeignKey()) {
                      Severity: Minor
                      Found in src/Propel/Generator/Builder/Om/ObjectBuilder.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 addToArray has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function addToArray(string &$script): void
                          {
                              $fks = $this->getTable()->getForeignKeys();
                              $referrers = $this->getTable()->getReferrers();
                              $hasFks = count($fks) > 0 || count($referrers) > 0;
                      Severity: Minor
                      Found in src/Propel/Generator/Builder/Om/ObjectBuilder.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 addColumnMutatorMethods has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function addColumnMutatorMethods(string &$script): void
                          {
                              foreach ($this->getTable()->getColumns() as $col) {
                                  if ($col->getType() === PropelTypes::OBJECT) {
                                      $this->addObjectMutator($script, $col);
                      Severity: Minor
                      Found in src/Propel/Generator/Builder/Om/AbstractObjectBuilder.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 compareForeignKeys has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function compareForeignKeys(bool $caseInsensitive = false): int
                          {
                              $fkDifferences = 0;
                              $fromTableFks = $this->getFromTable()->getForeignKeys();
                              $toTableFks = $this->getToTable()->getForeignKeys();
                      Severity: Minor
                      Found in src/Propel/Generator/Model/Diff/TableComparator.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 __toString has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function __toString(): string
                          {
                              $tables = [];
                              foreach ($this->getTables() as $table) {
                                  $columns = [];
                      Severity: Minor
                      Found in src/Propel/Generator/Model/Database.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 addMakeSlugUnique has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function addMakeSlugUnique(string &$script): void
                          {
                              $script .= "
                      
                      /**
                      Severity: Major
                      Found in src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php - About 2 hrs to fix

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

                            protected function addRetrieveTree(string &$script): void
                            {
                                $queryClassName = $this->queryClassName;
                                $objectClassName = $this->objectClassName;
                                $useScope = $this->behavior->useScope();
                        src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifier.php on lines 577..609

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

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language