wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 718 of 718 total issues

Function configureHighlighting has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    protected function configureHighlighting( array &$field, array $subFields, $rootField = true ) {
        if ( $this->mappingFlags & MappingConfigBuilder::OPTIMIZE_FOR_EXPERIMENTAL_HIGHLIGHTER ) {
            if ( $this->checkFlag( self::SPEED_UP_HIGHLIGHTING ) ) {
                if ( $rootField ) {
                    $field[ 'index_options' ] = 'offsets';
Severity: Minor
Found in includes/Search/TextIndexField.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 overrideMoreLikeThisOptionsFromMessage has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    private static function overrideMoreLikeThisOptionsFromMessage() {
        global $wgCirrusSearchMoreLikeThisConfig,
            $wgCirrusSearchMoreLikeThisAllowedFields,
            $wgCirrusSearchMoreLikeThisMaxQueryTermsLimit,
            $wgCirrusSearchMoreLikeThisFields;
Severity: Minor
Found in includes/Hooks.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 pickBest has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function pickBest() {
        if ( !$this->titles ) {
            return null;
        }
        if ( !$this->term ) {
Severity: Minor
Found in includes/NearMatchPicker.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 getMapping has 72 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: Major
Found in includes/Search/TextIndexField.php - About 2 hrs to fix

    Method classifyError has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function classifyError( \Elastica\Exception\ExceptionInterface $exception = null ) {
            if ( $exception === null ) {
                return 'unknown';
            }
            $error = self::extractFullError( $exception );
    Severity: Major
    Found in includes/ElasticaErrorHandler.php - About 2 hrs to fix

      SearchProfileService has 25 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class SearchProfileService {
      
          /**
           * Profile type for ordering crossproject result blocks
           */
      Severity: Minor
      Found in includes/Profile/SearchProfileService.php - About 2 hrs to fix

        Method showJobDetail has 69 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function showJobDetail() {
                $profile = $this->getSearchConfig()
                    ->getProfileService()
                    ->loadProfileByName( SearchProfileService::SANEITIZER, $this->profileName );
                '@phan-var array $profile';
        Severity: Major
        Found in maintenance/SaneitizeJobs.php - About 2 hrs to fix

          Function parse has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              public function parse( $query, $start, $end ) {
                  $match = [];
                  Assert::precondition( $start < $end, '$start < $end' );
                  Assert::precondition( $end <= strlen( $query ), '$end <= strlen( $query )' );
                  if ( preg_match( self::PHRASE_REGEX, $query, $match, 0, $start ) === 1 ) {
          Severity: Minor
          Found in includes/Parser/QueryStringRegex/PhraseQueryParser.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 reformat has 67 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function reformat( array $problems ): array {
                  $clean = [];
                  $indexBaseName = $this->getSearchConfig()->get( SearchConfig::INDEX_BASE_NAME );
                  // Generic connection for resolving index names, its always the same everywhere
                  $connection = Connection::getPool( $this->getSearchConfig() );
          Severity: Major
          Found in includes/Api/CheckSanity.php - About 2 hrs to fix

            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

                            Severity
                            Category
                            Status
                            Source
                            Language