wikimedia/mediawiki-extensions-Translate

View on GitHub
src/TranslatorInterface/EntitySearch.php

Summary

Maintainability
C
7 hrs
Test Coverage

Function searchMessages has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
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
Severity: Minor
Found in src/TranslatorInterface/EntitySearch.php - About 2 hrs to fix

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

    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' );
Severity: Minor
Found in src/TranslatorInterface/EntitySearch.php - About 1 hr to fix

    Method searchMessages has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    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
    Severity: Minor
    Found in src/TranslatorInterface/EntitySearch.php - About 1 hr to fix

      Method __construct has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              WANObjectCache $cache,
              Collation $collation,
              MessageGroups $messageGroupFactory,
              NamespaceInfo $namespaceInfo,
              MessageIndex $messageIndex,
      Severity: Major
      Found in src/TranslatorInterface/EntitySearch.php - About 50 mins to fix

        Function searchStaticMessageGroups has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        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' );
        Severity: Minor
        Found in src/TranslatorInterface/EntitySearch.php - About 35 mins to fix

        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

        There are no issues that match your filters.

        Category
        Status