File SpecialEditWatchlist.php
has 632 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @defgroup Watchlist Users watchlist handling
*/
SpecialEditWatchlist
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
class SpecialEditWatchlist extends UnlistedSpecialPage {
/**
* Editing modes. EDIT_CLEAR is no longer used; the "Clear" link scared people
* too much. Now it's passed on to the raw editor, from which it's very easy to clear.
*/
Method getNormalForm
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getNormalForm() {
$fields = [];
$count = 0;
// Allow subscribers to manipulate the list of watched pages (or use it
Function getNormalForm
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
protected function getNormalForm() {
$fields = [];
$count = 0;
// Allow subscribers to manipulate the list of watched pages (or use it
- 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 execute
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute( $mode ) {
$this->setHeaders();
$user = $this->getUser();
if ( !$user->isRegistered()
Method buildRemoveLine
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function buildRemoveLine( $title, string $expiryDaysText = '' ): string {
$linkRenderer = $this->getLinkRenderer();
$link = $linkRenderer->makeLink( $title );
$tools = [];
Method showTitles
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function showTitles( $titles, &$output ) {
$talk = $this->msg( 'talkpagelinktext' )->text();
// Do a batch existence check
$batch = $this->linkBatchFactory->newLinkBatch();
if ( count( $titles ) >= 100 ) {
Function showTitles
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function showTitles( $titles, &$output ) {
$talk = $this->msg( 'talkpagelinktext' )->text();
// Do a batch existence check
$batch = $this->linkBatchFactory->newLinkBatch();
if ( count( $titles ) >= 100 ) {
- 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 submitRaw
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function submitRaw( $data ) {
$wanted = $this->extractTitles( $data['Titles'] );
$current = $this->getWatchlist();
if ( count( $wanted ) > 0 ) {
- 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 buildTools
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function buildTools( $unused, LinkRenderer $linkRenderer = null, $selectedMode = false ) {
if ( !$linkRenderer ) {
$linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
}
Method submitRaw
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function submitRaw( $data ) {
$wanted = $this->extractTitles( $data['Titles'] );
$current = $this->getWatchlist();
if ( count( $wanted ) > 0 ) {
Function execute
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function execute( $mode ) {
$this->setHeaders();
$user = $this->getUser();
if ( !$user->isRegistered()
- 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 getWatchlist
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function getWatchlist() {
$list = [];
$watchedItems = $this->watchedItemStore->getWatchedItemsForUser(
$this->getUser(),
- 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 7 arguments (exceeds 4 allowed). Consider refactoring. Open
WatchedItemStoreInterface $watchedItemStore = null,
TitleParser $titleParser = null,
GenderCache $genderCache = null,
LinkBatchFactory $linkBatchFactory = null,
NamespaceInfo $nsInfo = null,
Function extractTitles
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function extractTitles( $list ) {
$list = explode( "\n", trim( $list ) );
$titles = [];
- 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 getExpandedTargets
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function getExpandedTargets( array $targets ) {
$expandedTargets = [];
foreach ( $targets as $target ) {
if ( !$target instanceof LinkTarget ) {
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
Avoid too many return
statements within this method. Open
return $defaultValue;