Function loadSessionInfoFromStore
has a Cognitive Complexity of 88 (exceeds 5 allowed). Consider refactoring. Open
private function loadSessionInfoFromStore( SessionInfo &$info, WebRequest $request ) {
$key = $this->store->makeKey( 'MWSession', $info->getId() );
$blob = $this->store->get( $key );
// If we got data from the store and the SessionInfo says to force use,
- 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 SessionManager.php
has 748 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* MediaWiki\Session entry point
*
* This program is free software; you can redistribute it and/or modify
Method loadSessionInfoFromStore
has 234 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function loadSessionInfoFromStore( SessionInfo &$info, WebRequest $request ) {
$key = $this->store->makeKey( 'MWSession', $info->getId() );
$blob = $this->store->get( $key );
// If we got data from the store and the SessionInfo says to force use,
Function getEmptySessionInternal
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
private function getEmptySessionInternal( WebRequest $request = null, $id = null ) {
if ( $id !== null ) {
if ( !self::validateSessionId( $id ) ) {
throw new \InvalidArgumentException( 'Invalid session ID' );
}
- 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
SessionManager
has 29 functions (exceeds 20 allowed). Consider refactoring. Open
class SessionManager implements SessionManagerInterface {
/** @var SessionManager|null */
private static $instance = null;
/** @var Session|null */
Function getSessionInfoForRequest
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
private function getSessionInfoForRequest( WebRequest $request ) {
// Call all providers to fetch "the" session
$infos = [];
foreach ( $this->getProviders() as $provider ) {
$info = $provider->provideSessionInfo( $request );
- 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 logPotentialSessionLeakage
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function logPotentialSessionLeakage( Session $session = null ) {
$proxyLookup = MediaWikiServices::getInstance()->getProxyLookup();
$session = $session ?: self::getGlobalSession();
$suspiciousIpExpiry = $this->config->get( MainConfigNames::SuspiciousIpExpiry );
Method getEmptySessionInternal
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getEmptySessionInternal( WebRequest $request = null, $id = null ) {
if ( $id !== null ) {
if ( !self::validateSessionId( $id ) ) {
throw new \InvalidArgumentException( 'Invalid session ID' );
}
Function __construct
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function __construct( $options = [] ) {
$services = MediaWikiServices::getInstance();
if ( isset( $options['config'] ) ) {
$this->config = $options['config'];
if ( !$this->config instanceof Config ) {
- 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 getSessionInfoForRequest
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getSessionInfoForRequest( WebRequest $request ) {
// Call all providers to fetch "the" session
$infos = [];
foreach ( $this->getProviders() as $provider ) {
$info = $provider->provideSessionInfo( $request );
Method getSessionFromInfo
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getSessionFromInfo( SessionInfo $info, WebRequest $request ) {
// @codeCoverageIgnoreStart
if ( defined( 'MW_NO_SESSION' ) ) {
$ep = defined( 'MW_ENTRY_POINT' ) ? MW_ENTRY_POINT : 'this';
Method __construct
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct( $options = [] ) {
$services = MediaWikiServices::getInstance();
if ( isset( $options['config'] ) ) {
$this->config = $options['config'];
if ( !$this->config instanceof Config ) {
Function getSessionFromInfo
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function getSessionFromInfo( SessionInfo $info, WebRequest $request ) {
// @codeCoverageIgnoreStart
if ( defined( 'MW_NO_SESSION' ) ) {
$ep = defined( 'MW_ENTRY_POINT' ) ? MW_ENTRY_POINT : 'this';
- 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 logPotentialSessionLeakage
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function logPotentialSessionLeakage( Session $session = null ) {
$proxyLookup = MediaWikiServices::getInstance()->getProxyLookup();
$session = $session ?: self::getGlobalSession();
$suspiciousIpExpiry = $this->config->get( MainConfigNames::SuspiciousIpExpiry );
- 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 getSessionById
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getSessionById( $id, $create = false, WebRequest $request = null ) {
if ( !self::validateSessionId( $id ) ) {
throw new \InvalidArgumentException( 'Invalid session ID' );
}
if ( !$request ) {
Function getSessionById
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getSessionById( $id, $create = false, WebRequest $request = null ) {
if ( !self::validateSessionId( $id ) ) {
throw new \InvalidArgumentException( 'Invalid session ID' );
}
if ( !$request ) {
- 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 getVaryHeaders
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function getVaryHeaders() {
// @codeCoverageIgnoreStart
if ( defined( 'MW_NO_SESSION' ) && MW_NO_SESSION !== 'warn' ) {
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 getGlobalSession
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function getGlobalSession(): Session {
if ( !PHPSessionHandler::isEnabled() ) {
$id = '';
} else {
$id = session_id();
- 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 $failHandler();
Avoid too many return
statements within this method. Open
return $failHandler();
Avoid too many return
statements within this method. Open
return $failHandler();
Avoid too many return
statements within this method. Open
return $failHandler();
Avoid too many return
statements within this method. Open
return $failHandler();
Avoid too many return
statements within this method. Open
return $failHandler();
Avoid too many return
statements within this method. Open
return $failHandler();
Avoid too many return
statements within this method. Open
return $failHandler();
Avoid too many return
statements within this method. Open
return $failHandler();
Avoid too many return
statements within this method. Open
return $failHandler();
Avoid too many return
statements within this method. Open
return $failHandler();
Avoid too many return
statements within this method. Open
return $failHandler();
Avoid too many return
statements within this method. Open
return $failHandler();
Avoid too many return
statements within this method. Open
return $failHandler();
Avoid too many return
statements within this method. Open
return $failHandler();
Avoid too many return
statements within this method. Open
return true;
Function getProviders
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function getProviders() {
if ( $this->sessionProviders === null ) {
$this->sessionProviders = [];
$objectFactory = MediaWikiServices::getInstance()->getObjectFactory();
foreach ( $this->config->get( MainConfigNames::SessionProviders ) as $spec ) {
- 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"