File RecentChange.php
has 848 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Utility class for creating and accessing recent change entries.
*
* This program is free software; you can redistribute it and/or modify
RecentChange
has 36 functions (exceeds 20 allowed). Consider refactoring. Open
class RecentChange implements Taggable {
use DeprecationHelper;
// Constants for the rc_source field. Extensions may also have
// their own source constants.
Method save
has 109 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function save( $send = self::SEND_FEED ) {
$services = MediaWikiServices::getInstance();
$mainConfig = $services->getMainConfig();
$putIPinRC = $mainConfig->get( MainConfigNames::PutIPinRC );
$dbw = $services->getConnectionProvider()->getPrimaryDatabase();
Method newLogEntry
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function newLogEntry( $timestamp,
$logPage, $user, $actionComment, $ip,
$type, $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = '',
$revId = 0, $isPatrollable = false, $forceBotFlag = null
) {
Consider simplifying this complex logical expression. Open
if (
( $params['omit_bots'] && $this->mAttribs['rc_bot'] ) ||
( $params['omit_anon'] && !$performer->isRegistered() ) ||
( $params['omit_user'] && $performer->isRegistered() ) ||
( $params['omit_minor'] && $this->mAttribs['rc_minor'] ) ||
Function getUserIdentityFromAnyId
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
private function getUserIdentityFromAnyId(
$userId,
$userName,
$actorId = null
): UserIdentity {
- 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 newForCategorization
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function newForCategorization(
$timestamp,
PageIdentity $categoryTitle,
?UserIdentity $user,
$comment,
Method notifyEdit
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function notifyEdit(
$timestamp, $page, $minor, $user, $comment, $oldId, $lastTimestamp,
$bot, $ip = '', $oldSize = 0, $newSize = 0, $newId = 0, $patrol = 0,
$tags = [], EditResult $editResult = null
) {
Method notifyNew
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function notifyNew(
$timestamp,
$page, $minor, $user, $comment, $bot,
$ip = '', $size = 0, $newId = 0, $patrol = 0, $tags = []
) {
Function save
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function save( $send = self::SEND_FEED ) {
$services = MediaWikiServices::getInstance();
$mainConfig = $services->getMainConfig();
$putIPinRC = $mainConfig->get( MainConfigNames::PutIPinRC );
$dbw = $services->getConnectionProvider()->getPrimaryDatabase();
- 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 doMarkPatrolled
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function doMarkPatrolled( Authority $performer, $auto = null, $tags = null ) {
if ( $auto ) {
wfWarn( __METHOD__ . ' with $auto = true' );
return [];
}
Method notifyEdit
has 15 arguments (exceeds 4 allowed). Consider refactoring. Open
$timestamp, $page, $minor, $user, $comment, $oldId, $lastTimestamp,
$bot, $ip = '', $oldSize = 0, $newSize = 0, $newId = 0, $patrol = 0,
$tags = [], EditResult $editResult = null
Method newLogEntry
has 15 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function newLogEntry( $timestamp,
$logPage, $user, $actionComment, $ip,
$type, $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = '',
$revId = 0, $isPatrollable = false, $forceBotFlag = null
Function doMarkPatrolled
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function doMarkPatrolled( Authority $performer, $auto = null, $tags = null ) {
if ( $auto ) {
wfWarn( __METHOD__ . ' with $auto = true' );
return [];
}
- 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 notifyRCFeeds
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function notifyRCFeeds( array $feeds = null ) {
$feeds ??=
MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::RCFeeds );
$performer = $this->getPerformerIdentity();
- 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 notifyLog
has 12 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function notifyLog( $timestamp,
$logPage, $user, $actionComment, $ip, $type,
$action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = ''
Method newForCategorization
has 12 arguments (exceeds 4 allowed). Consider refactoring. Open
$timestamp,
PageIdentity $categoryTitle,
?UserIdentity $user,
$comment,
PageIdentity $pageTitle,
Method getQueryInfo
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getQueryInfo() {
$commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'rc_comment' );
// Optimizer sometimes refuses to pick up the correct join order (T311360)
$commentQuery['joins']['comment_rc_comment'][0] = 'STRAIGHT_JOIN';
return [
Method notifyNew
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
$timestamp,
$page, $minor, $user, $comment, $bot,
$ip = '', $size = 0, $newId = 0, $patrol = 0, $tags = []
Function newLogEntry
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function newLogEntry( $timestamp,
$logPage, $user, $actionComment, $ip,
$type, $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = '',
$revId = 0, $isPatrollable = false, $forceBotFlag = 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
Method getUserIdentityFromAnyId
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getUserIdentityFromAnyId(
$userId,
$userName,
$actorId = null
): UserIdentity {
Function getNotifyUrl
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getNotifyUrl() {
$services = MediaWikiServices::getInstance();
$mainConfig = $services->getMainConfig();
$useRCPatrol = $mainConfig->get( MainConfigNames::UseRCPatrol );
$useNPPatrol = $mainConfig->get( MainConfigNames::UseNPPatrol );
- 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 getAttribute
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getAttribute( $name ) {
if ( $name === 'rc_comment' ) {
return MediaWikiServices::getInstance()->getCommentStore()
->getComment( 'rc_comment', $this->mAttribs, true )->text;
}
- 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
Consider simplifying this complex logical expression. Open
if ( !$useRCPatrol && ( !$useNPPatrol || $this->getAttribute( 'rc_type' ) != RC_NEW ) &&
( !$useFilePatrol || !( $this->getAttribute( 'rc_type' ) == RC_LOG &&
$this->getAttribute( 'rc_log_type' ) == 'upload' ) ) ) {
$status->fatal( 'rcpatroldisabled' );
}
Avoid too many return
statements within this method. Open
return $this->mAttribs[$name] ?? null;
Avoid too many return
statements within this method. Open
return [];
Function checkIPAddress
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static function checkIPAddress( $ip ) {
global $wgRequest;
if ( $ip ) {
if ( !IPUtils::isIPAddress( $ip ) ) {
- 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"