File MessageGroups.php
has 413 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare( strict_types = 1 );
namespace MediaWiki\Extension\Translate\MessageGroupProcessing;
MessageGroups
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
class MessageGroups {
/** @var MessageGroup[]|null Map of (group ID => MessageGroup) */
private $groups;
/** @var MessageGroupLoader[]|null */
private $groupLoaders;
Function getParentGroups
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public static function getParentGroups( MessageGroup $targetGroup ): array {
$ids = self::getSharedGroups( $targetGroup );
if ( $ids === [] ) {
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 getGroupStructure
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public static function getGroupStructure(): array {
$groups = self::getAllGroups();
// Determine the top level groups of the tree
$tree = $groups;
- 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 getParentGroups
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getParentGroups( MessageGroup $targetGroup ): array {
$ids = self::getSharedGroups( $targetGroup );
if ( $ids === [] ) {
return [];
}
Method getGroupStructure
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getGroupStructure(): array {
$groups = self::getAllGroups();
// Determine the top level groups of the tree
$tree = $groups;
Method getGroupLoaders
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getGroupLoaders(): array {
if ( $this->groupLoaders !== null ) {
return $this->groupLoaders;
}
Function isTranslatableMessage
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function isTranslatableMessage( MessageHandle $handle, string $targetLanguage ): bool {
static $cache = [];
if ( !$handle->isValid() ) {
return false;
- 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 subGroups
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function subGroups(
AggregateMessageGroup $parent,
array &$childIds = [],
string $fname = 'caller'
): array {
Function getGroupsById
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function getGroupsById( array $ids, bool $skipMeta = false ): array {
$groups = [];
foreach ( $ids as $id ) {
$group = self::getGroup( $id );
- 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 expandWildcards
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function expandWildcards( $ids ): array {
$all = [];
$ids = (array)$ids;
foreach ( $ids as $index => $id ) {
- 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 isTranslatableMessage
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function isTranslatableMessage( MessageHandle $handle, string $targetLanguage ): bool {
static $cache = [];
if ( !$handle->isValid() ) {
return false;
Function labelExists
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function labelExists( string $name ): bool {
$groups = self::getAllGroups();
foreach ( $groups as $group ) {
if ( $group instanceof AggregateMessageGroup ) {
if ( $group->getLabel() === $name ) {
- 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"