File EmailNotification.php
has 386 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Classes used to send e-mails
*
* This program is free software; you can redistribute it and/or modify
Method composeCommonMailtext
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function composeCommonMailtext( MessageCache $messageCache ) {
$services = MediaWikiServices::getInstance();
$config = $services->getMainConfig();
$userOptionsLookup = $services->getUserOptionsLookup();
Function actuallyNotifyOnPageChange
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public function actuallyNotifyOnPageChange(
Authority $editor,
$title,
$timestamp,
$summary,
- 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 actuallyNotifyOnPageChange
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function actuallyNotifyOnPageChange(
Authority $editor,
$title,
$timestamp,
$summary,
Method notifyOnPageChange
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function notifyOnPageChange(
Authority $editor,
$title,
$timestamp,
$summary,
Function notifyOnPageChange
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function notifyOnPageChange(
Authority $editor,
$title,
$timestamp,
$summary,
- 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 canSendUserTalkEmail
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function canSendUserTalkEmail( UserIdentity $editor, $title, $minorEdit ) {
$services = MediaWikiServices::getInstance();
$config = $services->getMainConfig();
if ( !$config->get( MainConfigNames::EnotifUserTalk ) || $title->getNamespace() !== NS_USER_TALK ) {
- 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 ( $userOptionsLookup->getOption( $watchingUser, 'enotifwatchlistpages' )
&& ( !$minorEdit || $userOptionsLookup->getOption( $watchingUser, 'enotifminoredits' ) )
&& $watchingUser->isEmailConfirmed()
&& $watchingUser->getId() != $userTalkId
&& !in_array( $watchingUser->getName(),
Method sendPersonalised
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function sendPersonalised( UserEmailContact $watchingUser, $source ): StatusValue {
// From the PHP manual:
// Note: The to parameter cannot be an address in the form of
// "Something <someone@example.com>". The mail command will not parse
// this properly while talking with the MTA.
Function composeCommonMailtext
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function composeCommonMailtext( MessageCache $messageCache ) {
$services = MediaWikiServices::getInstance();
$config = $services->getMainConfig();
$userOptionsLookup = $services->getUserOptionsLookup();
- 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 canSendUserTalkEmail
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function canSendUserTalkEmail( UserIdentity $editor, $title, $minorEdit ) {
$services = MediaWikiServices::getInstance();
$config = $services->getMainConfig();
if ( !$config->get( MainConfigNames::EnotifUserTalk ) || $title->getNamespace() !== NS_USER_TALK ) {
Method sendImpersonal
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function sendImpersonal( array $addresses ): ?StatusValue {
if ( count( $addresses ) === 0 ) {
return null;
}
$services = MediaWikiServices::getInstance();
Method actuallyNotifyOnPageChange
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Authority $editor,
$title,
$timestamp,
$summary,
$minorEdit,
Method notifyOnPageChange
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Authority $editor,
$title,
$timestamp,
$summary,
$minorEdit,