src/TranslatorInterface/EntitySearch.php
Function searchMessages
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
Open
public function searchMessages( string $query, int $maxResults ): array {
// Optimized based on requirements:
// * "Natural" sorting of results
// * No need to show which message group things belong to
// * Match at any point in the message
- 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 searchStaticMessageGroups
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function searchStaticMessageGroups( string $query, int $maxResults, array $types = [] ): array {
$cache = $this->cache;
// None of the static groups currently use language-dependent labels. This
// may need revisiting later and splitting the cache by language.
$key = $cache->makeKey( 'Translate', 'EntitySearch', 'static-groups', '-v2' );
Method searchMessages
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function searchMessages( string $query, int $maxResults ): array {
// Optimized based on requirements:
// * "Natural" sorting of results
// * No need to show which message group things belong to
// * Match at any point in the message
Method __construct
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
WANObjectCache $cache,
Collation $collation,
MessageGroups $messageGroupFactory,
NamespaceInfo $namespaceInfo,
MessageIndex $messageIndex,
Function searchStaticMessageGroups
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
public function searchStaticMessageGroups( string $query, int $maxResults, array $types = [] ): array {
$cache = $this->cache;
// None of the static groups currently use language-dependent labels. This
// may need revisiting later and splitting the cache by language.
$key = $cache->makeKey( 'Translate', 'EntitySearch', 'static-groups', '-v2' );
- 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"