wikimedia/mediawiki-core

View on GitHub
includes/specials/SpecialEditWatchlist.php

Summary

Maintainability
F
4 days
Test Coverage

File SpecialEditWatchlist.php has 632 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @defgroup Watchlist Users watchlist handling
 */

Severity: Major
Found in includes/specials/SpecialEditWatchlist.php - About 1 day to fix

    SpecialEditWatchlist has 30 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class SpecialEditWatchlist extends UnlistedSpecialPage {
        /**
         * Editing modes. EDIT_CLEAR is no longer used; the "Clear" link scared people
         * too much. Now it's passed on to the raw editor, from which it's very easy to clear.
         */
    Severity: Minor
    Found in includes/specials/SpecialEditWatchlist.php - About 3 hrs to fix

      Method getNormalForm has 69 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function getNormalForm() {
              $fields = [];
              $count = 0;
      
              // Allow subscribers to manipulate the list of watched pages (or use it
      Severity: Major
      Found in includes/specials/SpecialEditWatchlist.php - About 2 hrs to fix

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

            protected function getNormalForm() {
                $fields = [];
                $count = 0;
        
                // Allow subscribers to manipulate the list of watched pages (or use it
        Severity: Minor
        Found in includes/specials/SpecialEditWatchlist.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 execute has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function execute( $mode ) {
                $this->setHeaders();
        
                $user = $this->getUser();
                if ( !$user->isRegistered()
        Severity: Minor
        Found in includes/specials/SpecialEditWatchlist.php - About 1 hr to fix

          Method buildRemoveLine has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function buildRemoveLine( $title, string $expiryDaysText = '' ): string {
                  $linkRenderer = $this->getLinkRenderer();
                  $link = $linkRenderer->makeLink( $title );
          
                  $tools = [];
          Severity: Minor
          Found in includes/specials/SpecialEditWatchlist.php - About 1 hr to fix

            Method showTitles has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function showTitles( $titles, &$output ) {
                    $talk = $this->msg( 'talkpagelinktext' )->text();
                    // Do a batch existence check
                    $batch = $this->linkBatchFactory->newLinkBatch();
                    if ( count( $titles ) >= 100 ) {
            Severity: Minor
            Found in includes/specials/SpecialEditWatchlist.php - About 1 hr to fix

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

                  private function showTitles( $titles, &$output ) {
                      $talk = $this->msg( 'talkpagelinktext' )->text();
                      // Do a batch existence check
                      $batch = $this->linkBatchFactory->newLinkBatch();
                      if ( count( $titles ) >= 100 ) {
              Severity: Minor
              Found in includes/specials/SpecialEditWatchlist.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 submitRaw has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function submitRaw( $data ) {
                      $wanted = $this->extractTitles( $data['Titles'] );
                      $current = $this->getWatchlist();
              
                      if ( count( $wanted ) > 0 ) {
              Severity: Minor
              Found in includes/specials/SpecialEditWatchlist.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 buildTools has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function buildTools( $unused, LinkRenderer $linkRenderer = null, $selectedMode = false ) {
                      if ( !$linkRenderer ) {
                          $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
                      }
              
              
              Severity: Minor
              Found in includes/specials/SpecialEditWatchlist.php - About 1 hr to fix

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

                    public function submitRaw( $data ) {
                        $wanted = $this->extractTitles( $data['Titles'] );
                        $current = $this->getWatchlist();
                
                        if ( count( $wanted ) > 0 ) {
                Severity: Minor
                Found in includes/specials/SpecialEditWatchlist.php - About 1 hr to fix

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

                      public function execute( $mode ) {
                          $this->setHeaders();
                  
                          $user = $this->getUser();
                          if ( !$user->isRegistered()
                  Severity: Minor
                  Found in includes/specials/SpecialEditWatchlist.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 getWatchlist has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function getWatchlist() {
                          $list = [];
                  
                          $watchedItems = $this->watchedItemStore->getWatchedItemsForUser(
                              $this->getUser(),
                  Severity: Minor
                  Found in includes/specials/SpecialEditWatchlist.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 __construct has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          WatchedItemStoreInterface $watchedItemStore = null,
                          TitleParser $titleParser = null,
                          GenderCache $genderCache = null,
                          LinkBatchFactory $linkBatchFactory = null,
                          NamespaceInfo $nsInfo = null,
                  Severity: Major
                  Found in includes/specials/SpecialEditWatchlist.php - About 50 mins to fix

                    Function extractTitles has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function extractTitles( $list ) {
                            $list = explode( "\n", trim( $list ) );
                    
                            $titles = [];
                    
                    
                    Severity: Minor
                    Found in includes/specials/SpecialEditWatchlist.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

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

                        private function getExpandedTargets( array $targets ) {
                            $expandedTargets = [];
                            foreach ( $targets as $target ) {
                                if ( !$target instanceof LinkTarget ) {
                                    try {
                    Severity: Minor
                    Found in includes/specials/SpecialEditWatchlist.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 $defaultValue;
                    Severity: Major
                    Found in includes/specials/SpecialEditWatchlist.php - About 30 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status