File RepoHooks.php
has 718 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Wikibase\Repo;
use LogEntry;
RepoHooks
has 36 functions (exceeds 20 allowed). Consider refactoring. Open
final class RepoHooks {
/**
* Handler for the BeforePageDisplay hook, that conditionally adds the wikibase
* mobile styles and injects the wikibase.ui.entitysearch module replacing the
Method onResourceLoaderRegisterModules
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function onResourceLoaderRegisterModules( ResourceLoader $resourceLoader ) {
$moduleTemplate = [
'localBasePath' => __DIR__ . '/..',
'remoteExtPath' => 'Wikibase/repo',
];
Function onApiCheckCanExecute
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public static function onApiCheckCanExecute( ApiBase $module, User $user, &$message ) {
if ( $module instanceof ApiEditPage ) {
$params = $module->extractRequestParams();
$pageObj = $module->getTitleOrPageId( $params );
$namespace = $pageObj->getTitle()->getNamespace();
- 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 onSkinTemplateNavigationUniversal
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function onSkinTemplateNavigationUniversal( SkinTemplate $skinTemplate, array &$links ) {
$entityContentFactory = WikibaseRepo::getEntityContentFactory();
$title = $skinTemplate->getRelevantTitle();
Function onSkinTemplateNavigationUniversal
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function onSkinTemplateNavigationUniversal( SkinTemplate $skinTemplate, array &$links ) {
$entityContentFactory = WikibaseRepo::getEntityContentFactory();
$title = $skinTemplate->getRelevantTitle();
- 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 onApiCheckCanExecute
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function onApiCheckCanExecute( ApiBase $module, User $user, &$message ) {
if ( $module instanceof ApiEditPage ) {
$params = $module->extractRequestParams();
$pageObj = $module->getTitleOrPageId( $params );
$namespace = $pageObj->getTitle()->getNamespace();
Function onBeforePageDisplay
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) {
$entityNamespaceLookup = WikibaseRepo::getEntityNamespaceLookup();
$namespace = $out->getTitle()->getNamespace();
$isEntityTitle = $entityNamespaceLookup->isNamespaceWithEntities( $namespace );
$settings = WikibaseRepo::getSettings();
- 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 onPageHistoryLineEnding
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function onPageHistoryLineEnding( HistoryPager $history, $row, &$html, array $classes ) {
// Note: This assumes that HistoryPager::getTitle returns a Title.
$entityContentFactory = WikibaseRepo::getEntityContentFactory();
$services = MediaWikiServices::getInstance();
Method onBeforePageDisplay
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) {
$entityNamespaceLookup = WikibaseRepo::getEntityNamespaceLookup();
$namespace = $out->getTitle()->getNamespace();
$isEntityTitle = $entityNamespaceLookup->isNamespaceWithEntities( $namespace );
$settings = WikibaseRepo::getSettings();
Method onArticleDeleteComplete
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
WikiPage $wikiPage,
User $user,
$reason,
$id,
?Content $content,
Method onFormat
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function onFormat( &$comment, $pre, $auto, $post, $title, $local ) {
Function onRevisionFromEditComplete
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function onRevisionFromEditComplete(
WikiPage $wikiPage,
RevisionRecord $revisionRecord,
$baseID,
UserIdentity $user
- 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 false;
Avoid too many return
statements within this method. Open
return true;
Function onOutputPageParserOutput
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function onOutputPageParserOutput( OutputPage $outputPage, ParserOutput $parserOutput ) {
// Set in PlaceholderEmittingEntityTermsView.
$placeholders = $parserOutput->getExtensionData( 'wikibase-view-chunks' );
if ( $placeholders !== null ) {
$outputPage->setProperty( 'wikibase-view-chunks', $placeholders );
- 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 onSetupAfterCache
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function onSetupAfterCache() {
global $wgContentHandlers,
$wgNamespaceContentModels;
if ( WikibaseRepo::getSettings()->getSetting( 'defaultEntityNamespaces' ) ) {
- 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 inheritDefaultRateLimits
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function inheritDefaultRateLimits( array &$rateLimits ) {
if ( isset( $rateLimits['wikibase-idgenerator']['&inherit-create-edit'] ) ) {
unset( $rateLimits['wikibase-idgenerator']['&inherit-create-edit'] );
$limits = $rateLimits['create'] ?? $rateLimits['edit'] ?? [];
foreach ( $limits as $group => $limit ) {
- 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"