includes/CommentFormatter/CommentParser.php
File CommentParser.php
has 328 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
namespace MediaWiki\CommentFormatter;
use File;
Method doWikiLinks
has 86 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function doWikiLinks( $comment, $selfLinkTarget = null, $samePage = false, $wikiId = false ) {
return preg_replace_callback(
'/
\[\[
\s*+ # ignore leading whitespace, the *+ quantifier disallows backtracking
Method doSectionLinks
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function doSectionLinks(
$comment,
$selfLinkTarget = null,
$samePage = false,
$wikiId = false
Method __construct
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
LinkRenderer $linkRenderer,
LinkBatchFactory $linkBatchFactory,
LinkCache $linkCache,
RepoGroup $repoGroup,
Language $userLang,
Method addPageLink
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
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(
Method preprocessInternal
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
private function preprocessInternal( $comment, $unsafe, $selfLinkTarget, $samePage, $wikiId,
$enableSectionLinks
Method preprocessUnsafe
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
public function preprocessUnsafe( $comment, LinkTarget $selfLinkTarget = null,
$samePage = false, $wikiId = false, $enableSectionLinks = true
Method preprocess
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
public function preprocess( string $comment, LinkTarget $selfLinkTarget = null,
$samePage = false, $wikiId = false, $enableSectionLinks = true
Function addPageLink
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
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(
- Read upRead up
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"