Function indexifyHost
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
private static function indexifyHost( $host, $reverse = true ) {
// Canonicalize.
$host = rawurldecode( $host );
if ( $host !== '' ) {
$tmp = idn_to_utf8( $host );
- 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"
Further reading
File LinkFilter.php
has 336 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
Function makeLikeArray
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public static function makeLikeArray( $filterEntry, $protocol = 'http://' ) {
$services = MediaWikiServices::getInstance();
$db = $services->getConnectionProvider()->getReplicaDatabase();
$likeDomain = [];
$likePath = [];
- 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"
Further reading
Method indexifyHost
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function indexifyHost( $host, $reverse = true ) {
// Canonicalize.
$host = rawurldecode( $host );
if ( $host !== '' ) {
$tmp = idn_to_utf8( $host );
Function makeIndexes
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public static function makeIndexes( $url, $reverseDomain = true ) {
// NOTE: refreshExternallinksIndex.php assumes that only protocol-relative URLs return more
// than one index, and that the indexes for protocol-relative URLs only vary in the "http://"
// versus "https://" prefix. If you change that, you'll likely need to update
// refreshExternallinksIndex.php accordingly.
- 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"
Further reading
Method makeLikeArray
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function makeLikeArray( $filterEntry, $protocol = 'http://' ) {
$services = MediaWikiServices::getInstance();
$db = $services->getConnectionProvider()->getReplicaDatabase();
$likeDomain = [];
$likePath = [];
Function getQueryConditions
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public static function getQueryConditions( $filterEntry, array $options = [] ) {
$options += [
'protocol' => [ 'http://', 'https://' ],
'oneWildcard' => false,
'db' => null,
- 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"
Further reading
Method getQueryConditions
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getQueryConditions( $filterEntry, array $options = [] ) {
$options += [
'protocol' => [ 'http://', 'https://' ],
'oneWildcard' => false,
'db' => null,
Method makeIndexes
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function makeIndexes( $url, $reverseDomain = true ) {
// NOTE: refreshExternallinksIndex.php assumes that only protocol-relative URLs return more
// than one index, and that the indexes for protocol-relative URLs only vary in the "http://"
// versus "https://" prefix. If you change that, you'll likely need to update
// refreshExternallinksIndex.php accordingly.
Function getProtocolPrefix
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function getProtocolPrefix( $protocol ) {
// Find the right prefix
$urlProtocols = MediaWikiServices::getInstance()->getMainConfig()
->get( MainConfigNames::UrlProtocols );
if ( $protocol && !in_array( $protocol, $urlProtocols ) ) {
- 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"
Further reading
Function reverseIndexes
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function reverseIndexes( $domainIndex ) {
$bits = MediaWikiServices::getInstance()->getUrlUtils()->parse( $domainIndex );
if ( !$bits ) {
return '';
}
- 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"
Further reading
Avoid too many return
statements within this method. Open
return 'V6.' .
substr( implode( '.', explode( ':', IPUtils::sanitizeIP( "{$cutIp}:1" ) ) ), 0, -1 ) .
'*.';
Avoid too many return
statements within this method. Open
return '[' . IPUtils::sanitizeIP( "{$cutIp}:1" ) . ']';
Avoid too many return
statements within this method. Open
return $host;
Avoid too many return
statements within this method. Open
return $host;
Avoid too many return
statements within this method. Open
return 'V4.' . implode( '.', array_map( static function ( $v ) {
return $v === '*' ? $v : (int)$v;
}, explode( '.', $host ) ) ) . '.';
Avoid too many return
statements within this method. Open
return implode( '.', array_reverse( explode( '.', $host ) ) ) . '.';
Function getIndexedUrlsNonReversed
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function getIndexedUrlsNonReversed( $urls ) {
$newLinks = [];
foreach ( $urls as $url ) {
$indexes = self::makeIndexes( $url, false );
if ( !$indexes ) {
- 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"
Further reading
Function reverseDomain
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static function reverseDomain( $domain ) {
if ( substr( $domain, 0, 3 ) === 'V6.' ) {
$ipv6 = str_replace( '.', ':', trim( substr( $domain, 3 ), '.' ) );
if ( IPUtils::isValid( $ipv6 ) ) {
return '[' . $ipv6 . ']';
- 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"