File MobileContext.php
has 436 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
use MediaWiki\Config\Config;
use MediaWiki\Context\ContextSource;
use MediaWiki\Context\IContextSource;
MobileContext
has 41 functions (exceeds 20 allowed). Consider refactoring. Open
class MobileContext extends ContextSource {
public const MODE_BETA = 'beta';
public const MODE_STABLE = 'stable';
public const OPTIN_COOKIE_NAME = 'optin';
public const STOP_MOBILE_REDIRECT_COOKIE_NAME = 'stopMobileRedirect';
Function getMobileMode
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function getMobileMode() {
$enableBeta = $this->config->get( 'MFEnableBeta' );
if ( !$enableBeta ) {
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
Function doToggling
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function doToggling() {
// make sure viewChange is set
$this->shouldDisplayMobileView();
if ( !$this->viewChange ) {
- 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 doToggling
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function doToggling() {
// make sure viewChange is set
$this->shouldDisplayMobileView();
if ( !$this->viewChange ) {
Method shouldDisplayMobileViewInternal
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function shouldDisplayMobileViewInternal() {
// May be overridden programmatically
if ( $this->forceMobileView ) {
return true;
}
Function getMobileUrl
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function getMobileUrl( $url, $forceHttps = false ) {
$urlUtils = MediaWikiServices::getInstance()->getUrlUtils();
$parsedUrl = $urlUtils->parse( $url );
// if parsing failed, maybe it's a local Url, try to expand and reparse it - task T107505
if ( !$parsedUrl ) {
- 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 shouldDisplayMobileViewInternal
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function shouldDisplayMobileViewInternal() {
// May be overridden programmatically
if ( $this->forceMobileView ) {
return true;
}
- 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 true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;