wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 691 of 718 total issues

Method searchArchive has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function searchArchive( $term ) {
        $this->searchContext->setOriginalSearchTerm( $term );
        $term = $this->searchContext->escaper()->fixupWholeQueryString( $term );
        $this->setResultsType( new TitleResultsType() );

Severity: Minor
Found in includes/Searcher.php - About 1 hr to fix

    Method getMapping has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getMapping( SearchEngine $engine ) {
            if ( !( $engine instanceof CirrusSearch ) ) {
                throw new \LogicException( "Cannot map CirrusSearch fields for another engine." );
            }
            $this->initFlags();
    Severity: Minor
    Found in includes/Search/SourceTextIndexField.php - About 1 hr to fix

      Method getSearchRequest has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getSearchRequest( Client $client ) {
              $fixablePart = $this->queryFixer->getFixablePart();
              if ( $fixablePart === null ) {
                  return null;
              }
      Severity: Minor
      Found in includes/Fallbacks/IndexLookupFallbackMethod.php - About 1 hr to fix

        Method toArray has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function toArray() {
                $output = [
                    'type' => $this->highlighterType
                ];
        
        
        Severity: Minor
        Found in includes/Search/Fetch/BaseHighlightedField.php - About 1 hr to fix

          Method extractResponseVariables has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function extractResponseVariables( $responseData ) {
                  if ( !is_array( $responseData ) ) {
                      // No known offenders, but just in case...
                      return [];
                  }
          Severity: Minor
          Found in includes/SearchRequestLog.php - About 1 hr to fix

            Method format has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function format( array $queryResult ) {
                    $result = [];
                    if ( isset( $queryResult['result']['hits']['hits'] ) ) {
                        $queryResult = [ $queryResult ];
                    }
            Severity: Minor
            Found in includes/ExplainPrinter.php - About 1 hr to fix

              Method getValueRegex has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function getValueRegex() {
                      Assert::invariant( $this->hasValue(), __METHOD__ . ' called but hasValue() is false' );
                      if ( $this->greedy() ) {
                          Assert::precondition( !$this->allowEmptyValue(), "greedy keywords must not accept empty value" );
                          // XXX: we ignore value delimiter for greedy keywords
              Severity: Minor
              Found in includes/Query/SimpleKeywordFeature.php - About 1 hr to fix

                Method toArray has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function toArray() {
                        $ar = [
                            'query' => $this->query,
                            'rawQuery' => $this->rawQuery
                        ];
                Severity: Minor
                Found in includes/Parser/AST/ParsedQuery.php - About 1 hr to fix

                  Method initProfile has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function initProfile() {
                          $res = $this->getDB( DB_REPLICA )
                              ->newSelectQueryBuilder()
                              ->select( [ 'min_id' => 'MIN(page_id)', 'max_id' => 'MAX(page_id)' ] )
                              ->table( 'page' )
                  Severity: Minor
                  Found in maintenance/SaneitizeJobs.php - About 1 hr to fix

                    Method validateSpecificAlias has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function validateSpecificAlias() {
                            $connection = $this->getConnection();
                    
                            $fieldsToCleanup = array_filter( explode( ',', $this->getOption( 'fieldsToDelete', '' ) ) );
                            $fieldsToCleanup = array_merge( $fieldsToCleanup, $this->getSearchConfig()->get( "CirrusSearchIndexFieldsToCleanup" ) );
                    Severity: Minor
                    Found in maintenance/UpdateOneSearchIndexConfig.php - About 1 hr to fix

                      Method execute has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function execute() {
                              $this->indexSuffix = $this->getOption( 'indexSuffix' );
                              $this->indexBaseName = $this->getOption( 'baseName',
                                  $this->getSearchConfig()->get( SearchConfig::INDEX_BASE_NAME ) );
                      
                      
                      Severity: Minor
                      Found in maintenance/CopySearchIndex.php - About 1 hr to fix

                        Function listExposedProfiles has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function listExposedProfiles( $type ) {
                                $profiles = [];
                                if ( isset( $this->repositories[$type] ) ) {
                                    foreach ( $this->repositories[$type] as $repo ) {
                                        foreach ( $repo->listExposedProfiles() as $name => $profile ) {
                        Severity: Minor
                        Found in includes/Profile/SearchProfileService.php - About 1 hr 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 getProfileName has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function getProfileName( $type, $context = self::CONTEXT_DEFAULT, array $contextParams = [] ) {
                                $minPrio = PHP_INT_MAX;
                                if ( !isset( $this->defaultProfiles[$type][$context] ) ) {
                                    throw new SearchProfileException( "No default profile found for $type in context $context" );
                                }
                        Severity: Minor
                        Found in includes/Profile/SearchProfileService.php - About 1 hr 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 collectPrefixSearchResults has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private function collectPrefixSearchResults( CompletionResultsCollector $collector, array $results, CompletionRequestLog $log ) {
                                if ( !isset( $results[self::MSEARCH_KEY_PREFIX] ) ) {
                                    return 0;
                                }
                                $indexName = $this->prefixSearchRequestBuilder->getIndex()->getName();
                        Severity: Minor
                        Found in includes/CompletionSuggester.php - About 1 hr 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 __construct has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function __construct( SearchConfig $config, $weight, $profile ) {
                                parent::__construct( $config, $weight );
                                if ( isset( $profile['k'] ) ) {
                                    $this->k = $this->getOverriddenFactor( $profile['k'] );
                                    if ( $this->k <= 0 ) {
                        Severity: Minor
                        Found in includes/Search/Rescore/SatuFunctionScoreBuilder.php - About 1 hr 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 getQuery has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function getQuery() {
                                if ( !$this->nonTextQueries ) {
                                    $mainQuery = $this->mainQuery ?: new \Elastica\Query\MatchAll();
                                } else {
                                    $mainQuery = new \Elastica\Query\BoolQuery();
                        Severity: Minor
                        Found in includes/Search/SearchContext.php - About 1 hr 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 extractResults has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            final public function extractResults() {
                                if ( $this->results === null ) {
                                    $this->results = [];
                                    $elasticaResults = $this->getElasticaResultSet();
                                    if ( $elasticaResults !== null ) {
                        Severity: Minor
                        Found in includes/Search/BaseCirrusSearchResultSet.php - About 1 hr 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 __construct has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function __construct( SearchConfig $config, $weight, $profile ) {
                                parent::__construct( $config, $weight );
                                if ( isset( $profile['impact'] ) ) {
                                    $this->impact = $this->getOverriddenFactor( $profile['impact'] );
                                    if ( $this->impact <= 0 ) {
                        Severity: Minor
                        Found in includes/Search/Rescore/LogMultFunctionScoreBuilder.php - About 1 hr 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 append has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function append( FunctionScore $functionScore ) {
                                if ( !$this->namespacesToBoost || count( $this->namespacesToBoost ) == 1 ) {
                                    // nothing to boost, no need to initialize anything else.
                                    return;
                                }
                        Severity: Minor
                        Found in includes/Search/Rescore/NamespacesFunctionScoreBuilder.php - About 1 hr 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 get has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function get( array $docIds, $sourceFiltering, $usePoolCounter = true ) {
                                $connection = $this->getOverriddenConnection();
                                $indexSuffix = $connection->pickIndexSuffixForNamespaces(
                                    $this->searchContext->getNamespaces()
                                );
                        Severity: Minor
                        Found in includes/Searcher.php - About 1 hr 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

                        Severity
                        Category
                        Status
                        Source
                        Language