N3XT0R/laravel-migration-generator

View on GitHub

Showing 18 of 19 total issues

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

    private function sortTablesByConstraintsRecursive(string $schema, array $tables, array $sortedTables = []): array
    {
        $unsortedTables = [];
        $connection = $this->getConnection();
        foreach ($tables as $tableName) {
Severity: Minor
Found in src/Service/Parser/SchemaParser.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 generateField has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    protected function generateField(FieldEntity $fieldEntity): string
    {
        $argumentString = '';
        $arguments = $fieldEntity->getArguments();
        $options = $fieldEntity->getOptions();
Severity: Minor
Found in src/Service/Generator/Compiler/Mapper/FieldMapper.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 writeToDisk has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function writeToDisk(
        string $name,
        string $path,
        int $currentAmount = -1,
        int $maxAmount = -1,
Severity: Minor
Found in src/Service/Generator/Compiler/MigrationCompiler.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 sortTablesByConstraintsRecursive has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function sortTablesByConstraintsRecursive(string $schema, array $tables, array $sortedTables = []): array
    {
        $unsortedTables = [];
        $connection = $this->getConnection();
        foreach ($tables as $tableName) {
Severity: Minor
Found in src/Service/Parser/SchemaParser.php - About 1 hr to fix

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

        protected function generateField(FieldEntity $fieldEntity): string
        {
            $argumentString = '';
            $arguments = $fieldEntity->getArguments();
            $options = $fieldEntity->getOptions();
    Severity: Minor
    Found in src/Service/Generator/Compiler/Mapper/FieldMapper.php - About 1 hr to fix

      Method resolveTableSchema has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function resolveTableSchema(string $schema, string $table): ResultEntity
          {
              $definitions = $this->getDefinitions();
              $sortedDefinitions = TopSort::sort($definitions);
              $connection = $this->getDoctrineConnection();
      Severity: Minor
      Found in src/Service/Generator/Resolver/DefinitionResolver.php - About 1 hr to fix

        Method convertColumnToFieldEntity has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function convertColumnToFieldEntity(string $table, Column $column): FieldEntity
            {
                $fieldEntity = new FieldEntity();
                $fieldEntity->setTable($table);
                $fieldEntity->setColumnName($column->getName());
        Severity: Minor
        Found in src/Service/Generator/Definition/TableDefinition.php - About 1 hr to fix

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

              protected function populateData(string $content, array $data): string
              {
                  foreach ($data as $key => $value) {
                      if (!is_object($value)) {
                          if (is_array($value)) {
          Severity: Minor
          Found in src/Service/Generator/Compiler/Engine/ReplaceEngine.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 generateByResult has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function generateByResult(ResultEntity $resultEntity, string $customMigrationClass = ''): void
              {
                  $this->setMigrationFiles([]);
                  $tableName = $resultEntity->getTableName();
                  $mapper = $this->getMapper();
          Severity: Minor
          Found in src/Service/Generator/Compiler/MigrationCompiler.php - About 1 hr to fix

            Function generateForeignKeys has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function generateForeignKeys(string $table, array $foreignKeys): array
                {
                    $result = [];
            
                    foreach ($foreignKeys as $foreignKey) {
            Severity: Minor
            Found in src/Service/Generator/Definition/ForeignKeyDefinition.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 generateIndexes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function generateIndexes(array $indexes): array
                {
                    $combinedIndexes = [];
                    foreach ($indexes as $index) {
                        if ($index instanceof Index === false || $index->getName() === 'PRIMARY') {
            Severity: Minor
            Found in src/Service/Generator/Definition/IndexDefinition.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 generateMigrationForTable has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    string $database,
                    string $table,
                    int $currentAmount = -1,
                    int $maxAmount = -1,
                    int $timestamp = -1
            Severity: Minor
            Found in src/Service/Generator/MigrationGenerator.php - About 35 mins to fix

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

                      string $name,
                      string $path,
                      int $currentAmount = -1,
                      int $maxAmount = -1,
                      int $timestamp = -1
              Severity: Minor
              Found in src/Service/Generator/Compiler/MigrationCompiler.php - About 35 mins to fix

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

                        string $name,
                        string $path,
                        int $currentAmount = -1,
                        int $maxAmount = -1,
                        int $timestamp = -1
                Severity: Minor
                Found in src/Service/Generator/Compiler/MigrationCompilerInterface.php - About 35 mins to fix

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

                          string $database,
                          string $table,
                          int $currentAmount = -1,
                          int $maxAmount = -1,
                          int $timestamp = -1
                  Severity: Minor
                  Found in src/Service/Generator/MigrationGeneratorInterface.php - About 35 mins to fix

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

                        protected function convertColumnToFieldEntity(string $table, Column $column): FieldEntity
                        {
                            $fieldEntity = new FieldEntity();
                            $fieldEntity->setTable($table);
                            $fieldEntity->setColumnName($column->getName());
                    Severity: Minor
                    Found in src/Service/Generator/Definition/TableDefinition.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 generateFields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function generateFields(string $table, array $columns): array
                        {
                            $result = [];
                    
                            if (0 !== count($columns)) {
                    Severity: Minor
                    Found in src/Service/Generator/Definition/TableDefinition.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 generateByResult has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function generateByResult(ResultEntity $resultEntity, string $customMigrationClass = ''): void
                        {
                            $this->setMigrationFiles([]);
                            $tableName = $resultEntity->getTableName();
                            $mapper = $this->getMapper();
                    Severity: Minor
                    Found in src/Service/Generator/Compiler/MigrationCompiler.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

                    Severity
                    Category
                    Status
                    Source
                    Language