propelorm/Propel2

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

Summary

Maintainability
F
4 days
Test Coverage

File AbstractOMBuilder.php has 603 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/AbstractOMBuilder.php - About 1 day to fix

    AbstractOMBuilder has 51 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class AbstractOMBuilder extends DataModelBuilder
    {
        use PathTrait;
    
        /**
    Severity: Major
    Found in src/Propel/Generator/Builder/Om/AbstractOMBuilder.php - About 7 hrs to fix

      Function needAliasForClassName has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function needAliasForClassName(string $class, string $classNamespace): bool
          {
              // Should remove this check by not allowing nullable return values in getNamespace
              if ($this->getNamespace() === null) {
                  return false;
      Severity: Minor
      Found in src/Propel/Generator/Builder/Om/AbstractOMBuilder.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 getCrossFKsPhpNameAffix has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function getCrossFKsPhpNameAffix(CrossForeignKeys $crossFKs, bool $plural = true): string
          {
              $names = [];
      
              if ($plural) {
      Severity: Minor
      Found in src/Propel/Generator/Builder/Om/AbstractOMBuilder.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 declareClassNamespace has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          public function declareClassNamespace(string $class, string $namespace = '', $alias = false): string
          {
              $namespace = trim($namespace, '\\');
      
              // check if the class is already declared
      Severity: Minor
      Found in src/Propel/Generator/Builder/Om/AbstractOMBuilder.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 getUseStatements has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getUseStatements(?string $ignoredNamespace = null): string
          {
              $script = '';
              $declaredClasses = $this->declaredClasses;
              unset($declaredClasses[$ignoredNamespace]);
      Severity: Minor
      Found in src/Propel/Generator/Builder/Om/AbstractOMBuilder.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 getRefRelatedBySuffix has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          protected static function getRefRelatedBySuffix(ForeignKey $fk): string
          {
              $relCol = '';
              foreach ($fk->getMapping() as $mapping) {
                  [$localColumn, $foreignValueOrColumn] = $mapping;
      Severity: Minor
      Found in src/Propel/Generator/Builder/Om/AbstractOMBuilder.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 applyBehaviorModifierBase has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function applyBehaviorModifierBase(string $hookName, string $modifier, string &$script, string $tab = '        '): void
          {
              $modifierGetter = 'get' . $modifier;
              foreach ($this->getTable()->getBehaviors() as $behavior) {
                  $modifier = $behavior->$modifierGetter();
      Severity: Minor
      Found in src/Propel/Generator/Builder/Om/AbstractOMBuilder.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 declareClassNamespace has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function declareClassNamespace(string $class, string $namespace = '', $alias = false): string
          {
              $namespace = trim($namespace, '\\');
      
              // check if the class is already declared
      Severity: Minor
      Found in src/Propel/Generator/Builder/Om/AbstractOMBuilder.php - About 1 hr to fix

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

            protected function needAliasForClassName(string $class, string $classNamespace): bool
            {
                // Should remove this check by not allowing nullable return values in getNamespace
                if ($this->getNamespace() === null) {
                    return false;
        Severity: Minor
        Found in src/Propel/Generator/Builder/Om/AbstractOMBuilder.php - About 1 hr to fix

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

              protected function extractCrossInformation(
                  CrossForeignKeys $crossFKs,
                  $crossFKToIgnore,
                  array &$signature,
                  array &$shortSignature,
          Severity: Minor
          Found in src/Propel/Generator/Builder/Om/AbstractOMBuilder.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 extractCrossInformation has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  CrossForeignKeys $crossFKs,
                  $crossFKToIgnore,
                  array &$signature,
                  array &$shortSignature,
                  array &$normalizedShortSignature,
          Severity: Minor
          Found in src/Propel/Generator/Builder/Om/AbstractOMBuilder.php - About 45 mins to fix

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

                private function clean(string $content): string
                {
                    // line feed
                    $content = str_replace("\r\n", "\n", $content);
            
            
            Severity: Minor
            Found in src/Propel/Generator/Builder/Om/AbstractOMBuilder.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 getRelatedBySuffix has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                protected static function getRelatedBySuffix(ForeignKey $fk): string
                {
                    $relCol = '';
            
                    foreach ($fk->getMapping() as $mapping) {
            Severity: Minor
            Found in src/Propel/Generator/Builder/Om/AbstractOMBuilder.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 false;
            Severity: Major
            Found in src/Propel/Generator/Builder/Om/AbstractOMBuilder.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return true;
              Severity: Major
              Found in src/Propel/Generator/Builder/Om/AbstractOMBuilder.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return $this->declareClassNamespace($class, $namespace, $autoAliasName);
                Severity: Major
                Found in src/Propel/Generator/Builder/Om/AbstractOMBuilder.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return true;
                  Severity: Major
                  Found in src/Propel/Generator/Builder/Om/AbstractOMBuilder.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return true;
                    Severity: Major
                    Found in src/Propel/Generator/Builder/Om/AbstractOMBuilder.php - About 30 mins to fix

                      Function getCrossRefFKGetterName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function getCrossRefFKGetterName(CrossForeignKeys $crossFKs, ForeignKey $excludeFK): string
                          {
                              $names = [];
                      
                              $fks = $crossFKs->getCrossForeignKeys();
                      Severity: Minor
                      Found in src/Propel/Generator/Builder/Om/AbstractOMBuilder.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

                      There are no issues that match your filters.

                      Category
                      Status