wikimedia/mediawiki-core

View on GitHub
includes/specials/SpecialRecentChanges.php

Summary

Maintainability
F
6 days
Test Coverage

File SpecialRecentChanges.php has 742 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Implements Special:Recentchanges
 *
 * This program is free software; you can redistribute it and/or modify
Severity: Major
Found in includes/specials/SpecialRecentChanges.php - About 1 day to fix

    Method optionsPanel has 101 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function optionsPanel( $defaults, $nondefaults, $numRows ) {
            $options = $nondefaults + $defaults;
    
            $note = '';
            $msg = $this->msg( 'rclegend' );
    Severity: Major
    Found in includes/specials/SpecialRecentChanges.php - About 4 hrs to fix

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

          public function __construct(
              WatchedItemStoreInterface $watchedItemStore = null,
              MessageCache $messageCache = null,
              UserOptionsLookup $userOptionsLookup = null,
              ChangeTagsStore $changeTagsStore = null,
      Severity: Major
      Found in includes/specials/SpecialRecentChanges.php - About 3 hrs to fix

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

            public function outputChangesList( $rows, $opts ) {
                $limit = $opts['limit'];
        
                $showWatcherCount = $this->getConfig()->get( MainConfigNames::RCShowWatchingUsers )
                    && $this->userOptionsLookup->getBoolOption( $this->getUser(), 'shownumberswatching' );
        Severity: Minor
        Found in includes/specials/SpecialRecentChanges.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 doHeader has 79 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function doHeader( $opts, $numRows ) {
                $this->setTopText( $opts );
        
                $defaults = $opts->getAllValues();
                $nondefaults = $opts->getChangedValues();
        Severity: Major
        Found in includes/specials/SpecialRecentChanges.php - About 3 hrs to fix

          SpecialRecentChanges has 26 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class SpecialRecentChanges extends ChangesListSpecialPage {
          
              private $watchlistFilterGroupDefinition;
          
              private WatchedItemStoreInterface $watchedItemStore;
          Severity: Minor
          Found in includes/specials/SpecialRecentChanges.php - About 3 hrs to fix

            Method outputChangesList has 66 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function outputChangesList( $rows, $opts ) {
                    $limit = $opts['limit'];
            
                    $showWatcherCount = $this->getConfig()->get( MainConfigNames::RCShowWatchingUsers )
                        && $this->userOptionsLookup->getBoolOption( $this->getUser(), 'shownumberswatching' );
            Severity: Major
            Found in includes/specials/SpecialRecentChanges.php - About 2 hrs to fix

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

                  protected function doMainQuery( $tables, $fields, $conds, $query_options,
                      $join_conds, FormOptions $opts
                  ) {
                      $dbr = $this->getDB();
              
              
              Severity: Major
              Found in includes/specials/SpecialRecentChanges.php - About 2 hrs to fix

                Method setTopText has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function setTopText( FormOptions $opts ) {
                        $message = $this->msg( 'recentchangestext' )->inContentLanguage();
                        if ( !$message->isDisabled() ) {
                            $contLang = $this->getContentLanguage();
                            // Parse the message in this weird ugly way to preserve the ability to include interlanguage
                Severity: Minor
                Found in includes/specials/SpecialRecentChanges.php - About 1 hr to fix

                  Method isDenseTagFilter has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function isDenseTagFilter( $tagIds, $limit ) {
                          $dbr = $this->getDB();
                          if ( !$tagIds
                              // This is a MySQL-specific hack
                              || $dbr->getType() !== 'mysql'
                  Severity: Minor
                  Found in includes/specials/SpecialRecentChanges.php - About 1 hr to fix

                    Method registerFilters has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function registerFilters() {
                            parent::registerFilters();
                    
                            if ( $this->needsWatchlistFeatures() ) {
                                $this->registerFiltersFromDefinitions( [ $this->watchlistFilterGroupDefinition ] );
                    Severity: Minor
                    Found in includes/specials/SpecialRecentChanges.php - About 1 hr to fix

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

                          public function parseParameters( $par, FormOptions $opts ) {
                              parent::parseParameters( $par, $opts );
                      
                              $bits = preg_split( '/\s*,\s*/', trim( $par ) );
                              foreach ( $bits as $bit ) {
                      Severity: Minor
                      Found in includes/specials/SpecialRecentChanges.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 optionsPanel has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function optionsPanel( $defaults, $nondefaults, $numRows ) {
                              $options = $nondefaults + $defaults;
                      
                              $note = '';
                              $msg = $this->msg( 'rclegend' );
                      Severity: Minor
                      Found in includes/specials/SpecialRecentChanges.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 __construct has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function __construct(
                              WatchedItemStoreInterface $watchedItemStore = null,
                              MessageCache $messageCache = null,
                              UserOptionsLookup $userOptionsLookup = null,
                              ChangeTagsStore $changeTagsStore = null,
                      Severity: Minor
                      Found in includes/specials/SpecialRecentChanges.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 doHeader has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function doHeader( $opts, $numRows ) {
                              $this->setTopText( $opts );
                      
                              $defaults = $opts->getAllValues();
                              $nondefaults = $opts->getChangedValues();
                      Severity: Minor
                      Found in includes/specials/SpecialRecentChanges.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 __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                              WatchedItemStoreInterface $watchedItemStore = null,
                              MessageCache $messageCache = null,
                              UserOptionsLookup $userOptionsLookup = null,
                              ChangeTagsStore $changeTagsStore = null,
                              UserIdentityUtils $userIdentityUtils = null,
                      Severity: Minor
                      Found in includes/specials/SpecialRecentChanges.php - About 45 mins to fix

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

                            protected function doMainQuery( $tables, $fields, $conds, $query_options,
                                $join_conds, FormOptions $opts
                        Severity: Minor
                        Found in includes/specials/SpecialRecentChanges.php - About 45 mins to fix

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

                              protected function addWatchlistJoins( IReadableDatabase $dbr, &$tables, &$fields, &$joinConds, &$conds ) {
                          Severity: Minor
                          Found in includes/specials/SpecialRecentChanges.php - About 35 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                                return;
                            Severity: Major
                            Found in includes/specials/SpecialRecentChanges.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                                  return;
                              Severity: Major
                              Found in includes/specials/SpecialRecentChanges.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                    return;
                                Severity: Major
                                Found in includes/specials/SpecialRecentChanges.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                      return;
                                  Severity: Major
                                  Found in includes/specials/SpecialRecentChanges.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                        return;
                                    Severity: Major
                                    Found in includes/specials/SpecialRecentChanges.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                          return;
                                      Severity: Major
                                      Found in includes/specials/SpecialRecentChanges.php - About 30 mins to fix

                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                        Open

                                                if ( $this->isStructuredFilterUiEnabled() ) {
                                                    $rcfilterContainer = Html::element(
                                                        'div',
                                                        [ 'class' => 'mw-rcfilters-container' ]
                                                    );
                                        Severity: Major
                                        Found in includes/specials/SpecialRecentChanges.php and 1 other location - About 2 hrs to fix
                                        includes/specials/SpecialWatchlist.php on lines 830..858

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

                                        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

                                                $associated = Html::rawElement( 'label', [
                                                    'class' => 'mw-input-with-label', 'title' => $this->msg( 'tooltip-namespace_association' )->text(),
                                                ], Html::element( 'input', [
                                                    'type' => 'checkbox', 'name' => 'associated', 'value' => '1', 'checked' => $opts['associated'],
                                                ] ) . '&nbsp;' . $this->msg( 'namespace_association' )->escaped() );
                                        Severity: Minor
                                        Found in includes/specials/SpecialRecentChanges.php and 1 other location - About 35 mins to fix
                                        includes/specials/SpecialRecentChanges.php on lines 866..870

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

                                        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

                                                $invert = Html::rawElement( 'label', [
                                                    'class' => 'mw-input-with-label', 'title' => $this->msg( 'tooltip-invert' )->text(),
                                                ], Html::element( 'input', [
                                                    'type' => 'checkbox', 'name' => 'invert', 'value' => '1', 'checked' => $opts['invert'],
                                                ] ) . '&nbsp;' . $this->msg( 'invert' )->escaped() );
                                        Severity: Minor
                                        Found in includes/specials/SpecialRecentChanges.php and 1 other location - About 35 mins to fix
                                        includes/specials/SpecialRecentChanges.php on lines 871..875

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

                                        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