phpmyadmin/phpmyadmin

View on GitHub
src/Export/Export.php

Summary

Maintainability
F
1 wk
Test Coverage

File Export.php has 864 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * function for the main export logic
 */

Severity: Major
Found in src/Export/Export.php - About 2 days to fix

    Function exportDatabase has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring.
    Open

        public function exportDatabase(
            DatabaseName $db,
            array $tables,
            string $whatStrucOrData,
            array $tableStructure,
    Severity: Minor
    Found in src/Export/Export.php - About 1 day 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 outputHandler has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
    Open

        public function outputHandler(string $line): bool
        {
            $GLOBALS['time_start'] ??= null;
            $GLOBALS['save_filename'] ??= null;
    
    
    Severity: Minor
    Found in src/Export/Export.php - About 7 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 exportDatabase has 179 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function exportDatabase(
            DatabaseName $db,
            array $tables,
            string $whatStrucOrData,
            array $tableStructure,
    Severity: Major
    Found in src/Export/Export.php - About 7 hrs to fix

      Function exportTable has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

          public function exportTable(
              string $db,
              string $table,
              string $whatStrucOrData,
              ExportPlugin $exportPlugin,
      Severity: Minor
      Found in src/Export/Export.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

      Method exportTable has 97 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function exportTable(
              string $db,
              string $table,
              string $whatStrucOrData,
              ExportPlugin $exportPlugin,
      Severity: Major
      Found in src/Export/Export.php - About 3 hrs to fix

        Function mergeAliases has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            public function mergeAliases(array $aliases1, array $aliases2): array
            {
                // First do a recursive array merge
                // on aliases arrays.
                $aliases = array_merge_recursive($aliases1, $aliases2);
        Severity: Minor
        Found in src/Export/Export.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

        Export has 30 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Export
        {
            public string $dumpBuffer = '';
        
            public int $dumpBufferLength = 0;
        Severity: Minor
        Found in src/Export/Export.php - About 3 hrs to fix

          Method outputHandler has 67 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function outputHandler(string $line): bool
              {
                  $GLOBALS['time_start'] ??= null;
                  $GLOBALS['save_filename'] ??= null;
          
          
          Severity: Major
          Found in src/Export/Export.php - About 2 hrs to fix

            Method exportTable has 15 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    string $db,
                    string $table,
                    string $whatStrucOrData,
                    ExportPlugin $exportPlugin,
                    string $errorUrl,
            Severity: Major
            Found in src/Export/Export.php - About 1 hr to fix

              Method exportDatabase has 14 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      DatabaseName $db,
                      array $tables,
                      string $whatStrucOrData,
                      array $tableStructure,
                      array $tableData,
              Severity: Major
              Found in src/Export/Export.php - About 1 hr to fix

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

                    public function openFile(string $filename, bool $quickExport): array
                    {
                        $fileHandle = null;
                        $message = null;
                        $doNotSaveItOver = true;
                Severity: Minor
                Found in src/Export/Export.php - About 1 hr to fix

                  Method exportServer has 11 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          string|array $dbSelect,
                          string $whatStrucOrData,
                          ExportPlugin $exportPlugin,
                          string $errorUrl,
                          string $exportType,
                  Severity: Major
                  Found in src/Export/Export.php - About 1 hr to fix

                    Function getFilenameAndMimetype has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function getFilenameAndMimetype(
                            string $exportType,
                            string $rememberTemplate,
                            ExportPlugin $exportPlugin,
                            string $compression,
                    Severity: Minor
                    Found in src/Export/Export.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 exportServer has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function exportServer(
                            string|array $dbSelect,
                            string $whatStrucOrData,
                            ExportPlugin $exportPlugin,
                            string $errorUrl,
                    Severity: Minor
                    Found in src/Export/Export.php - About 1 hr to fix

                      Method mergeAliases has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function mergeAliases(array $aliases1, array $aliases2): array
                          {
                              // First do a recursive array merge
                              // on aliases arrays.
                              $aliases = array_merge_recursive($aliases1, $aliases2);
                      Severity: Minor
                      Found in src/Export/Export.php - About 1 hr to fix

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

                            public function exportServer(
                                string|array $dbSelect,
                                string $whatStrucOrData,
                                ExportPlugin $exportPlugin,
                                string $errorUrl,
                        Severity: Minor
                        Found in src/Export/Export.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 openFile has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function openFile(string $filename, bool $quickExport): array
                            {
                                $fileHandle = null;
                                $message = null;
                                $doNotSaveItOver = true;
                        Severity: Minor
                        Found in src/Export/Export.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

                        Consider simplifying this complex logical expression.
                        Open

                                if (
                                    @file_exists($saveFilename)
                                    && ((! $quickExport && empty($_POST['onserver_overwrite']))
                                    || ($quickExport
                                    && $doNotSaveItOver))
                        Severity: Major
                        Found in src/Export/Export.php - About 40 mins to fix

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

                                  string $exportType,
                                  string $rememberTemplate,
                                  ExportPlugin $exportPlugin,
                                  string $compression,
                                  string $filenameTemplate,
                          Severity: Minor
                          Found in src/Export/Export.php - About 35 mins to fix

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

                                    string $whatStrucOrData,
                                    ExportPlugin $exportPlugin,
                                    string $errorUrl,
                                    string|null $db,
                                    string $sqlQuery,
                            Severity: Minor
                            Found in src/Export/Export.php - About 35 mins to fix

                              Function getHTMLForRefreshButton has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  private function getHTMLForRefreshButton(string $exportType): string
                                  {
                                      $postParams = $this->getPostParams($exportType);
                              
                                      $refreshButton = '<form id="export_refresh_form" method="POST" action="'
                              Severity: Minor
                              Found in src/Export/Export.php - About 35 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 too many return statements within this method.
                              Open

                                              return;
                              Severity: Major
                              Found in src/Export/Export.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return;
                                Severity: Major
                                Found in src/Export/Export.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                              return;
                                  Severity: Major
                                  Found in src/Export/Export.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                return;
                                    Severity: Major
                                    Found in src/Export/Export.php - About 30 mins to fix

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

                                          private function getPostParams(string $exportType): array
                                          {
                                              $postParams = $_POST;
                                      
                                              // Convert the multiple select elements from an array to a string
                                      Severity: Minor
                                      Found in src/Export/Export.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