File SessionBackend.php
has 524 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* MediaWiki session backend
*
* This program is free software; you can redistribute it and/or modify
Function save
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
public function save( $closing = false ) {
$anon = $this->user->isAnon();
if ( !$anon && $this->provider->getManager()->isUserSessionPrevented( $this->user->getName() ) ) {
$this->logger->debug(
- 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
SessionBackend
has 35 functions (exceeds 20 allowed). Consider refactoring. Open
final class SessionBackend {
/** @var SessionId */
private $id;
/** @var bool */
Method save
has 111 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function save( $closing = false ) {
$anon = $this->user->isAnon();
if ( !$anon && $this->provider->getManager()->isUserSessionPrevented( $this->user->getName() ) ) {
$this->logger->debug(
Method __construct
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct(
SessionId $id, SessionInfo $info, CachedBagOStuff $store, LoggerInterface $logger,
HookContainer $hookContainer, $lifetime
) {
$phpSessionHandling = MediaWikiServices::getInstance()->getMainConfig()
Function __construct
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function __construct(
SessionId $id, SessionInfo $info, CachedBagOStuff $store, LoggerInterface $logger,
HookContainer $hookContainer, $lifetime
) {
$phpSessionHandling = MediaWikiServices::getInstance()->getMainConfig()
- 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 logPersistenceChange
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function logPersistenceChange( WebRequest $request, bool $persist ) {
if ( !$this->isPersistent() && !$persist ) {
// FIXME SessionManager calls unpersistSession() on anonymous requests (and the cookie
// filtering in WebResponse makes it a noop). Skip those.
return;
Method __construct
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
SessionId $id, SessionInfo $info, CachedBagOStuff $store, LoggerInterface $logger,
HookContainer $hookContainer, $lifetime
Function logPersistenceChange
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function logPersistenceChange( WebRequest $request, bool $persist ) {
if ( !$this->isPersistent() && !$persist ) {
// FIXME SessionManager calls unpersistSession() on anonymous requests (and the cookie
// filtering in WebResponse makes it a noop). Skip those.
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 resetId
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function resetId() {
if ( $this->provider->persistsSessionId() ) {
$oldId = (string)$this->id;
$restart = $this->usePhpSessionHandling && $oldId === session_id() &&
PHPSessionHandler::isEnabled();
- 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"