wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 691 of 718 total issues

Method apply has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function apply( SearchContext $context, $term ) {
        $keyListRegex = implode(
            '|',
            array_map(
                static function ( $kw ) {
Severity: Major
Found in includes/Query/SimpleKeywordFeature.php - About 2 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

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

      class CirrusSearchResultBuilder {
          /**
           * @var array
           */
          private $data;
      Severity: Minor
      Found in includes/Search/CirrusSearchResultBuilder.php - About 2 hrs to fix

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

        class ResultSet extends BaseSearchResultSet implements CirrusSearchResultSet {
            use SearchResultSetTrait;
        
            /**
             * @var \Elastica\ResultSet
        Severity: Minor
        Found in includes/Search/ResultSet.php - About 2 hrs to fix

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

          class InterleavedResultSet extends BaseSearchResultSet implements CirrusSearchResultSet, SearchMetricsProvider {
              use SearchResultSetTrait;
          
              /** @var string[] Doc ID's belonging to team A */
              private $teamA;
          Severity: Minor
          Found in includes/Search/InterleavedResultSet.php - About 2 hrs to fix

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

            class ArrayCirrusSearchResult extends CirrusSearchResult {
                public const DOC_ID = 'doc_id';
                public const SCORE = 'score';
                public const EXPLANATION = 'explanation';
                public const TEXT_SNIPPET = 'text_snippet';
            Severity: Minor
            Found in includes/Search/ArrayCirrusSearchResult.php - About 2 hrs to fix

              Method buildSuggestConfig has 66 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function buildSuggestConfig() {
                      $field = 'suggest';
                      $config = $this->query->getSearchConfig();
                      $suggestSettings = $this->getProfile();
                      $settings = [
              Severity: Major
              Found in includes/Fallbacks/PhraseSuggestFallbackMethod.php - About 2 hrs to fix

                Method indexData has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function indexData(): int {
                        // We build the suggestions by reading CONTENT and GENERAL indices.
                        // This does not support extra indices like FILES on commons.
                        $sourceIndexSuffixes = [ Connection::CONTENT_INDEX_SUFFIX, Connection::GENERAL_INDEX_SUFFIX ];
                
                
                Severity: Major
                Found in maintenance/UpdateSuggesterIndex.php - About 2 hrs to fix

                  Function extractFullError has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function extractFullError( \Elastica\Exception\ExceptionInterface $exception ): array {
                          if ( $exception instanceof BulkResponseException ) {
                              $actionReasons = [];
                              foreach ( $exception->getActionExceptions() as $actionException ) {
                                  $actionReasons[] = $actionException->getMessage() . ': '
                  Severity: Minor
                  Found in includes/ElasticaErrorHandler.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

                  Function build has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function build( SearchContext $searchContext, $term ) {
                          $searchContext->addSyntaxUsed( 'full_text' );
                          // Transform MediaWiki specific syntax to filters and extra
                          // (pre-escaped) query string
                          foreach ( $this->features as $feature ) {
                  Severity: Minor
                  Found in includes/Query/FullTextQueryStringQueryBuilder.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

                  Function compare has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def compare(q, docs_by_cluster, stats, index_type):
                      keys = list(docs_by_cluster.keys())
                      head = keys[0]
                      other = keys[1:]
                      if not other:
                  Severity: Minor
                  Found in scripts/compare-clusters.py - 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 searchTextInternal has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function searchTextInternal( $term ) {
                          // Searcher needs to be cloned before any actual query building is done.
                          $interleaveSearcher = $this->buildInterleaveSearcher();
                  
                          $qb = $this->buildFullTextSearch( $term );
                  Severity: Major
                  Found in includes/Searcher.php - About 2 hrs to fix

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

                        public function execute() {
                            $this->disablePoolCountersAndLogging();
                    
                            $this->indexSuffix = $this->getBackCompatOption( 'indexSuffix', 'indexType' );
                            $this->indexBaseName = $this->getOption( 'baseName',
                    Severity: Major
                    Found in maintenance/DumpIndex.php - About 2 hrs to fix

                      Method mergeStatusWithChildren has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function mergeStatusWithChildren( array $status, array $childResponse ) {
                              foreach ( $childResponse['nodes'] as $nodeData ) {
                                  foreach ( $nodeData['tasks'] as $taskId => $childData ) {
                                      $sliceId = $childData['status']['slice_id'];
                                      $status['slices'][$sliceId] = $childData['status'];
                      Severity: Major
                      Found in includes/Elastica/ReindexTask.php - About 2 hrs to fix

                        Method extractFullError has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public static function extractFullError( \Elastica\Exception\ExceptionInterface $exception ): array {
                                if ( $exception instanceof BulkResponseException ) {
                                    $actionReasons = [];
                                    foreach ( $exception->getActionExceptions() as $actionException ) {
                                        $actionReasons[] = $actionException->getMessage() . ': '
                        Severity: Major
                        Found in includes/ElasticaErrorHandler.php - About 2 hrs to fix

                          Method extractMessageAndStatus has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static function extractMessageAndStatus( \Elastica\Exception\ExceptionInterface $exception = null ) {
                                  if ( !$exception ) {
                                      return [ Status::newFatal( 'cirrussearch-backend-error' ), '' ];
                                  }
                          
                          
                          Severity: Major
                          Found in includes/ElasticaErrorHandler.php - About 2 hrs to fix

                            File RequestLogger.php has 271 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            <?php
                            
                            namespace CirrusSearch;
                            
                            use ISearchResultSet;
                            Severity: Minor
                            Found in includes/RequestLogger.php - About 2 hrs to fix

                              SearchQueryBuilder has 23 functions (exceeds 20 allowed). Consider refactoring.
                              Open

                              final class SearchQueryBuilder {
                              
                                  /**
                                   * @var ParsedQuery
                                   */
                              Severity: Minor
                              Found in includes/Search/SearchQueryBuilder.php - About 2 hrs to fix

                                BaseCirrusSearchResultSet has 23 functions (exceeds 20 allowed). Consider refactoring.
                                Open

                                abstract class BaseCirrusSearchResultSet extends BaseSearchResultSet implements CirrusSearchResultSet {
                                    use SearchResultSetTrait;
                                
                                    /** @var bool */
                                    private $hasMoreResults = false;
                                Severity: Minor
                                Found in includes/Search/BaseCirrusSearchResultSet.php - About 2 hrs to fix

                                  File SuggestBuilder.php has 270 lines of code (exceeds 250 allowed). Consider refactoring.
                                  Open

                                  <?php
                                  
                                  namespace CirrusSearch\BuildDocument\Completion;
                                  
                                  use CirrusSearch\Connection;
                                  Severity: Minor
                                  Found in includes/BuildDocument/Completion/SuggestBuilder.php - About 2 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language