php-yaoi/php-yaoi

View on GitHub
src/Database/Pgsql/SchemaReader.php

Summary

Maintainability
C
1 day
Test Coverage

Function getColumns has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    public function getColumns($tableName) {
        //echo PHP_EOL . 'table: ' . $tableName . PHP_EOL;
        $res = $this->database
            ->select()
            ->select('c.column_name, c.is_nullable, c.data_type, c.column_default, tc.constraint_type')
Severity: Minor
Found in src/Database/Pgsql/SchemaReader.php - About 3 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 getColumns has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getColumns($tableName) {
        //echo PHP_EOL . 'table: ' . $tableName . PHP_EOL;
        $res = $this->database
            ->select()
            ->select('c.column_name, c.is_nullable, c.data_type, c.column_default, tc.constraint_type')
Severity: Minor
Found in src/Database/Pgsql/SchemaReader.php - About 1 hr to fix

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

        private function readIndexes(Table $def) {
            $res = $this->database->select()
                ->select('t.relname as table_name, i.relname as index_name, a.attname as column_name')
                ->select('ix.indisunique::int as is_unique,ix.indisprimary::int as is_primary')
                ->from('pg_class t, pg_class i, pg_index ix, pg_attribute a')
    Severity: Minor
    Found in src/Database/Pgsql/SchemaReader.php - About 1 hr to fix

      Method readForeignKeys has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function readForeignKeys(Table $def) {
              $res = $this->database
                  ->select()
                  ->select('tc.constraint_name, kcu.column_name')
                  ->select('ccu.table_name  AS foreign_table_name, ccu.column_name AS foreign_column_name')
      Severity: Minor
      Found in src/Database/Pgsql/SchemaReader.php - About 1 hr to fix

        Method getColumnFlagsByString has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getColumnFlagsByString($typeString) {
                $phpType = Column::AUTO_TYPE;
        
                switch (true) {
                    case 'integer' === substr($typeString, 0, 7):
        Severity: Minor
        Found in src/Database/Pgsql/SchemaReader.php - About 1 hr to fix

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

              private function readIndexes(Table $def) {
                  $res = $this->database->select()
                      ->select('t.relname as table_name, i.relname as index_name, a.attname as column_name')
                      ->select('ix.indisunique::int as is_unique,ix.indisprimary::int as is_primary')
                      ->from('pg_class t, pg_class i, pg_index ix, pg_attribute a')
          Severity: Minor
          Found in src/Database/Pgsql/SchemaReader.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

          Avoid deeply nested control flow statements.
          Open

                                  if ("'" === $default[0]) {
                                      $pos = strrpos($default, "'::");
                                      if ($pos !== false) {
                                          $default = substr($default, 1, $pos - 1);
                                      }
          Severity: Major
          Found in src/Database/Pgsql/SchemaReader.php - About 45 mins to fix

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

                public function getColumnFlagsByString($typeString) {
                    $phpType = Column::AUTO_TYPE;
            
                    switch (true) {
                        case 'integer' === substr($typeString, 0, 7):
            Severity: Minor
            Found in src/Database/Pgsql/SchemaReader.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