wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub
includes/CirrusSearch.php

Summary

Maintainability
D
2 days
Test Coverage

File CirrusSearch.php has 366 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace CirrusSearch;

use CirrusSearch\Extra\MultiList\MultiListBuilder;
Severity: Minor
Found in includes/CirrusSearch.php - About 4 hrs to fix

    CirrusSearch has 24 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class CirrusSearch extends SearchEngine {
    
        /**
         * Special profile to instruct this class to use profile
         * selection mechanism.
    Severity: Minor
    Found in includes/CirrusSearch.php - About 2 hrs to fix

      Function searchTextReal has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function searchTextReal( SearchQuery $query ) {
              $searcher = $this->makeSearcher( $query->getSearchConfig() );
              $status = $searcher->search( $query );
              $this->lastSearchMetrics = $searcher->getSearchMetrics();
              if ( !$status->isOK() ) {
      Severity: Minor
      Found in includes/CirrusSearch.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 doSearchText has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function doSearchText( $term ) {
              try {
                  $builder = SearchQueryBuilder::newFTSearchQueryBuilder( $this->config,
                      $term, $this->namespacePrefixParser, $this->getCirrusSearchHookRunner() );
              } catch ( SearchQueryParseException $e ) {
      Severity: Minor
      Found in includes/CirrusSearch.php - About 1 hr to fix

        Method searchTextReal has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function searchTextReal( SearchQuery $query ) {
                $searcher = $this->makeSearcher( $query->getSearchConfig() );
                $status = $searcher->search( $query );
                $this->lastSearchMetrics = $searcher->getSearchMetrics();
                if ( !$status->isOK() ) {
        Severity: Minor
        Found in includes/CirrusSearch.php - About 1 hr to fix

          Method getProfiles has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getProfiles( $profileType, User $user = null ) {
                  $profileService = $this->config->getProfileService();
                  $serviceProfileType = null;
                  switch ( $profileType ) {
                      case SearchEngine::COMPLETION_PROFILE_TYPE:
          Severity: Minor
          Found in includes/CirrusSearch.php - About 1 hr to fix

            Method __construct has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function __construct( SearchConfig $config = null,
                    CirrusDebugOptions $debugOptions = null,
                    NamespacePrefixParser $namespacePrefixParser = null,
                    InterwikiResolver $interwikiResolver = null, TitleHelper $titleHelper = null
                ) {
            Severity: Minor
            Found in includes/CirrusSearch.php - About 1 hr to fix

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

                  public function __construct( SearchConfig $config = null,
                      CirrusDebugOptions $debugOptions = null,
                      NamespacePrefixParser $namespacePrefixParser = null,
                      InterwikiResolver $interwikiResolver = null, TitleHelper $titleHelper = null
              Severity: Minor
              Found in includes/CirrusSearch.php - About 35 mins to fix

                Function prefixSearch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function prefixSearch( $search, $variants ) {
                        $searcher = $this->makeSearcher();
                
                        if ( $search ) {
                            $searcher->setResultsType( new FancyTitleResultsType( 'prefix' ) );
                Severity: Minor
                Found in includes/CirrusSearch.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

                Function getProfiles has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function getProfiles( $profileType, User $user = null ) {
                        $profileService = $this->config->getProfileService();
                        $serviceProfileType = null;
                        switch ( $profileType ) {
                            case SearchEngine::COMPLETION_PROFILE_TYPE:
                Severity: Minor
                Found in includes/CirrusSearch.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

                Function completionSearchBackend has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function completionSearchBackend( $search ) {
                        if ( in_array( NS_SPECIAL, $this->namespaces ) ) {
                            // delegate special search to parent
                            return parent::completionSearchBackend( $search );
                        }
                Severity: Minor
                Found in includes/CirrusSearch.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

                Avoid too many return statements within this method.
                Open

                        return $this->getSuggestions( $search, $variants, $this->config );
                Severity: Major
                Found in includes/CirrusSearch.php - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status