wikimedia/mediawiki-core

View on GitHub
includes/Storage/PageUpdater.php

Summary

Maintainability
F
6 days
Test Coverage

File PageUpdater.php has 837 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
Severity: Major
Found in includes/Storage/PageUpdater.php - About 2 days to fix

    PageUpdater has 55 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class PageUpdater {
    
        /**
         * Options that have to be present in the ServiceOptions object passed to the constructor.
         * @note When adding options here, also add them to PageUpdaterFactory::CONSTRUCTOR_OPTIONS.
    Severity: Major
    Found in includes/Storage/PageUpdater.php - About 7 hrs to fix

      Method doModify has 94 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function doModify( CommentStoreComment $summary ): PageUpdateStatus {
              $wikiPage = $this->getWikiPage(); // TODO: use for legacy hooks only!
      
              // Update article, but only if changed.
              $status = PageUpdateStatus::newEmpty( false );
      Severity: Major
      Found in includes/Storage/PageUpdater.php - About 3 hrs to fix

        Method saveRevision has 76 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function saveRevision( CommentStoreComment $summary, int $flags = 0 ) {
                $this->setFlags( $flags );
        
                if ( $this->wasCommitted() ) {
                    throw new RuntimeException(
        Severity: Major
        Found in includes/Storage/PageUpdater.php - About 3 hrs to fix

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

              private function doCreate( CommentStoreComment $summary ): PageUpdateStatus {
                  if ( $this->preventChange ) {
                      throw new LogicException(
                          "Content was changed even though preventChange() was called."
                      );
          Severity: Major
          Found in includes/Storage/PageUpdater.php - About 3 hrs to fix

            Function doModify has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

                private function doModify( CommentStoreComment $summary ): PageUpdateStatus {
                    $wikiPage = $this->getWikiPage(); // TODO: use for legacy hooks only!
            
                    // Update article, but only if changed.
                    $status = PageUpdateStatus::newEmpty( false );
            Severity: Minor
            Found in includes/Storage/PageUpdater.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 updateRevision has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function updateRevision( int $revId = 0 ) {
                    if ( $this->wasCommitted() ) {
                        throw new RuntimeException(
                            'saveRevision() or updateRevision() has already been called on this PageUpdater!'
                        );
            Severity: Minor
            Found in includes/Storage/PageUpdater.php - About 2 hrs to fix

              Function saveRevision has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function saveRevision( CommentStoreComment $summary, int $flags = 0 ) {
                      $this->setFlags( $flags );
              
                      if ( $this->wasCommitted() ) {
                          throw new RuntimeException(
              Severity: Minor
              Found in includes/Storage/PageUpdater.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 makeNewRevision has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function makeNewRevision(
                      CommentStoreComment $comment,
                      PageUpdateStatus $status
                  ) {
                      $wikiPage = $this->getWikiPage();
              Severity: Minor
              Found in includes/Storage/PageUpdater.php - About 1 hr to fix

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

                        UserIdentity $author,
                        WikiPage $wikiPage,
                        DerivedPageDataUpdater $derivedDataUpdater,
                        IConnectionProvider $dbProvider,
                        RevisionStore $revisionStore,
                Severity: Major
                Found in includes/Storage/PageUpdater.php - About 1 hr to fix

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

                      private function getAtomicSectionUpdate(
                          IDatabase $dbw,
                          WikiPage $wikiPage,
                          RevisionRecord $newRevisionRecord,
                          CommentStoreComment $summary,
                  Severity: Minor
                  Found in includes/Storage/PageUpdater.php - About 1 hr to fix

                    Method doUpdate has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function doUpdate( RevisionRecord $revision ): PageUpdateStatus {
                            $currentRevision = $this->grabParentRevision();
                            if ( !$currentRevision ) {
                                // Article gone missing
                                return PageUpdateStatus::newFatal( 'edit-gone-missing' );
                    Severity: Minor
                    Found in includes/Storage/PageUpdater.php - About 1 hr to fix

                      Method __construct has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function __construct(
                              UserIdentity $author,
                              WikiPage $wikiPage,
                              DerivedPageDataUpdater $derivedDataUpdater,
                              IConnectionProvider $dbProvider,
                      Severity: Minor
                      Found in includes/Storage/PageUpdater.php - About 1 hr to fix

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

                            private function makeNewRevision(
                                CommentStoreComment $comment,
                                PageUpdateStatus $status
                            ) {
                                $wikiPage = $this->getWikiPage();
                        Severity: Minor
                        Found in includes/Storage/PageUpdater.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 updateRevision has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function updateRevision( int $revId = 0 ) {
                                if ( $this->wasCommitted() ) {
                                    throw new RuntimeException(
                                        'saveRevision() or updateRevision() has already been called on this PageUpdater!'
                                    );
                        Severity: Minor
                        Found in includes/Storage/PageUpdater.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 doCreate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private function doCreate( CommentStoreComment $summary ): PageUpdateStatus {
                                if ( $this->preventChange ) {
                                    throw new LogicException(
                                        "Content was changed even though preventChange() was called."
                                    );
                        Severity: Minor
                        Found in includes/Storage/PageUpdater.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

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

                                IDatabase $dbw,
                                WikiPage $wikiPage,
                                RevisionRecord $newRevisionRecord,
                                CommentStoreComment $summary,
                                array $hints = []
                        Severity: Minor
                        Found in includes/Storage/PageUpdater.php - About 35 mins to fix

                          There are no issues that match your filters.

                          Category
                          Status