File Hooks.php
has 351 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Hooks for UniversalLanguageSelector extension.
*
* Copyright (C) 2012-2018 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon
Method onBeforePageDisplay
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function onBeforePageDisplay( $out, $skin ): void {
$unsupportedSkins = [ 'minerva', 'apioutput' ];
if ( in_array( $skin->getSkinName(), $unsupportedSkins, true ) ) {
return;
}
Function onUserGetLanguageObject
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function onUserGetLanguageObject( $user, &$code, $context ) {
if ( $this->config->get( 'ULSLanguageDetection' ) ) {
// Vary any caching based on the header value. Note that
// we need to vary regardless of whether we end up using
// the header or not, so that requests without the header
- 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 onUserGetLanguageObject
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function onUserGetLanguageObject( $user, &$code, $context ) {
if ( $this->config->get( 'ULSLanguageDetection' ) ) {
// Vary any caching based on the header value. Note that
// we need to vary regardless of whether we end up using
// the header or not, so that requests without the header
Function onBeforePageDisplay
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function onBeforePageDisplay( $out, $skin ): void {
$unsupportedSkins = [ 'minerva', 'apioutput' ];
if ( in_array( $skin->getSkinName(), $unsupportedSkins, true ) ) {
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 onSkinAfterPortlet
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function onSkinAfterPortlet( $skin, $name, &$content ) {
if ( $name !== 'lang' ) {
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 false;
Function getDefaultLanguage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function getDefaultLanguage( array $preferred ) {
/** @var array supported List of Supported languages by MediaWiki internal language codes */
$supported = $this->languageNameUtils
->getLanguageNames( LanguageNameUtils::AUTONYMS, LanguageNameUtils::SUPPORTED );
- 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"