wikimedia/mediawiki-core

View on GitHub
includes/specials/SpecialWhatLinksHere.php

Summary

Maintainability
F
4 days
Test Coverage

Method showIndirectLinks has 239 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function showIndirectLinks(
        $level, $target, $limit, $offsetNamespace = 0, $offsetPageID = 0, $dir = 'next'
    ) {
        $out = $this->getOutput();
        $dbr = $this->dbProvider->getReplicaDatabase();
Severity: Major
Found in includes/specials/SpecialWhatLinksHere.php - About 1 day to fix

    Function showIndirectLinks has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
    Open

        private function showIndirectLinks(
            $level, $target, $limit, $offsetNamespace = 0, $offsetPageID = 0, $dir = 'next'
        ) {
            $out = $this->getOutput();
            $dbr = $this->dbProvider->getReplicaDatabase();
    Severity: Minor
    Found in includes/specials/SpecialWhatLinksHere.php - About 1 day 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

    File SpecialWhatLinksHere.php has 550 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

      Method listItem has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function listItem( $row, $nt, $target, $notClose = false ) {
              $dirmark = $this->getLanguage()->getDirMark();
      
              if ( $row->rd_from ) {
                  $query = [ 'redirect' => 'no' ];
      Severity: Minor
      Found in includes/specials/SpecialWhatLinksHere.php - About 1 hr to fix

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

            protected function getFormFields() {
                $this->addHelpLink( 'Help:What links here' );
                $this->getOutput()->addModuleStyles( 'mediawiki.special' );
        
                $fields = [
        Severity: Minor
        Found in includes/specials/SpecialWhatLinksHere.php - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                  if ( ( !$fetchredirs || !$rdRes->numRows() )
                      // @phan-suppress-next-line PhanPossiblyUndeclaredVariable $plRes is declared when fetching links
                      && ( $hidelinks || !$plRes->numRows() )
                      // @phan-suppress-next-line PhanPossiblyUndeclaredVariable $tlRes is declared when fetching trans
                      && ( $hidetrans || !$tlRes->numRows() )
          Severity: Critical
          Found in includes/specials/SpecialWhatLinksHere.php - About 1 hr to fix

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

                public function onSuccess() {
                    $opts = new FormOptions();
            
                    $opts->add( 'namespace', null, FormOptions::INTNULL );
                    $opts->add( 'limit', null, FormOptions::INTNULL );
            Severity: Minor
            Found in includes/specials/SpecialWhatLinksHere.php - About 1 hr to fix

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

                  private function parseOffsetAndDir( FormOptions $opts ): array {
                      $from = $opts->getValue( 'from' );
                      $opts->reset( 'from' );
              
                      if ( $from ) {
              Severity: Minor
              Found in includes/specials/SpecialWhatLinksHere.php - About 1 hr to fix

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

                    protected function wlhLink( Title $target, $text, $editText ) {
                        static $title = null;
                        if ( $title === null ) {
                            $title = $this->getPageTitle();
                        }
                Severity: Minor
                Found in includes/specials/SpecialWhatLinksHere.php - About 1 hr to fix

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

                          IConnectionProvider $dbProvider,
                          LinkBatchFactory $linkBatchFactory,
                          IContentHandlerFactory $contentHandlerFactory,
                          SearchEngineFactory $searchEngineFactory,
                          NamespaceInfo $namespaceInfo,
                  Severity: Major
                  Found in includes/specials/SpecialWhatLinksHere.php - About 50 mins to fix

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

                        private function parseOffsetAndDir( FormOptions $opts ): array {
                            $from = $opts->getValue( 'from' );
                            $opts->reset( 'from' );
                    
                            if ( $from ) {
                    Severity: Minor
                    Found in includes/specials/SpecialWhatLinksHere.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 showIndirectLinks has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            $level, $target, $limit, $offsetNamespace = 0, $offsetPageID = 0, $dir = 'next'
                    Severity: Minor
                    Found in includes/specials/SpecialWhatLinksHere.php - About 45 mins to fix

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

                          protected function listItem( $row, $nt, $target, $notClose = false ) {
                              $dirmark = $this->getLanguage()->getDirMark();
                      
                              if ( $row->rd_from ) {
                                  $query = [ 'redirect' => 'no' ];
                      Severity: Minor
                      Found in includes/specials/SpecialWhatLinksHere.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 0;
                      Severity: Major
                      Found in includes/specials/SpecialWhatLinksHere.php - About 30 mins to fix

                        There are no issues that match your filters.

                        Category
                        Status