wikimedia/mediawiki-core

View on GitHub
includes/page/DeletePage.php

Summary

Maintainability
F
3 days
Test Coverage

File DeletePage.php has 565 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace MediaWiki\Page;

use BadMethodCallException;
Severity: Major
Found in includes/page/DeletePage.php - About 1 day to fix

    Method deleteInternal has 126 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function deleteInternal(
            WikiPage $page,
            string $pageRole,
            string $reason,
            ?string $webRequestId = null
    Severity: Major
    Found in includes/page/DeletePage.php - About 5 hrs to fix

      Method archiveRevisions has 75 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function archiveRevisions( WikiPage $page, int $id ): bool {
              // Given the lock above, we can be confident in the title and page ID values
              $namespace = $page->getTitle()->getNamespace();
              $dbKey = $page->getTitle()->getDBkey();
      
      
      Severity: Major
      Found in includes/page/DeletePage.php - About 3 hrs to fix

        Function deleteInternal has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            public function deleteInternal(
                WikiPage $page,
                string $pageRole,
                string $reason,
                ?string $webRequestId = null
        Severity: Minor
        Found in includes/page/DeletePage.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

        DeletePage has 24 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class DeletePage {
            /**
             * @internal For use by PageCommandFactory
             */
            public const CONSTRUCTOR_OPTIONS = [
        Severity: Minor
        Found in includes/page/DeletePage.php - About 2 hrs to fix

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

                  HookContainer $hookContainer,
                  RevisionStore $revisionStore,
                  LBFactory $lbFactory,
                  JobQueueGroup $jobQueueGroup,
                  CommentStore $commentStore,
          Severity: Major
          Found in includes/page/DeletePage.php - About 2 hrs to fix

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

                private function doDeleteUpdates( WikiPage $page, RevisionRecord $revRecord ): void {
                    try {
                        $countable = $page->isCountable();
                    } catch ( TimeoutException $e ) {
                        throw $e;
            Severity: Minor
            Found in includes/page/DeletePage.php - About 1 hr to fix

              Function runPreDeleteHooks has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function runPreDeleteHooks( WikiPage $page, string &$reason ): Status {
                      $status = Status::newGood();
              
                      $legacyDeleter = $this->userFactory->newFromAuthority( $this->deleter );
                      if ( !$this->hookRunner->onArticleDelete(
              Severity: Minor
              Found in includes/page/DeletePage.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 archiveRevisions has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function archiveRevisions( WikiPage $page, int $id ): bool {
                      // Given the lock above, we can be confident in the title and page ID values
                      $namespace = $page->getTitle()->getNamespace();
                      $dbKey = $page->getTitle()->getDBkey();
              
              
              Severity: Minor
              Found in includes/page/DeletePage.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 deleteUnsafe has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function deleteUnsafe( string $reason ): Status {
                      $this->setDeletionAttempted();
                      $origReason = $reason;
                      $hookStatus = $this->runPreDeleteHooks( $this->page, $reason );
                      if ( !$hookStatus->isGood() ) {
              Severity: Minor
              Found in includes/page/DeletePage.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