wikimedia/mediawiki-core

View on GitHub
includes/linker/Linker.php

Summary

Maintainability
F
2 wks
Test Coverage

File Linker.php has 1475 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Methods to make links and related items.
 *
 * This program is free software; you can redistribute it and/or modify
Severity: Major
Found in includes/linker/Linker.php - About 3 days to fix

    Function makeThumbLink2 has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function makeThumbLink2(
            LinkTarget $title, $file, $frameParams = [], $handlerParams = [],
            $time = false, $query = '', array $classes = [], ?Parser $parser = null
        ) {
            $exists = $file && $file->exists();
    Severity: Minor
    Found in includes/linker/Linker.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

    Function makeImageLink has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function makeImageLink( Parser $parser, LinkTarget $title,
            $file, $frameParams = [], $handlerParams = [], $time = false,
            $query = '', $widthOption = null
        ) {
            $title = Title::newFromLinkTarget( $title );
    Severity: Minor
    Found in includes/linker/Linker.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

    Linker has 55 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Linker {
        /**
         * Flags for userToolLinks()
         */
        public const TOOL_LINKS_NOBLOCK = 1;
    Severity: Major
    Found in includes/linker/Linker.php - About 7 hrs to fix

      Method makeImageLink has 191 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function makeImageLink( Parser $parser, LinkTarget $title,
              $file, $frameParams = [], $handlerParams = [], $time = false,
              $query = '', $widthOption = null
          ) {
              $title = Title::newFromLinkTarget( $title );
      Severity: Major
      Found in includes/linker/Linker.php - About 7 hrs to fix

        Method makeThumbLink2 has 188 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function makeThumbLink2(
                LinkTarget $title, $file, $frameParams = [], $handlerParams = [],
                $time = false, $query = '', array $classes = [], ?Parser $parser = null
            ) {
                $exists = $file && $file->exists();
        Severity: Major
        Found in includes/linker/Linker.php - About 7 hrs to fix

          Function normalizeSubpageLink has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function normalizeSubpageLink( $contextTitle, $target, &$text ) {
                  # Valid link forms:
                  # Foobar -- normal
                  # :Foobar -- override special treatment of prefix (images, language links)
                  # /Foobar -- convert to CurrentPage/Foobar
          Severity: Minor
          Found in includes/linker/Linker.php - About 6 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 normalizeSubpageLink has 61 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function normalizeSubpageLink( $contextTitle, $target, &$text ) {
                  # Valid link forms:
                  # Foobar -- normal
                  # :Foobar -- override special treatment of prefix (images, language links)
                  # /Foobar -- convert to CurrentPage/Foobar
          Severity: Major
          Found in includes/linker/Linker.php - About 2 hrs to fix

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

                public static function generateTOC( ?TOCData $tocData, Language $lang = null, array $options = [] ): string {
                    $toc = '';
                    $lastLevel = 0;
                    $maxTocLevel = $options['maxtoclevel'] ?? null;
                    if ( $maxTocLevel === null ) {
            Severity: Minor
            Found in includes/linker/Linker.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 makeBrokenImageLinkObj has 52 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function makeBrokenImageLinkObj(
                    $title, $label = '', $query = '', $unused1 = '', $unused2 = '',
                    $time = false, array $handlerParams = [], bool $currentExists = false
                ) {
                    if ( !$title instanceof LinkTarget ) {
            Severity: Major
            Found in includes/linker/Linker.php - About 2 hrs to fix

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

                  public static function buildRollbackLink(
                      RevisionRecord $revRecord,
                      IContextSource $context = null,
                      $editCount = false
                  ) {
              Severity: Minor
              Found in includes/linker/Linker.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 userToolLinkArray has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function userToolLinkArray(
                      $userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null
                  ): array {
                      $services = MediaWikiServices::getInstance();
                      $disableAnonTalk = $services->getMainConfig()->get( MainConfigNames::DisableAnonTalk );
              Severity: Minor
              Found in includes/linker/Linker.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 getImageLinkMTOParams has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function getImageLinkMTOParams( $frameParams, $query = '', $parser = null ) {
                      $mtoParams = [];
                      if ( isset( $frameParams['link-url'] ) && $frameParams['link-url'] !== '' ) {
                          $mtoParams['custom-url-link'] = $frameParams['link-url'];
                          if ( isset( $frameParams['link-target'] ) ) {
              Severity: Minor
              Found in includes/linker/Linker.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 titleAttrib has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function titleAttrib( $name, $options = null, array $msgParams = [], $localizer = null ) {
                      if ( !$localizer ) {
                          $localizer = self::getContextFromMain();
                      }
                      $message = $localizer->msg( "tooltip-$name", $msgParams );
              Severity: Minor
              Found in includes/linker/Linker.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 buildRollbackLink has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function buildRollbackLink(
                      RevisionRecord $revRecord,
                      IContextSource $context = null,
                      $editCount = false
                  ) {
              Severity: Minor
              Found in includes/linker/Linker.php - About 1 hr to fix

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

                    public static function userToolLinkArray(
                        $userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null
                    ): array {
                        $services = MediaWikiServices::getInstance();
                        $disableAnonTalk = $services->getMainConfig()->get( MainConfigNames::DisableAnonTalk );
                Severity: Minor
                Found in includes/linker/Linker.php - About 1 hr to fix

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

                      public static function getRollbackEditCount( RevisionRecord $revRecord, $verify = true ) {
                          if ( func_num_args() > 1 ) {
                              wfDeprecated( __METHOD__ . ' with $verify parameter', '1.40' );
                          }
                          $showRollbackEditCount = MediaWikiServices::getInstance()->getMainConfig()
                  Severity: Minor
                  Found in includes/linker/Linker.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 getRollbackEditCount has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function getRollbackEditCount( RevisionRecord $revRecord, $verify = true ) {
                          if ( func_num_args() > 1 ) {
                              wfDeprecated( __METHOD__ . ' with $verify parameter', '1.40' );
                          }
                          $showRollbackEditCount = MediaWikiServices::getInstance()->getMainConfig()
                  Severity: Minor
                  Found in includes/linker/Linker.php - About 1 hr to fix

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

                        public static function makeExternalLink( $url, $text, $escape = true,
                            $linktype = '', $attribs = [], $title = null
                        ) {
                            global $wgTitle;
                            $class = 'external';
                    Severity: Minor
                    Found in includes/linker/Linker.php - About 1 hr to fix

                      Method generateTOC has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static function generateTOC( ?TOCData $tocData, Language $lang = null, array $options = [] ): string {
                              $toc = '';
                              $lastLevel = 0;
                              $maxTocLevel = $options['maxtoclevel'] ?? null;
                              if ( $maxTocLevel === null ) {
                      Severity: Minor
                      Found in includes/linker/Linker.php - About 1 hr to fix

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

                            public static function titleAttrib( $name, $options = null, array $msgParams = [], $localizer = null ) {
                                if ( !$localizer ) {
                                    $localizer = self::getContextFromMain();
                                }
                                $message = $localizer->msg( "tooltip-$name", $msgParams );
                        Severity: Minor
                        Found in includes/linker/Linker.php - About 1 hr to fix

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

                              public static function userLink(
                                  $userId,
                                  $userName,
                                  $altUserName = false,
                                  $attributes = []
                          Severity: Minor
                          Found in includes/linker/Linker.php - About 1 hr to fix

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

                                public static function getRevDeleteLink(
                                    Authority $performer,
                                    RevisionRecord $revRecord,
                                    LinkTarget $title
                                ) {
                            Severity: Minor
                            Found in includes/linker/Linker.php - About 1 hr to fix

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

                                  public static function makeBrokenImageLinkObj(
                                      $title, $label = '', $query = '', $unused1 = '', $unused2 = '',
                                      $time = false, array $handlerParams = [], bool $currentExists = false
                                  ) {
                                      if ( !$title instanceof LinkTarget ) {
                              Severity: Minor
                              Found in includes/linker/Linker.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 userLink has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public static function userLink(
                                      $userId,
                                      $userName,
                                      $altUserName = false,
                                      $attributes = []
                              Severity: Minor
                              Found in includes/linker/Linker.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 revUserTools has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public static function revUserTools(
                                      RevisionRecord $revRecord,
                                      $isPublic = false,
                                      $useParentheses = true
                                  ) {
                              Severity: Minor
                              Found in includes/linker/Linker.php - About 1 hr to fix

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

                                    public static function link(
                                        $target, $html = null, $customAttribs = [], $query = [], $options = []
                                    ) {
                                        if ( !$target instanceof LinkTarget ) {
                                            wfWarn( __METHOD__ . ': Requires $target to be a LinkTarget object.', 2 );
                                Severity: Minor
                                Found in includes/linker/Linker.php - About 1 hr to fix

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

                                      public static function getImageLinkMTOParams( $frameParams, $query = '', $parser = null ) {
                                          $mtoParams = [];
                                          if ( isset( $frameParams['link-url'] ) && $frameParams['link-url'] !== '' ) {
                                              $mtoParams['custom-url-link'] = $frameParams['link-url'];
                                              if ( isset( $frameParams['link-target'] ) ) {
                                  Severity: Minor
                                  Found in includes/linker/Linker.php - About 1 hr to fix

                                    Method makeBrokenImageLinkObj has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                            $title, $label = '', $query = '', $unused1 = '', $unused2 = '',
                                            $time = false, array $handlerParams = [], bool $currentExists = false
                                    Severity: Major
                                    Found in includes/linker/Linker.php - About 1 hr to fix

                                      Method makeImageLink has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                      Open

                                          public static function makeImageLink( Parser $parser, LinkTarget $title,
                                              $file, $frameParams = [], $handlerParams = [], $time = false,
                                              $query = '', $widthOption = null
                                      Severity: Major
                                      Found in includes/linker/Linker.php - About 1 hr to fix

                                        Method makeThumbLink2 has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                        Open

                                                LinkTarget $title, $file, $frameParams = [], $handlerParams = [],
                                                $time = false, $query = '', array $classes = [], ?Parser $parser = null
                                        Severity: Major
                                        Found in includes/linker/Linker.php - About 1 hr to fix

                                          Method makeThumbLinkObj has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                          Open

                                                  LinkTarget $title, $file, $label = '', $alt = '', $align = null,
                                                  $params = [], $framed = false, $manualthumb = ''
                                          Severity: Major
                                          Found in includes/linker/Linker.php - About 1 hr to fix

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

                                                public static function makeExternalLink( $url, $text, $escape = true,
                                                    $linktype = '', $attribs = [], $title = null
                                                ) {
                                                    global $wgTitle;
                                                    $class = 'external';
                                            Severity: Minor
                                            Found in includes/linker/Linker.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

                                            Avoid deeply nested control flow statements.
                                            Open

                                                                        if ( $text === '' ) {
                                                                            $text = $nodotdot . $suffix;
                                                                        }
                                            Severity: Major
                                            Found in includes/linker/Linker.php - About 45 mins to fix

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

                                                  public static function makeExternalLink( $url, $text, $escape = true,
                                                      $linktype = '', $attribs = [], $title = null
                                              Severity: Minor
                                              Found in includes/linker/Linker.php - About 45 mins to fix

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

                                                        $userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null,
                                                        $useParentheses = true
                                                Severity: Minor
                                                Found in includes/linker/Linker.php - About 45 mins to fix

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

                                                      public static function processResponsiveImages( $file, $thumb, $hp ) {
                                                          $responsiveImages = MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::ResponsiveImages );
                                                          if ( $responsiveImages && $thumb && !$thumb->isError() ) {
                                                              $hp15 = $hp;
                                                              $hp15['width'] = round( $hp['width'] * 1.5 );
                                                  Severity: Minor
                                                  Found in includes/linker/Linker.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 makeHeadline has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                  Open

                                                      public static function makeHeadline( $level, $attribs, $anchor, $html,
                                                          $link, $fallbackAnchor = false
                                                  Severity: Minor
                                                  Found in includes/linker/Linker.php - About 45 mins to fix

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

                                                        public static function makeSelfLinkObj( $nt, $html = '', $query = '', $trail = '', $prefix = '', $hash = '' ) {
                                                    Severity: Minor
                                                    Found in includes/linker/Linker.php - About 45 mins to fix

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

                                                          public static function link(
                                                              $target, $html = null, $customAttribs = [], $query = [], $options = []
                                                          ) {
                                                              if ( !$target instanceof LinkTarget ) {
                                                                  wfWarn( __METHOD__ . ': Requires $target to be a LinkTarget object.', 2 );
                                                      Severity: Minor
                                                      Found in includes/linker/Linker.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 tocLine has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                      Open

                                                          public static function tocLine( $linkAnchor, $tocline, $tocnumber, $level, $sectionIndex = false ) {
                                                      Severity: Minor
                                                      Found in includes/linker/Linker.php - About 35 mins to fix

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

                                                                $comment, $title = null, $local = false, $wikiId = null, $useParentheses = true
                                                        Severity: Minor
                                                        Found in includes/linker/Linker.php - About 35 mins to fix

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

                                                                  $userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null
                                                          Severity: Minor
                                                          Found in includes/linker/Linker.php - About 35 mins to fix

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

                                                                    $target, $html = null, $customAttribs = [],
                                                                    $query = [], $options = [ 'known' ]
                                                            Severity: Minor
                                                            Found in includes/linker/Linker.php - About 35 mins to fix

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

                                                                      $target, $html = null, $customAttribs = [], $query = [], $options = []
                                                              Severity: Minor
                                                              Found in includes/linker/Linker.php - About 35 mins to fix

                                                                Avoid too many return statements within this method.
                                                                Open

                                                                        return str_replace( "\n", ' ', $s );
                                                                Severity: Major
                                                                Found in includes/linker/Linker.php - About 30 mins to fix

                                                                  Avoid too many return statements within this method.
                                                                  Open

                                                                          return $linkRenderer->makeLink( $target, $text, $customAttribs, $query );
                                                                  Severity: Major
                                                                  Found in includes/linker/Linker.php - About 30 mins to fix

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

                                                                        public static function accesskey( $name, $localizer = null ) {
                                                                            if ( !isset( self::$accesskeycache[$name] ) ) {
                                                                                if ( !$localizer ) {
                                                                                    $localizer = self::getContextFromMain();
                                                                                }
                                                                    Severity: Minor
                                                                    Found in includes/linker/Linker.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

                                                                        public static function generateTOC( ?TOCData $tocData, Language $lang = null, array $options = [] ): string {
                                                                            $toc = '';
                                                                            $lastLevel = 0;
                                                                            $maxTocLevel = $options['maxtoclevel'] ?? null;
                                                                            if ( $maxTocLevel === null ) {
                                                                    Severity: Major
                                                                    Found in includes/linker/Linker.php and 1 other location - About 1 day to fix
                                                                    includes/OutputTransform/Stages/HandleTOCMarkers.php on lines 184..220

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

                                                                    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

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

                                                                            return '<div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading">'
                                                                                . Html::element( 'input', [
                                                                                    'type' => 'checkbox',
                                                                                    'role' => 'button',
                                                                                    'id' => 'toctogglecheckbox',
                                                                    Severity: Major
                                                                    Found in includes/linker/Linker.php and 1 other location - About 2 hrs to fix
                                                                    includes/OutputTransform/Stages/HandleTOCMarkers.php on lines 151..172

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

                                                                    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

                                                                        public static function blockLink( $userId, $userText ) {
                                                                            if ( $userText === '' ) {
                                                                                wfDebug( __METHOD__ . ' received an empty username. Are there database errors ' .
                                                                                    'that need to be fixed?' );
                                                                                return wfMessage( 'empty-username' )->parse();
                                                                    Severity: Major
                                                                    Found in includes/linker/Linker.php and 1 other location - About 1 hr to fix
                                                                    includes/linker/Linker.php on lines 1434..1447

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

                                                                    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

                                                                        public static function emailLink( $userId, $userText ) {
                                                                            if ( $userText === '' ) {
                                                                                wfLogWarning( __METHOD__ . ' received an empty username. Are there database errors ' .
                                                                                    'that need to be fixed?' );
                                                                                return wfMessage( 'empty-username' )->parse();
                                                                    Severity: Major
                                                                    Found in includes/linker/Linker.php and 1 other location - About 1 hr to fix
                                                                    includes/linker/Linker.php on lines 1413..1427

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

                                                                    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

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

                                                                            return Html::openElement( 'li', [ 'class' => $classes ] )
                                                                                . Html::rawElement( 'a',
                                                                                    [ 'href' => "#$linkAnchor" ],
                                                                                    Html::element( 'span', [ 'class' => 'tocnumber' ], $tocnumber )
                                                                                        . ' '
                                                                    Severity: Minor
                                                                    Found in includes/linker/Linker.php and 1 other location - About 30 mins to fix
                                                                    includes/OutputTransform/Stages/HandleTOCMarkers.php on lines 120..126

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

                                                                    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