wikimedia/mediawiki-core

View on GitHub
includes/page/MergeHistory.php

Summary

Maintainability
D
2 days
Test Coverage

File MergeHistory.php has 365 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * Copyright © 2015 Geoffrey Mon <geofbot@gmail.com>
 *
Severity: Minor
Found in includes/page/MergeHistory.php - About 4 hrs to fix

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

        private function updateSourcePage( $status, $user, $reason ) {
            $deleteSource = false;
            $legacySourceTitle = $this->titleFactory->newFromPageIdentity( $this->source );
            $legacyDestTitle = $this->titleFactory->newFromPageIdentity( $this->dest );
            $sourceModel = $legacySourceTitle->getContentModel();
    Severity: Major
    Found in includes/page/MergeHistory.php - About 2 hrs to fix

      Method merge has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function merge( Authority $performer, $reason = '' ) {
              $status = new Status();
      
              // Check validity and permissions required for merge
              $validCheck = $this->isValidMerge(); // Check this first to check for null pages
      Severity: Major
      Found in includes/page/MergeHistory.php - About 2 hrs to fix

        Method initTimestampLimits has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function initTimestampLimits() {
                // Max timestamp should be min of destination page
                $firstDestTimestamp = $this->dbw->newSelectQueryBuilder()
                    ->select( 'MIN(rev_timestamp)' )
                    ->from( 'revision' )
        Severity: Major
        Found in includes/page/MergeHistory.php - About 2 hrs to fix

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

                  PageIdentity $source,
                  PageIdentity $dest,
                  ?string $timestamp,
                  IConnectionProvider $dbProvider,
                  IContentHandlerFactory $contentHandlerFactory,
          Severity: Major
          Found in includes/page/MergeHistory.php - About 1 hr to fix

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

                private function initTimestampLimits() {
                    // Max timestamp should be min of destination page
                    $firstDestTimestamp = $this->dbw->newSelectQueryBuilder()
                        ->select( 'MIN(rev_timestamp)' )
                        ->from( 'revision' )
            Severity: Minor
            Found in includes/page/MergeHistory.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 updateSourcePage has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                private function updateSourcePage( $status, $user, $reason ) {
                    $deleteSource = false;
                    $legacySourceTitle = $this->titleFactory->newFromPageIdentity( $this->source );
                    $legacyDestTitle = $this->titleFactory->newFromPageIdentity( $this->dest );
                    $sourceModel = $legacySourceTitle->getContentModel();
            Severity: Minor
            Found in includes/page/MergeHistory.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 merge has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function merge( Authority $performer, $reason = '' ) {
                    $status = new Status();
            
                    // Check validity and permissions required for merge
                    $validCheck = $this->isValidMerge(); // Check this first to check for null pages
            Severity: Minor
            Found in includes/page/MergeHistory.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

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

                public function isValidMerge() {
                    $status = new Status();
            
                    // If either article ID is 0, then revisions cannot be reliably selected
                    if ( $this->source->getId() === 0 ) {
            Severity: Minor
            Found in includes/page/MergeHistory.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

            There are no issues that match your filters.

            Category
            Status