File SpecialSetSiteLink.php
has 342 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Wikibase\Repo\Specials;
use InvalidArgumentException;
Method getForm
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getForm( EntityDocument $entity = null ) {
if ( $this->page === null ) {
$this->page = $this->site === null ? '' : $this->getSiteLink( $entity, $this->site );
}
if ( !$this->badges ) {
Method __construct
has 12 arguments (exceeds 4 allowed). Consider refactoring. Open
array $tags,
SpecialPageCopyrightView $copyrightView,
SummaryFormatter $summaryFormatter,
EntityTitleLookup $entityTitleLookup,
MediaWikiEditEntityFactory $editEntityFactory,
Method factory
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
AnonymousEditWarningBuilder $anonymousEditWarningBuilder,
ChangeOpFactoryProvider $changeOpFactoryProvider,
MediaWikiEditEntityFactory $editEntityFactory,
EntityTitleLookup $entityTitleLookup,
FallbackLabelDescriptionLookupFactory $labelDescriptionLookupFactory,
Method processArguments
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function processArguments( $subPage ) {
parent::processArguments( $subPage );
$request = $this->getRequest();
// explode the subpage from the format Special:SetSitelink/q123/enwiki
Method getMultiSelectForBadges
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getMultiSelectForBadges() {
$options = [];
$default = [];
/** @var ItemId[] $badgeItemIds */
Function getForm
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function getForm( EntityDocument $entity = null ) {
if ( $this->page === null ) {
$this->page = $this->site === null ? '' : $this->getSiteLink( $entity, $this->site );
}
if ( !$this->badges ) {
- 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 parseBadges
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function parseBadges( array $badges, Status $status ) {
$badgesObjects = [];
foreach ( $badges as $badge ) {
try {
- 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 setSiteLink
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private function setSiteLink( EntityDocument $item, $siteId, $pageName, array $badgeIds, Summary &$summary = null ) {
Avoid too many return
statements within this method. Open
return $status;
Function processArguments
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function processArguments( $subPage ) {
parent::processArguments( $subPage );
$request = $this->getRequest();
// explode the subpage from the format Special:SetSitelink/q123/enwiki
- 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"