File UserOptionsManager.php
has 415 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
Function getOptionKinds
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
public function getOptionKinds(
UserIdentity $userIdentity,
IContextSource $context,
$options = null
): array {
- 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 saveOptionsInternal
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public function saveOptionsInternal( UserIdentity $user, IDatabase $dbw ): bool {
if ( !$user->isRegistered() || $this->userNameUtils->isTemp( $user->getName() ) ) {
throw new InvalidArgumentException( __METHOD__ . ' was called on anon or temporary user' );
}
- 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 getOptionKinds
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getOptionKinds(
UserIdentity $userIdentity,
IContextSource $context,
$options = null
): array {
Method saveOptionsInternal
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function saveOptionsInternal( UserIdentity $user, IDatabase $dbw ): bool {
if ( !$user->isRegistered() || $this->userNameUtils->isTemp( $user->getName() ) ) {
throw new InvalidArgumentException( __METHOD__ . ' was called on anon or temporary user' );
}
Function resetOptions
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function resetOptions(
UserIdentity $user,
IContextSource $context,
$resetKinds = [ 'registered', 'registered-multiselect', 'registered-checkmatrix', 'unused' ]
) {
- 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 loadOriginalOptions
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function loadOriginalOptions(
UserIdentity $user,
int $queryFlags = IDBAccessObject::READ_NORMAL,
array $data = null
): array {
Function getOptions
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getOptions(
UserIdentity $user,
int $flags = 0,
int $queryFlags = IDBAccessObject::READ_NORMAL
): array {
- 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 __construct
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
ServiceOptions $options,
DefaultOptionsLookup $defaultOptionsLookup,
LanguageConverterFactory $languageConverterFactory,
IConnectionProvider $dbProvider,
LoggerInterface $logger,
Function loadOriginalOptions
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function loadOriginalOptions(
UserIdentity $user,
int $queryFlags = IDBAccessObject::READ_NORMAL,
array $data = null
): array {
- 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 getOption
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
UserIdentity $user,
string $oname,
$defaultOverride = null,
bool $ignoreHidden = false,
int $queryFlags = IDBAccessObject::READ_NORMAL