File RestrictionStore.php
has 387 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace MediaWiki\Permissions;
use DBAccessObjectUtils;
Function loadRestrictions
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public function loadRestrictions(
PageIdentity $page, int $flags = IDBAccessObject::READ_NORMAL
): void {
$page->assertWiki( PageIdentity::LOCAL );
- 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 getCascadeProtectionSourcesInternal
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
private function getCascadeProtectionSourcesInternal(
PageIdentity $page, bool $shortCircuit = false
) {
if ( !$page->canExist() ) {
return $shortCircuit ? false : [ [], [] ];
- 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 loadRestrictions
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function loadRestrictions(
PageIdentity $page, int $flags = IDBAccessObject::READ_NORMAL
): void {
$page->assertWiki( PageIdentity::LOCAL );
Method getCascadeProtectionSourcesInternal
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getCascadeProtectionSourcesInternal(
PageIdentity $page, bool $shortCircuit = false
) {
if ( !$page->canExist() ) {
return $shortCircuit ? false : [ [], [] ];
Function loadRestrictionsFromRows
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function loadRestrictionsFromRows(
PageIdentity $page, array $rows
): void {
$page->assertWiki( PageIdentity::LOCAL );
- 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 getCreateProtectionInternal
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getCreateProtectionInternal( PageIdentity $page ): ?array {
// Can't protect pages in special namespaces
if ( !$page->canExist() ) {
return null;
}
Method loadRestrictionsFromRows
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function loadRestrictionsFromRows(
PageIdentity $page, array $rows
): void {
$page->assertWiki( PageIdentity::LOCAL );
Method __construct
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
ServiceOptions $options,
WANObjectCache $wanCache,
ILoadBalancer $loadBalancer,
LinkCache $linkCache,
LinksMigration $linksMigration,
Function isProtected
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function isProtected( PageIdentity $page, string $action = '' ): bool {
$page->assertWiki( PageIdentity::LOCAL );
// Special pages have inherent protection (TODO: remove after switch to ProperPageIdentity)
if ( $page->getNamespace() === NS_SPECIAL ) {
- 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 getCreateProtectionInternal
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function getCreateProtectionInternal( PageIdentity $page ): ?array {
// Can't protect pages in special namespaces
if ( !$page->canExist() ) {
return null;
}
- 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 [ $sources, $pageRestrictions ];
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return (bool)array_diff(
array_intersect(
$this->getRestrictions( $page, $action ),
$this->options->get( MainConfigNames::RestrictionLevels )
),