wikimedia/mediawiki-core

View on GitHub
includes/Revision/RevisionStore.php

Summary

Maintainability
F
2 wks
Test Coverage

File RevisionStore.php has 2010 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/Revision/RevisionStore.php - About 5 days to fix

    RevisionStore has 72 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class RevisionStore implements RevisionFactory, RevisionLookup, LoggerAwareInterface {
    
        use LegacyArticleIdAccess;
    
        public const ROW_CACHE_KEY = 'revision-row-1.29';
    Severity: Major
    Found in includes/Revision/RevisionStore.php - About 1 day to fix

      Method newRevisionsFromBatch has 156 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function newRevisionsFromBatch(
              $rows,
              array $options = [],
              $queryFlags = 0,
              PageIdentity $page = null
      Severity: Major
      Found in includes/Revision/RevisionStore.php - About 6 hrs to fix

        Function getSlotRowsForBatch has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

            private function getSlotRowsForBatch(
                $rowsOrIds,
                array $options = [],
                $queryFlags = 0
            ) {
        Severity: Minor
        Found in includes/Revision/RevisionStore.php - About 4 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

        Function newRevisionsFromBatch has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

            public function newRevisionsFromBatch(
                $rows,
                array $options = [],
                $queryFlags = 0,
                PageIdentity $page = null
        Severity: Minor
        Found in includes/Revision/RevisionStore.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

        Method newRevisionFromRowAndSlots has 87 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function newRevisionFromRowAndSlots(
                stdClass $row,
                $slots,
                int $queryFlags = 0,
                ?PageIdentity $page = null,
        Severity: Major
        Found in includes/Revision/RevisionStore.php - About 3 hrs to fix

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

              private function getSlotRowsForBatch(
                  $rowsOrIds,
                  array $options = [],
                  $queryFlags = 0
              ) {
          Severity: Major
          Found in includes/Revision/RevisionStore.php - About 3 hrs to fix

            Method insertRevisionOn has 74 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function insertRevisionOn( RevisionRecord $rev, IDatabase $dbw ) {
                    // TODO: pass in a DBTransactionContext instead of a database connection.
                    $this->checkDatabaseDomain( $dbw );
            
                    $slotRoles = $rev->getSlotRoles();
            Severity: Major
            Found in includes/Revision/RevisionStore.php - About 2 hrs to fix

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

                  private function insertRevisionRowOn(
                      IDatabase $dbw,
                      RevisionRecord $rev,
                      $parentId
                  ) {
              Severity: Major
              Found in includes/Revision/RevisionStore.php - About 2 hrs to fix

                Function constructSlotRecords has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function constructSlotRecords(
                        $revId,
                        $slotRows,
                        $queryFlags,
                        PageIdentity $page,
                Severity: Minor
                Found in includes/Revision/RevisionStore.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 getQueryInfo has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getQueryInfo( $options = [] ) {
                        $ret = [
                            'tables' => [],
                            'fields' => [],
                            'joins'  => [],
                Severity: Major
                Found in includes/Revision/RevisionStore.php - About 2 hrs to fix

                  Method loadSlotContent has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function loadSlotContent(
                          SlotRecord $slot,
                          ?string $blobData = null,
                          ?string $blobFlags = null,
                          ?string $blobFormat = null,
                  Severity: Major
                  Found in includes/Revision/RevisionStore.php - About 2 hrs to fix

                    Function loadSlotContent has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function loadSlotContent(
                            SlotRecord $slot,
                            ?string $blobData = null,
                            ?string $blobFlags = null,
                            ?string $blobFormat = null,
                    Severity: Minor
                    Found in includes/Revision/RevisionStore.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 getKnownCurrentRevision has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function getKnownCurrentRevision( PageIdentity $page, $revId = 0 ) {
                            $db = $this->getDBConnection( DB_REPLICA );
                            $revIdPassed = $revId;
                            $pageId = $this->getArticleId( $page );
                            if ( !$pageId ) {
                    Severity: Major
                    Found in includes/Revision/RevisionStore.php - About 2 hrs to fix

                      Method ensureRevisionRowMatchesPage has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function ensureRevisionRowMatchesPage( $row, PageIdentity $page, $context = [] ) {
                              $revId = (int)( $row->rev_id ?? 0 );
                              $revPageId = (int)( $row->rev_page ?? 0 ); // XXX: also check $row->page_id?
                              $expectedPageId = $page->getId( $this->wikiId );
                              // Avoid fatal error when the Title's ID changed, T246720
                      Severity: Minor
                      Found in includes/Revision/RevisionStore.php - About 1 hr to fix

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

                            public function newRevisionFromRowAndSlots(
                                stdClass $row,
                                $slots,
                                int $queryFlags = 0,
                                ?PageIdentity $page = null,
                        Severity: Minor
                        Found in includes/Revision/RevisionStore.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 getRelativeRevision has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function getRelativeRevision( RevisionRecord $rev, $flags, $dir ) {
                                $op = $dir === 'next' ? '>' : '<';
                                $sort = $dir === 'next' ? 'ASC' : 'DESC';
                        
                                $revisionIdValue = $rev->getId( $this->wikiId );
                        Severity: Minor
                        Found in includes/Revision/RevisionStore.php - About 1 hr to fix

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

                                  ILoadBalancer $loadBalancer,
                                  SqlBlobStore $blobStore,
                                  WANObjectCache $cache,
                                  BagOStuff $localCache,
                                  CommentStore $commentStore,
                          Severity: Major
                          Found in includes/Revision/RevisionStore.php - About 1 hr to fix

                            Method constructSlotRecords has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                private function constructSlotRecords(
                                    $revId,
                                    $slotRows,
                                    $queryFlags,
                                    PageIdentity $page,
                            Severity: Minor
                            Found in includes/Revision/RevisionStore.php - About 1 hr to fix

                              Method getAuthorsBetween has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function getAuthorsBetween(
                                      $pageId,
                                      RevisionRecord $old = null,
                                      RevisionRecord $new = null,
                                      Authority $performer = null,
                              Severity: Minor
                              Found in includes/Revision/RevisionStore.php - About 1 hr to fix

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

                                    public function newRevisionFromArchiveRowAndSlots(
                                        stdClass $row,
                                        $slots,
                                        int $queryFlags = 0,
                                        ?PageIdentity $page = null,
                                Severity: Minor
                                Found in includes/Revision/RevisionStore.php - About 1 hr to fix

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

                                      private function getPage( ?int $pageId, ?int $revId, int $queryFlags = IDBAccessObject::READ_NORMAL ) {
                                          if ( !$pageId && !$revId ) {
                                              throw new InvalidArgumentException( '$pageId and $revId cannot both be 0 or null' );
                                          }
                                  
                                  
                                  Severity: Minor
                                  Found in includes/Revision/RevisionStore.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 insertRevisionRowOn has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      private function insertRevisionRowOn(
                                          IDatabase $dbw,
                                          RevisionRecord $rev,
                                          $parentId
                                      ) {
                                  Severity: Minor
                                  Found in includes/Revision/RevisionStore.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 ensureRevisionRowMatchesPage has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      private function ensureRevisionRowMatchesPage( $row, PageIdentity $page, $context = [] ) {
                                          $revId = (int)( $row->rev_id ?? 0 );
                                          $revPageId = (int)( $row->rev_page ?? 0 ); // XXX: also check $row->page_id?
                                          $expectedPageId = $page->getId( $this->wikiId );
                                          // Avoid fatal error when the Title's ID changed, T246720
                                  Severity: Minor
                                  Found in includes/Revision/RevisionStore.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 updateSlotsOn has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function updateSlotsOn(
                                          RevisionRecord $revision,
                                          RevisionSlotsUpdate $revisionSlotsUpdate,
                                          IDatabase $dbw
                                      ): array {
                                  Severity: Minor
                                  Found in includes/Revision/RevisionStore.php - About 1 hr to fix

                                    Method getPage has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        private function getPage( ?int $pageId, ?int $revId, int $queryFlags = IDBAccessObject::READ_NORMAL ) {
                                            if ( !$pageId && !$revId ) {
                                                throw new InvalidArgumentException( '$pageId and $revId cannot both be 0 or null' );
                                            }
                                    
                                    
                                    Severity: Minor
                                    Found in includes/Revision/RevisionStore.php - About 1 hr to fix

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

                                          public function newNullRevision(
                                              IDatabase $dbw,
                                              PageIdentity $page,
                                              CommentStoreComment $comment,
                                              $minor,
                                      Severity: Minor
                                      Found in includes/Revision/RevisionStore.php - About 1 hr to fix

                                        Method getSlotsQueryInfo has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                            public function getSlotsQueryInfo( $options = [] ) {
                                                $ret = [
                                                    'tables' => [],
                                                    'fields' => [],
                                                    'joins'  => [],
                                        Severity: Minor
                                        Found in includes/Revision/RevisionStore.php - About 1 hr to fix

                                          Method insertRevisionInternal has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                                          Open

                                              private function insertRevisionInternal(
                                                  RevisionRecord $rev,
                                                  IDatabase $dbw,
                                                  UserIdentity $user,
                                                  CommentStoreComment $comment,
                                          Severity: Minor
                                          Found in includes/Revision/RevisionStore.php - About 1 hr to fix

                                            Function getContentBlobsForBatch has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                                public function getContentBlobsForBatch(
                                                    $rowsOrIds,
                                                    $slots = null,
                                                    $queryFlags = 0
                                                ) {
                                            Severity: Minor
                                            Found in includes/Revision/RevisionStore.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 loadSlotRecords has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                                            Open

                                                private function loadSlotRecords( $revId, $queryFlags, PageIdentity $page ) {
                                                    // TODO: Find a way to add NS_MODULE from Scribunto here
                                                    if ( $page->getNamespace() !== NS_TEMPLATE ) {
                                                        $res = $this->loadSlotRecordsFromDb( $revId, $queryFlags, $page );
                                                        return $this->constructSlotRecords( $revId, $res, $queryFlags, $page );
                                            Severity: Minor
                                            Found in includes/Revision/RevisionStore.php - About 1 hr to fix

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

                                                  public function getKnownCurrentRevision( PageIdentity $page, $revId = 0 ) {
                                                      $db = $this->getDBConnection( DB_REPLICA );
                                                      $revIdPassed = $revId;
                                                      $pageId = $this->getArticleId( $page );
                                                      if ( !$pageId ) {
                                              Severity: Minor
                                              Found in includes/Revision/RevisionStore.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 newRevisionFromArchiveRowAndSlots has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                                  public function newRevisionFromArchiveRowAndSlots(
                                                      stdClass $row,
                                                      $slots,
                                                      int $queryFlags = 0,
                                                      ?PageIdentity $page = null,
                                              Severity: Minor
                                              Found in includes/Revision/RevisionStore.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 loadSlotRecordsFromDb has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                              Open

                                                  private function loadSlotRecordsFromDb( $revId, $queryFlags, PageIdentity $page ): array {
                                                      $revQuery = $this->getSlotsQueryInfo( [ 'content' ] );
                                              
                                                      [ $dbMode, $dbOptions ] = DBAccessObjectUtils::getDBOptions( $queryFlags );
                                                      $db = $this->getDBConnection( $dbMode );
                                              Severity: Minor
                                              Found in includes/Revision/RevisionStore.php - About 1 hr to fix

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

                                                    public function getArchiveQueryInfo() {
                                                        $commentQuery = $this->commentStore->getJoin( 'ar_comment' );
                                                        $ret = [
                                                            'tables' => [
                                                                'archive',
                                                Severity: Minor
                                                Found in includes/Revision/RevisionStore.php - About 1 hr to fix

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

                                                      public function getRevisionIdsBetween(
                                                          int $pageId,
                                                          RevisionRecord $old = null,
                                                          RevisionRecord $new = null,
                                                          ?int $max = null,
                                                  Severity: Minor
                                                  Found in includes/Revision/RevisionStore.php - About 1 hr to fix

                                                    Method countRevisionsBetween has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                                    Open

                                                        public function countRevisionsBetween(
                                                            $pageId,
                                                            RevisionRecord $old = null,
                                                            RevisionRecord $new = null,
                                                            $max = null,
                                                    Severity: Minor
                                                    Found in includes/Revision/RevisionStore.php - About 1 hr to fix

                                                      Function getRelativeRevision has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                                      Open

                                                          private function getRelativeRevision( RevisionRecord $rev, $flags, $dir ) {
                                                              $op = $dir === 'next' ? '>' : '<';
                                                              $sort = $dir === 'next' ? 'ASC' : 'DESC';
                                                      
                                                              $revisionIdValue = $rev->getId( $this->wikiId );
                                                      Severity: Minor
                                                      Found in includes/Revision/RevisionStore.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

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

                                                              RevisionRecord $rev,
                                                              IDatabase $dbw,
                                                              UserIdentity $user,
                                                              CommentStoreComment $comment,
                                                              PageIdentity $page,
                                                      Severity: Major
                                                      Found in includes/Revision/RevisionStore.php - About 50 mins to fix

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

                                                                int $pageId,
                                                                RevisionRecord $old = null,
                                                                RevisionRecord $new = null,
                                                                ?int $max = null,
                                                                $options = [],
                                                        Severity: Major
                                                        Found in includes/Revision/RevisionStore.php - About 50 mins to fix

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

                                                                  $pageId,
                                                                  RevisionRecord $old = null,
                                                                  RevisionRecord $new = null,
                                                                  Authority $performer = null,
                                                                  $max = null,
                                                          Severity: Minor
                                                          Found in includes/Revision/RevisionStore.php - About 45 mins to fix

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

                                                                    $pageId,
                                                                    RevisionRecord $old = null,
                                                                    RevisionRecord $new = null,
                                                                    Authority $performer = null,
                                                                    $max = null,
                                                            Severity: Minor
                                                            Found in includes/Revision/RevisionStore.php - About 45 mins to fix

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

                                                                      IDatabase $dbw,
                                                                      PageIdentity $page,
                                                                      CommentStoreComment $comment,
                                                                      $minor,
                                                                      UserIdentity $user
                                                              Severity: Minor
                                                              Found in includes/Revision/RevisionStore.php - About 35 mins to fix

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

                                                                        stdClass $row,
                                                                        $slots,
                                                                        int $queryFlags = 0,
                                                                        ?PageIdentity $page = null,
                                                                        bool $fromCache = false
                                                                Severity: Minor
                                                                Found in includes/Revision/RevisionStore.php - About 35 mins to fix

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

                                                                          $pageId,
                                                                          RevisionRecord $old = null,
                                                                          RevisionRecord $new = null,
                                                                          $max = null,
                                                                          $options = []
                                                                  Severity: Minor
                                                                  Found in includes/Revision/RevisionStore.php - About 35 mins to fix

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

                                                                            IDatabase $dbw,
                                                                            $revisionId,
                                                                            SlotRecord $protoSlot,
                                                                            PageIdentity $page,
                                                                            array $blobHints = []
                                                                    Severity: Minor
                                                                    Found in includes/Revision/RevisionStore.php - About 35 mins to fix

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

                                                                              SlotRecord $slot,
                                                                              ?string $blobData = null,
                                                                              ?string $blobFlags = null,
                                                                              ?string $blobFormat = null,
                                                                              int $queryFlags = 0
                                                                      Severity: Minor
                                                                      Found in includes/Revision/RevisionStore.php - About 35 mins to fix

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

                                                                                $revId,
                                                                                $slotRows,
                                                                                $queryFlags,
                                                                                PageIdentity $page,
                                                                                $slotContents = null
                                                                        Severity: Minor
                                                                        Found in includes/Revision/RevisionStore.php - About 35 mins to fix

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

                                                                                  stdClass $row,
                                                                                  $slots,
                                                                                  int $queryFlags = 0,
                                                                                  ?PageIdentity $page = null,
                                                                                  array $overrides = []
                                                                          Severity: Minor
                                                                          Found in includes/Revision/RevisionStore.php - About 35 mins to fix

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

                                                                                    IDatabase $db,
                                                                                    array $conditions,
                                                                                    int $flags = IDBAccessObject::READ_NORMAL,
                                                                                    PageIdentity $page = null,
                                                                                    array $options = []
                                                                            Severity: Minor
                                                                            Found in includes/Revision/RevisionStore.php - About 35 mins to fix

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

                                                                                  private function getRevisionLimitConditions(
                                                                                      ISQLPlatform $dbr,
                                                                                      RevisionRecord $old = null,
                                                                                      RevisionRecord $new = null,
                                                                                      $options = []
                                                                              Severity: Minor
                                                                              Found in includes/Revision/RevisionStore.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

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

                                                                                  public function getAuthorsBetween(
                                                                                      $pageId,
                                                                                      RevisionRecord $old = null,
                                                                                      RevisionRecord $new = null,
                                                                                      Authority $performer = null,
                                                                              Severity: Minor
                                                                              Found in includes/Revision/RevisionStore.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 null;
                                                                              Severity: Major
                                                                              Found in includes/Revision/RevisionStore.php - About 30 mins to fix

                                                                                Avoid too many return statements within this method.
                                                                                Open

                                                                                                        return $newRevisionRecord(
                                                                                                            $row,
                                                                                                            new RevisionSlots(
                                                                                                                $this->constructSlotRecords(
                                                                                                                    $row->$revIdField,
                                                                                Severity: Major
                                                                                Found in includes/Revision/RevisionStore.php - About 30 mins to fix

                                                                                  Avoid too many return statements within this method.
                                                                                  Open

                                                                                                          return null;
                                                                                  Severity: Major
                                                                                  Found in includes/Revision/RevisionStore.php - About 30 mins to fix

                                                                                    Avoid too many return statements within this method.
                                                                                    Open

                                                                                            return $this->getRevisionById( intval( $revId ), $flags );
                                                                                    Severity: Major
                                                                                    Found in includes/Revision/RevisionStore.php - About 30 mins to fix

                                                                                      Avoid too many return statements within this method.
                                                                                      Open

                                                                                                  return false;
                                                                                      Severity: Major
                                                                                      Found in includes/Revision/RevisionStore.php - About 30 mins to fix

                                                                                        Avoid too many return statements within this method.
                                                                                        Open

                                                                                                    return $result;
                                                                                        Severity: Major
                                                                                        Found in includes/Revision/RevisionStore.php - About 30 mins to fix

                                                                                          Avoid too many return statements within this method.
                                                                                          Open

                                                                                                                  return null;
                                                                                          Severity: Major
                                                                                          Found in includes/Revision/RevisionStore.php - About 30 mins to fix

                                                                                            Avoid too many return statements within this method.
                                                                                            Open

                                                                                                    return $result;
                                                                                            Severity: Major
                                                                                            Found in includes/Revision/RevisionStore.php - About 30 mins to fix

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

                                                                                                  public function getRevisionIdsBetween(
                                                                                                      int $pageId,
                                                                                                      RevisionRecord $old = null,
                                                                                                      RevisionRecord $new = null,
                                                                                                      ?int $max = null,
                                                                                              Severity: Minor
                                                                                              Found in includes/Revision/RevisionStore.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

                                                                                                      try {
                                                                                                          $user = $this->actorStore->newActorFromRowFields(
                                                                                                              $row->ar_user ?? null,
                                                                                                              $row->ar_user_text ?? null,
                                                                                                              $row->ar_actor ?? null
                                                                                              Severity: Major
                                                                                              Found in includes/Revision/RevisionStore.php and 1 other location - About 2 hrs to fix
                                                                                              includes/Revision/RevisionStore.php on lines 1746..1761

                                                                                              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 130.

                                                                                              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

                                                                                                      try {
                                                                                                          $user = $this->actorStore->newActorFromRowFields(
                                                                                                              $row->rev_user ?? null,
                                                                                                              $row->rev_user_text ?? null,
                                                                                                              $row->rev_actor ?? null
                                                                                              Severity: Major
                                                                                              Found in includes/Revision/RevisionStore.php and 1 other location - About 2 hrs to fix
                                                                                              includes/Revision/RevisionStore.php on lines 1664..1679

                                                                                              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 130.

                                                                                              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