wikimedia/mediawiki-core

View on GitHub
includes/changes/ChangesList.php

Summary

Maintainability
F
3 days
Test Coverage

File ChangesList.php has 619 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Base class for all changes lists.
 *
 * The class is used for formatting recent changes, related changes and watchlist.
Severity: Major
Found in includes/changes/ChangesList.php - About 1 day to fix

    ChangesList has 42 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ChangesList extends ContextSource {
        use ProtectedHookAccessorTrait;
    
        public const CSS_CLASS_PREFIX = 'mw-changeslist-';
    
    
    Severity: Minor
    Found in includes/changes/ChangesList.php - About 5 hrs to fix

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

          public function insertDiffHist( &$s, &$rc, $unpatrolled = null ) {
              # Diff link
              if (
                  $rc->mAttribs['rc_type'] == RC_NEW ||
                  $rc->mAttribs['rc_type'] == RC_LOG ||
      Severity: Minor
      Found in includes/changes/ChangesList.php - About 1 hr to fix

        Method showCharacterDifference has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function showCharacterDifference( $old, $new, IContextSource $context = null ) {
                if ( !$context ) {
                    $context = RequestContext::getMain();
                }
        
        
        Severity: Minor
        Found in includes/changes/ChangesList.php - About 1 hr to fix

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

              public function getArticleLink( &$rc, $unpatrolled, $watched ) {
                  $params = [];
                  if ( $rc->getTitle()->isRedirect() ) {
                      $params = [ 'redirect' => 'no' ];
                  }
          Severity: Minor
          Found in includes/changes/ChangesList.php - About 1 hr to fix

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

                public function insertUserRelatedLinks( &$s, &$rc ) {
                    if ( static::isDeleted( $rc, RevisionRecord::DELETED_USER ) ) {
                        $deletedClass = 'history-deleted';
                        if ( static::isDeleted( $rc, RevisionRecord::DELETED_RESTRICTED ) ) {
                            $deletedClass .= ' mw-history-suppressed';
            Severity: Minor
            Found in includes/changes/ChangesList.php - About 1 hr to fix

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

                  private function insertPageTools( &$s, &$rc ) {
                      // FIXME Some page tools (e.g. thanks) might make sense for log entries.
                      if ( !in_array( $rc->mAttribs['rc_type'], [ RC_EDIT, RC_NEW ] )
                          // FIXME When would either of these not exist when type is RC_EDIT? Document.
                          || !$rc->mAttribs['rc_this_oldid']
              Severity: Minor
              Found in includes/changes/ChangesList.php - About 1 hr to fix

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

                    public static function showCharacterDifference( $old, $new, IContextSource $context = null ) {
                        if ( !$context ) {
                            $context = RequestContext::getMain();
                        }
                
                
                Severity: Minor
                Found in includes/changes/ChangesList.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 revDateLink has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        RevisionRecord $rev,
                        Authority $performer,
                        Language $lang,
                        $title = null,
                        $className = ''
                Severity: Minor
                Found in includes/changes/ChangesList.php - About 35 mins to fix

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

                      public static function isUnpatrolled( $rc, User $user ) {
                          if ( $rc instanceof RecentChange ) {
                              $isPatrolled = $rc->mAttribs['rc_patrolled'];
                              $rcType = $rc->mAttribs['rc_type'];
                              $rcLogType = $rc->mAttribs['rc_log_type'];
                  Severity: Minor
                  Found in includes/changes/ChangesList.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 getArticleLink has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function getArticleLink( &$rc, $unpatrolled, $watched ) {
                          $params = [];
                          if ( $rc->getTitle()->isRedirect() ) {
                              $params = [ 'redirect' => 'no' ];
                          }
                  Severity: Minor
                  Found in includes/changes/ChangesList.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

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

                      public function insertDiffHist( &$s, &$rc, $unpatrolled = null ) {
                          # Diff link
                          if (
                              $rc->mAttribs['rc_type'] == RC_NEW ||
                              $rc->mAttribs['rc_type'] == RC_LOG ||
                  Severity: Minor
                  Found in includes/changes/ChangesList.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

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

                      public function insertComment( $rc ) {
                          if ( static::isDeleted( $rc, RevisionRecord::DELETED_COMMENT ) ) {
                              $deletedClass = 'history-deleted';
                              if ( static::isDeleted( $rc, RevisionRecord::DELETED_RESTRICTED ) ) {
                                  $deletedClass .= ' mw-history-suppressed';
                  Severity: Minor
                  Found in includes/changes/ChangesList.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