phpmyadmin/phpmyadmin

View on GitHub
src/Database/Designer/Common.php

Summary

Maintainability
D
3 days
Test Coverage

File Common.php has 457 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace PhpMyAdmin\Database\Designer;
Severity: Minor
Found in src/Database/Designer/Common.php - About 7 hrs to fix

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

        public function addNewRelation(
            string $t1,
            string $f1,
            string $t2,
            string $f2,
    Severity: Minor
    Found in src/Database/Designer/Common.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

    Method addNewRelation has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function addNewRelation(
            string $t1,
            string $f1,
            string $t2,
            string $f2,
    Severity: Major
    Found in src/Database/Designer/Common.php - About 2 hrs to fix

      Function getScriptContr has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getScriptContr(array $designerTables): array
          {
              $this->dbi->selectDb(Current::$database);
              /** @var array{C_NAME: string[], DTN: string[], DCN: string[], STN: string[], SCN: string[]} $con */
              $con = ['C_NAME' => [], 'DTN' => [], 'DCN' => [], 'STN' => [], 'SCN' => []];
      Severity: Minor
      Found in src/Database/Designer/Common.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

      Method getScriptContr has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getScriptContr(array $designerTables): array
          {
              $this->dbi->selectDb(Current::$database);
              /** @var array{C_NAME: string[], DTN: string[], DCN: string[], STN: string[], SCN: string[]} $con */
              $con = ['C_NAME' => [], 'DTN' => [], 'DCN' => [], 'STN' => [], 'SCN' => []];
      Severity: Major
      Found in src/Database/Designer/Common.php - About 2 hrs to fix

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

            public function saveSetting(string $index, string $value): bool
            {
                $databaseDesignerSettingsFeature = $this->relation->getRelationParameters()->databaseDesignerSettingsFeature;
                if ($databaseDesignerSettingsFeature !== null) {
                    $cfgDesigner = [
        Severity: Minor
        Found in src/Database/Designer/Common.php - About 1 hr to fix

          Method removeRelation has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function removeRelation(string $t1, string $f1, string $t2, string $f2): array
              {
                  [$db1, $t1] = explode('.', $t1);
                  [$db2, $t2] = explode('.', $t2);
          
          
          Severity: Minor
          Found in src/Database/Designer/Common.php - About 1 hr to fix

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

                public function saveTablePositions(int $pg): bool
                {
                    $pdfFeature = $this->relation->getRelationParameters()->pdfFeature;
                    if ($pdfFeature === null) {
                        return false;
            Severity: Minor
            Found in src/Database/Designer/Common.php - About 1 hr to fix

              Method addNewRelation has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      string $t1,
                      string $f1,
                      string $t2,
                      string $f2,
                      string $onDelete,
              Severity: Major
              Found in src/Database/Designer/Common.php - About 1 hr to fix

                Avoid too many return statements within this method.
                Open

                            return [false, __('Error: Relational features are disabled!')];
                Severity: Major
                Found in src/Database/Designer/Common.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return [false, __('Error: Internal relationship could not be added!') . '<br>' . $error];
                  Severity: Major
                  Found in src/Database/Designer/Common.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return [true, __('Internal relationship has been added.')];
                    Severity: Major
                    Found in src/Database/Designer/Common.php - About 30 mins to fix

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

                          public function getAllKeys(array $designerTables): array
                          {
                              $keys = [];
                      
                              foreach ($designerTables as $designerTable) {
                      Severity: Minor
                      Found in src/Database/Designer/Common.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 removeRelation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function removeRelation(string $t1, string $f1, string $t2, string $f2): array
                          {
                              [$db1, $t1] = explode('.', $t1);
                              [$db2, $t2] = explode('.', $t2);
                      
                      
                      Severity: Minor
                      Found in src/Database/Designer/Common.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