propelorm/Propel2

View on GitHub

Showing 740 of 740 total issues

Method getColumnDDL has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getColumnDDL(Column $col): string
    {
        $domain = $col->getDomain();

        $ddl = [$this->quoteIdentifier($col->getName())];
Severity: Minor
Found in src/Propel/Generator/Platform/PgsqlPlatform.php - About 1 hr to fix

    Method queryMethods has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function queryMethods(AbstractOMBuilder $builder): string
        {
            $script = '';
    
            if ($this->withUpdatedAt()) {

      Consider simplifying this complex logical expression.
      Open

              if ($this->tableAlteringWorkaround && !$changedNotEditableThroughDirectDDL && $tableDiff->hasAddedColumns()) {
                  $addedCols = $tableDiff->getAddedColumns();
                  foreach ($addedCols as $column) {
                      $sqlChangeNotSupported =
                          //The column may not have a PRIMARY KEY or UNIQUE constraint.
      Severity: Critical
      Found in src/Propel/Generator/Platform/SqlitePlatform.php - About 1 hr to fix

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

            public function getModifyTableIndicesDDL(TableDiff $tableDiff): string
            {
                $ret = '';
        
                foreach ($tableDiff->getRemovedIndices() as $index) {
        Severity: Major
        Found in src/Propel/Generator/Platform/DefaultPlatform.php and 1 other location - About 1 hr to fix
        src/Propel/Generator/Platform/DefaultPlatform.php on lines 1037..1056

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

        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

            public function getModifyTableForeignKeysDDL(TableDiff $tableDiff): string
            {
                $ret = '';
        
                foreach ($tableDiff->getRemovedFks() as $fk) {
        Severity: Major
        Found in src/Propel/Generator/Platform/DefaultPlatform.php and 1 other location - About 1 hr to fix
        src/Propel/Generator/Platform/DefaultPlatform.php on lines 1008..1027

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

        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 addAddSelectColumns(string &$script): void
            {
                $script .= "
            /**
             * Add all the columns needed to create a new object.
        Severity: Major
        Found in src/Propel/Generator/Builder/Om/TableMapBuilder.php and 1 other location - About 1 hr to fix
        src/Propel/Generator/Builder/Om/TableMapBuilder.php on lines 1323..1360

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

        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 addRemoveSelectColumns(string &$script): void
            {
                $script .= "
            /**
             * Remove all the columns needed to create a new object.
        Severity: Major
        Found in src/Propel/Generator/Builder/Om/TableMapBuilder.php and 1 other location - About 1 hr to fix
        src/Propel/Generator/Builder/Om/TableMapBuilder.php on lines 1274..1312

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

        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 getColumnFromName has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

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

              protected function executeRollbackForDatasource(string $datasource, string $sql): void
              {
                  $connection = $this->migrationManager->getConnection($datasource);
          
                  if ($this->isVerbose()) {
          Severity: Minor
          Found in src/Propel/Generator/Command/Executor/RollbackExecutor.php - About 1 hr to fix

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

                public function build(): void
                {
                    foreach ($this->getDatabases() as $database) {
                        $dotSyntax = "digraph G {\n";
            
            
            Severity: Minor
            Found in src/Propel/Generator/Manager/GraphvizManager.php - About 1 hr to fix

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

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

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

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

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

                      public function fixNamespaceDeclarations(string $source): string
                      {
                          $cooperativeLexems = [T_WHITESPACE, T_NS_SEPARATOR, T_STRING];
                  
                          if (PHP_VERSION_ID >= 80000) {
                  Severity: Minor
                  Found in src/Propel/Generator/Util/QuickBuilder.php - About 1 hr to fix

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

                        protected function addShiftRLValues(string &$script): void
                        {
                            $objectClassName = $this->objectClassName;
                            $useScope = $this->behavior->useScope();
                            $tableMapClassName = $this->builder->getTableMapClass();

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

                          public function format(?DataFetcherInterface $dataFetcher = null)
                          {
                              $this->checkInit();
                              if ($dataFetcher) {
                                  $this->setDataFetcher($dataFetcher);
                      Severity: Minor
                      Found in src/Propel/Runtime/Formatter/ObjectFormatter.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 buildFixtures has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function buildFixtures(string $fixturesDir, array $connections, InputInterface $input, OutputInterface $output): int
                          {
                              if (!file_exists($this->root . '/' . $fixturesDir)) {
                                  $output->writeln(sprintf('<error>Directory "%s" not found.</error>', $fixturesDir));
                      
                      
                      Severity: Minor
                      Found in src/Propel/Generator/Command/TestPrepareCommand.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 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

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

                          public function compareIndices(bool $caseInsensitive = false): int
                          {
                              $indexDifferences = 0;
                              $fromTableIndices = array_merge($this->getFromTable()->getIndices(), $this->getFromTable()->getUnices());
                              $toTableIndices = array_merge($this->getToTable()->getIndices(), $this->getToTable()->getUnices());
                      Severity: Minor
                      Found in src/Propel/Generator/Model/Diff/TableComparator.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 mergeStatements has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function mergeStatements(string $sql): string
                          {
                              $sqlParser = new SqlParser();
                              $sqlParser->setSQL($sql);
                              $statements = $sqlParser->explodeIntoStatements();
                      Severity: Minor
                      Found in src/Propel/Generator/Platform/Util/AlterTableStatementMerger.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

                      Severity
                      Category
                      Status
                      Source
                      Language