File MessageCollection.php
has 546 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare( strict_types = 1 );
namespace MediaWiki\Extension\Translate\MessageLoading;
MessageCollection
has 44 functions (exceeds 20 allowed). Consider refactoring. Open
class MessageCollection implements ArrayAccess, Iterator, Countable {
/**
* The queries can get very large because each message title is specified
* individually. Very large queries can confuse the database query planner.
* Queries are split into multiple separate queries having at most this many
Function initMessages
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
public function initMessages(): void {
if ( $this->messages !== null ) {
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
Method initMessages
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function initMessages(): void {
if ( $this->messages !== null ) {
return;
}
Function filterChanged
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function filterChanged( array $keys, bool $condition ): array {
$this->loadData( $keys );
$origKeys = [];
if ( !$condition ) {
- 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 applyFilter
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function applyFilter( string $filter, bool $condition, ?int $value ): void {
$keys = $this->keys;
if ( $filter === 'fuzzy' ) {
$keys = $this->filterFuzzy( $keys, $condition );
} elseif ( $filter === 'hastranslation' ) {
- 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 filterChanged
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function filterChanged( array $keys, bool $condition ): array {
$this->loadData( $keys );
$origKeys = [];
if ( !$condition ) {
Method applyFilter
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function applyFilter( string $filter, bool $condition, ?int $value ): void {
$keys = $this->keys;
if ( $filter === 'fuzzy' ) {
$keys = $this->filterFuzzy( $keys, $condition );
} elseif ( $filter === 'hastranslation' ) {
Function getAuthors
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getAuthors(): array {
$this->loadTranslations();
$authors = array_flip( $this->authors );
- 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 filterOnCondition
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function filterOnCondition( array $keys, array $condKeys, bool $condition = true ): array {
if ( $condition ) {
// Delete $condKeys from $keys
foreach ( array_keys( $condKeys ) as $key ) {
unset( $keys[$key] );
- 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"