wikimedia/mediawiki-core

View on GitHub
includes/CommentFormatter/CommentParser.php

Summary

Maintainability
D
1 day
Test Coverage

File CommentParser.php has 328 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace MediaWiki\CommentFormatter;

use File;
Severity: Minor
Found in includes/CommentFormatter/CommentParser.php - About 3 hrs to fix

    Method doWikiLinks has 86 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function doWikiLinks( $comment, $selfLinkTarget = null, $samePage = false, $wikiId = false ) {
            return preg_replace_callback(
                '/
                    \[\[
                    \s*+ # ignore leading whitespace, the *+ quantifier disallows backtracking
    Severity: Major
    Found in includes/CommentFormatter/CommentParser.php - About 3 hrs to fix

      Method doSectionLinks has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function doSectionLinks(
              $comment,
              $selfLinkTarget = null,
              $samePage = false,
              $wikiId = false
      Severity: Major
      Found in includes/CommentFormatter/CommentParser.php - About 2 hrs to fix

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

                LinkRenderer $linkRenderer,
                LinkBatchFactory $linkBatchFactory,
                LinkCache $linkCache,
                RepoGroup $repoGroup,
                Language $userLang,
        Severity: Major
        Found in includes/CommentFormatter/CommentParser.php - About 1 hr to fix

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

              private function addPageLink( LinkTarget $target, $text, $wikiId ) {
                  if ( $wikiId !== null && $wikiId !== false && !$target->isExternal() ) {
                      // Handle links from a foreign wiki ID
                      return Linker::makeExternalLink(
                          WikiMap::getForeignURL(
          Severity: Minor
          Found in includes/CommentFormatter/CommentParser.php - About 1 hr to fix

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

                private function preprocessInternal( $comment, $unsafe, $selfLinkTarget, $samePage, $wikiId,
                    $enableSectionLinks
            Severity: Minor
            Found in includes/CommentFormatter/CommentParser.php - About 45 mins to fix

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

                  public function preprocessUnsafe( $comment, LinkTarget $selfLinkTarget = null,
                      $samePage = false, $wikiId = false, $enableSectionLinks = true
              Severity: Minor
              Found in includes/CommentFormatter/CommentParser.php - About 35 mins to fix

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

                    public function preprocess( string $comment, LinkTarget $selfLinkTarget = null,
                        $samePage = false, $wikiId = false, $enableSectionLinks = true
                Severity: Minor
                Found in includes/CommentFormatter/CommentParser.php - About 35 mins to fix

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

                      private function addPageLink( LinkTarget $target, $text, $wikiId ) {
                          if ( $wikiId !== null && $wikiId !== false && !$target->isExternal() ) {
                              // Handle links from a foreign wiki ID
                              return Linker::makeExternalLink(
                                  WikiMap::getForeignURL(
                  Severity: Minor
                  Found in includes/CommentFormatter/CommentParser.php - About 25 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  There are no issues that match your filters.

                  Category
                  Status