Showing 13 of 13 total issues

File Migration.php has 417 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace atk4\schema;
Severity: Minor
Found in src/Migration.php - About 6 hrs to fix

    Function setDb has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

        public function setDb($db_data, $import_data = true)
        {
            $this->tables = array_keys($db_data);
    
            // create tables
    Severity: Minor
    Found in src/PhpunitTestCase.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

    Migration has 32 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class Migration extends Expression
    {
        public const REF_TYPE_NONE = 0;
        public const REF_TYPE_LINK = 1;
        public const REF_TYPE_PRIMARY = 2;
    Severity: Minor
    Found in src/Migration.php - About 4 hrs to fix

      Function run has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          public function run(): string
          {
              $changes = $added = $altered = $dropped = 0;
      
              // We use this to read fields from SQL
      Severity: Minor
      Found in src/Migration.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 getDb has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getDb($tables = null, bool $no_id = false)
          {
              $tables = $tables ?: $this->tables;
      
              if (is_string($tables)) {
      Severity: Minor
      Found in src/PhpunitTestCase.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 setDb has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function setDb($db_data, $import_data = true)
          {
              $this->tables = array_keys($db_data);
      
              // create tables
      Severity: Minor
      Found in src/PhpunitTestCase.php - About 1 hr to fix

        Method run has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function run(): string
            {
                $changes = $added = $altered = $dropped = 0;
        
                // We use this to read fields from SQL
        Severity: Minor
        Found in src/Migration.php - About 1 hr to fix

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

              public function setModel(Model $m): Model
              {
                  $this->table($m->table);
          
                  foreach ($m->getFields() as $field) {
          Severity: Minor
          Found in src/Migration.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 __construct has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function __construct($source, $params = [])
              {
                  // IDENTITY column or column with SEQUENCE as a default value is available only as of Oracle 12c
                  // see https://stackoverflow.com/questions/10613846/create-table-with-sequence-nextval-in-oracle#10613875
                  $this->templates['create'] = <<<'EOT'
          Severity: Minor
          Found in src/Migration/Oracle.php - About 1 hr to fix

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

                public function _render_statements(): string
                {
                    $result = [];
            
                    if (isset($this->args['dropField'])) {
            Severity: Minor
            Found in src/Migration.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 _render_statements has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function _render_statements(): string
                {
                    $result = [];
            
                    if (isset($this->args['dropField'])) {
            Severity: Minor
            Found in src/Migration/Postgresql.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 createModel has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function createModel($persistence, $table = null): Model
                {
                    $this['table'] = $table ?? $this['table'];
            
                    $m = new Model([$persistence, 'table' => $this['table']]);
            Severity: Minor
            Found in src/Migration.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 getSqlFieldType has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getSqlFieldType(?string $type, array $options = []): ?string
                {
                    if ($type !== null) {
                        $type = strtolower($type);
                    }
            Severity: Minor
            Found in src/Migration.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

            Severity
            Category
            Status
            Source
            Language