phpmyadmin/phpmyadmin

View on GitHub
src/Tracking/Tracking.php

Summary

Maintainability
F
6 days
Test Coverage

File Tracking.php has 804 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Functions used for database and table tracking
 */

Severity: Major
Found in src/Tracking/Tracking.php - About 1 day to fix

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

    class Tracking
    {
        public function __construct(
            private SqlQueryForm $sqlQueryForm,
            public Template $template,
    Severity: Minor
    Found in src/Tracking/Tracking.php - About 3 hrs to fix

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

          public function getTrackedData(string $dbname, string $tablename, string $version): TrackedData
          {
              $trackingFeature = $this->relation->getRelationParameters()->trackingFeature;
              Assert::notNull($trackingFeature);
      
      
      Severity: Major
      Found in src/Tracking/Tracking.php - About 2 hrs to fix

        Method getHtmlForTrackingReport has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getHtmlForTrackingReport(
                TrackedData $trackedData,
                array $urlParams,
                string $logType,
                array $filterUsers,
        Severity: Major
        Found in src/Tracking/Tracking.php - About 2 hrs to fix

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

              public function getTrackingSet(): string
              {
                  $trackingSet = '';
          
                  // a key is absent from the request if it has been removed from
          Severity: Minor
          Found in src/Tracking/Tracking.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 getTrackedData has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getTrackedData(string $dbname, string $tablename, string $version): TrackedData
              {
                  $trackingFeature = $this->relation->getRelationParameters()->trackingFeature;
                  Assert::notNull($trackingFeature);
          
          
          Severity: Minor
          Found in src/Tracking/Tracking.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 getTrackingSet has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getTrackingSet(): string
              {
                  $trackingSet = '';
          
                  // a key is absent from the request if it has been removed from
          Severity: Minor
          Found in src/Tracking/Tracking.php - About 1 hr to fix

            Method getHtmlForTrackingReportExportForm1 has 13 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    TrackedData $trackedData,
                    array $urlParams,
                    string $logType,
                    array $filterUsers,
                    string $str1,
            Severity: Major
            Found in src/Tracking/Tracking.php - About 1 hr to fix

              Method getHtmlForTrackingReportExportForm1 has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getHtmlForTrackingReportExportForm1(
                      TrackedData $trackedData,
                      array $urlParams,
                      string $logType,
                      array $filterUsers,
              Severity: Minor
              Found in src/Tracking/Tracking.php - About 1 hr to fix

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

                        array $urlParams,
                        string $str1,
                        string $str2,
                        string $str3,
                        string $str4,
                Severity: Major
                Found in src/Tracking/Tracking.php - About 1 hr to fix

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

                      public function getHtmlForTrackingReportExportForm2(
                          array $urlParams,
                          string $str1,
                          string $str2,
                          string $str3,
                  Severity: Minor
                  Found in src/Tracking/Tracking.php - About 1 hr to fix

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

                        public function getHtmlForSchemaSnapshot(string $db, string $table, string $version, array $params): string
                        {
                            $html = '<h3>' . __('Structure snapshot')
                                . '  [<a href="' . Url::getFromRoute('/table/tracking', $params) . '">' . __('Close')
                                . '</a>]</h3>';
                    Severity: Minor
                    Found in src/Tracking/Tracking.php - About 1 hr to fix

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

                          public function getHtmlForDbTrackingTables(
                              string $db,
                              array $urlParams,
                              string $textDir,
                          ): string {
                      Severity: Minor
                      Found in src/Tracking/Tracking.php - About 1 hr to fix

                        Method getHtmlForDataStatements has 9 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                array $logData,
                                array $filterUsers,
                                array $urlParams,
                                string $dropImageOrText,
                                LogTypeEnum $logType,
                        Severity: Major
                        Found in src/Tracking/Tracking.php - About 1 hr to fix

                          Method getHtmlForDataStatements has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function getHtmlForDataStatements(
                                  array $logData,
                                  array $filterUsers,
                                  array $urlParams,
                                  string $dropImageOrText,
                          Severity: Minor
                          Found in src/Tracking/Tracking.php - About 1 hr to fix

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

                                    TrackedData $trackedData,
                                    array $filterUsers,
                                    array $urlParams,
                                    int $ddlogCount,
                                    string $dropImageOrText,
                            Severity: Major
                            Found in src/Tracking/Tracking.php - About 1 hr to fix

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

                                      TrackedData $trackedData,
                                      array $urlParams,
                                      string $logType,
                                      array $filterUsers,
                                      string $version,
                              Severity: Major
                              Found in src/Tracking/Tracking.php - About 1 hr to fix

                                Method getHtmlForDataDefinitionStatements has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                        TrackedData $trackedData,
                                        array $filterUsers,
                                        array $urlParams,
                                        string $dropImageOrText,
                                        string $version,
                                Severity: Major
                                Found in src/Tracking/Tracking.php - About 50 mins to fix

                                  Method deleteFromTrackingReportLog has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                          string $db,
                                          string $table,
                                          string $version,
                                          array $logData,
                                          LogTypeEnum $logType,
                                  Severity: Minor
                                  Found in src/Tracking/Tracking.php - About 45 mins to fix

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

                                            TrackedData $trackedData,
                                            array $filterUsers,
                                            string $logType,
                                            DateTimeImmutable $dateFrom,
                                            DateTimeImmutable $dateTo,
                                    Severity: Minor
                                    Found in src/Tracking/Tracking.php - About 35 mins to fix

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

                                              string $dbName,
                                              string $tableName,
                                              string $version,
                                              LogTypeEnum $logType,
                                              array $newData,
                                      Severity: Minor
                                      Found in src/Tracking/Tracking.php - About 35 mins to fix

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

                                                private SqlQueryForm $sqlQueryForm,
                                                public Template $template,
                                                protected Relation $relation,
                                                private DatabaseInterface $dbi,
                                                private TrackingChecker $trackingChecker,
                                        Severity: Minor
                                        Found in src/Tracking/Tracking.php - About 35 mins to fix

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

                                              public function getHtmlForTrackingReportExportForm1(
                                                  TrackedData $trackedData,
                                                  array $urlParams,
                                                  string $logType,
                                                  array $filterUsers,
                                          Severity: Minor
                                          Found in src/Tracking/Tracking.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

                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                          Open

                                                  foreach ($logSchemaEntries as $logEntry) {
                                                      if (trim($logEntry) == '') {
                                                          continue;
                                                      }
                                          
                                          
                                          Severity: Major
                                          Found in src/Tracking/Tracking.php and 1 other location - About 3 hrs to fix
                                          src/Tracking/Tracking.php on lines 704..723

                                          Duplicated Code

                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                          Tuning

                                          This issue has a mass of 150.

                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                          Refactorings

                                          Further Reading

                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                          Open

                                                  foreach ($logDataEntries as $logEntry) {
                                                      if (trim($logEntry) == '') {
                                                          continue;
                                                      }
                                          
                                          
                                          Severity: Major
                                          Found in src/Tracking/Tracking.php and 1 other location - About 3 hrs to fix
                                          src/Tracking/Tracking.php on lines 673..692

                                          Duplicated Code

                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                          Tuning

                                          This issue has a mass of 150.

                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                          Refactorings

                                          Further Reading

                                          There are no issues that match your filters.

                                          Category
                                          Status