File BlockUser.php
has 433 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
Method __construct
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct(
ServiceOptions $options,
BlockRestrictionStore $blockRestrictionStore,
BlockPermissionCheckerFactory $blockPermissionCheckerFactory,
BlockUtils $blockUtils,
Method __construct
has 18 arguments (exceeds 4 allowed). Consider refactoring. Open
ServiceOptions $options,
BlockRestrictionStore $blockRestrictionStore,
BlockPermissionCheckerFactory $blockPermissionCheckerFactory,
BlockUtils $blockUtils,
BlockActionInfo $blockActionInfo,
Function placeBlockUnsafe
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function placeBlockUnsafe( bool $reblock = false ): Status {
$status = $this->blockUtils->validateTarget( $this->target );
if ( !$status->isOK() ) {
$this->logger->debug( 'placeBlockUnsafe: invalid target' );
- 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 __construct
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function __construct(
ServiceOptions $options,
BlockRestrictionStore $blockRestrictionStore,
BlockPermissionCheckerFactory $blockPermissionCheckerFactory,
BlockUtils $blockUtils,
- 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 placeBlockInternal
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function placeBlockInternal( bool $reblock = true ): Status {
$block = $this->configureBlock();
$denyReason = [ 'hookaborted' ];
$legacyUser = $this->userFactory->newFromAuthority( $this->performer );
Method placeBlockUnsafe
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function placeBlockUnsafe( bool $reblock = false ): Status {
$status = $this->blockUtils->validateTarget( $this->target );
if ( !$status->isOK() ) {
$this->logger->debug( 'placeBlockUnsafe: invalid target' );
Method placeBlock
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function placeBlock( bool $reblock = false ): Status {
$priorBlock = $this->blockStore
->newFromTarget( $this->target, null, /*fromPrimary=*/true );
$priorHideUser = $priorBlock instanceof DatabaseBlock && $priorBlock->getHideName();
if (
Function placeBlockInternal
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function placeBlockInternal( bool $reblock = true ): Status {
$block = $this->configureBlock();
$denyReason = [ 'hookaborted' ];
$legacyUser = $this->userFactory->newFromAuthority( $this->performer );
- 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 placeBlock
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function placeBlock( bool $reblock = false ): Status {
$priorBlock = $this->blockStore
->newFromTarget( $this->target, null, /*fromPrimary=*/true );
$priorHideUser = $priorBlock instanceof DatabaseBlock && $priorBlock->getHideName();
if (
- 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 configureBlock
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function configureBlock( $sourceBlock = null ): DatabaseBlock {
if ( $sourceBlock === null ) {
$block = new DatabaseBlock();
} else {
$block = clone $sourceBlock;
Function constructLogParams
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function constructLogParams(): array {
$logExpiry = wfIsInfinity( $this->rawExpiry ) ? 'infinity' : $this->rawExpiry;
$logParams = [
'5::duration' => $logExpiry,
'6::flags' => $this->blockLogFlags(),
- 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 blockLogFlags
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function blockLogFlags(): string {
$flags = [];
if ( $this->targetType != AbstractBlock::TYPE_USER && !$this->isHardBlock ) {
// For grepping: message block-log-flags-anononly
- 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 $this->placeBlockInternal( $reblock );
Avoid too many return
statements within this method. Open
return Status::newFatal( 'ipb_hide_partial' );
Avoid too many return
statements within this method. Open
return Status::newFatal( 'ipb_expiry_temp' );
Avoid too many return
statements within this method. Open
return $this->placeBlockUnsafe( $reblock );
Avoid too many return
statements within this method. Open
return Status::newFatal( 'ipb-empty-block' );
Avoid too many return
statements within this method. Open
return Status::newGood( $block );
Avoid too many return
statements within this method. Open
return Status::newFatal( 'ipb_hide_invalid', Message::numParam( $hideUserContribLimit ) );