File MobileFrontendHooks.php
has 697 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
// phpcs:disable MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName
use MediaWiki\Actions\ActionEntryPoint;
MobileFrontendHooks
has 44 functions (exceeds 20 allowed). Consider refactoring. Open
class MobileFrontendHooks implements
APIQuerySiteInfoGeneralInfoHook,
AuthChangeFormFieldsHook,
RequestContextCreateSkinHook,
BeforeDisplayNoArticleTextHook,
Method onBeforePageDisplay
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function onBeforePageDisplay( $out, $skin ): void {
$context = $this->mobileContext;
$mfEnableXAnalyticsLogging = $this->config->get( 'MFEnableXAnalyticsLogging' );
$mfNoIndexPages = $this->config->get( 'MFNoindexPages' );
$isCanonicalLinkHandledByCore = $this->config->get( 'EnableCanonicalServerLink' );
Function onBeforePageDisplay
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function onBeforePageDisplay( $out, $skin ): void {
$context = $this->mobileContext;
$mfEnableXAnalyticsLogging = $this->config->get( 'MFEnableXAnalyticsLogging' );
$mfNoIndexPages = $this->config->get( 'MFNoindexPages' );
$isCanonicalLinkHandledByCore = $this->config->get( 'EnableCanonicalServerLink' );
- 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 onOutputPageBeforeHTML
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function onOutputPageBeforeHTML( $out, &$text ) {
// This hook can be executed more than once per page view if the page content is composed from
// multiple sources! Anything that doesn't depend on $text should use onBeforePageDisplay.
$context = $this->mobileContext;
Function onRequestContextCreateSkin
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function onRequestContextCreateSkin( $context, &$skin ) {
$mobileContext = $this->mobileContext;
$mobileContext->doToggling();
if ( !$mobileContext->shouldDisplayMobileView() ) {
- 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 onRequestContextCreateSkin
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function onRequestContextCreateSkin( $context, &$skin ) {
$mobileContext = $this->mobileContext;
$mobileContext->doToggling();
if ( !$mobileContext->shouldDisplayMobileView() ) {
Method getResourceLoaderMFConfigVars
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getResourceLoaderMFConfigVars() {
$vars = [];
$config = MediaWikiServices::getInstance()->getService( 'MobileFrontend.Config' );
$mfScriptPath = $config->get( 'MFScriptPath' );
$pageProps = $config->get( 'MFQueryPropModules' );
Method __construct
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
HookContainer $hookContainer,
Config $config,
SkinFactory $skinFactory,
UserOptionsLookup $userOptionsLookup,
WatchlistManager $watchlistManager,
Method onMediaWikiPerformAction
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function onMediaWikiPerformAction( $output, $article, $title, $user,
$request, $entryPoint
Function onOutputPageBeforeHTML
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function onOutputPageBeforeHTML( $out, &$text ) {
// This hook can be executed more than once per page view if the page content is composed from
// multiple sources! Anything that doesn't depend on $text should use onBeforePageDisplay.
$context = $this->mobileContext;
- 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 onSkinAddFooterLinks
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function onSkinAddFooterLinks( Skin $skin, string $key, array &$footerLinks ) {
$context = $this->mobileContext;
if ( $key === 'places' ) {
if ( $context->shouldDisplayMobileView() ) {
$terms = MobileFrontendSkinHooks::getTermsLink( $skin );
- 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 hasEditNoticesFeatureConflict
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function hasEditNoticesFeatureConflict( Config $config, User $user ): bool {
$gadgetName = $config->get( 'MFEditNoticesConflictingGadgetName' );
if ( !$gadgetName ) {
return false;
}
- 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 onSpecialPageBeforeExecute
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function onSpecialPageBeforeExecute( $special, $subpage ) {
$isMobileView = $this->mobileContext->shouldDisplayMobileView();
$taglines = $this->mobileContext->getConfig()->get( 'MFSpecialPageTaglines' );
$name = $special->getName();
- 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 onPostLoginRedirect
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function onPostLoginRedirect( &$returnTo, &$returnToQuery, &$type ) {
$context = $this->mobileContext;
if ( !$context->shouldDisplayMobileView() ) {
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"