wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 691 of 718 total issues

File AnalyzerBuilder.php has 299 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace CirrusSearch\Maintenance;

use MediaWiki\Config\ConfigException;
Severity: Minor
Found in includes/Maintenance/AnalyzerBuilder.php - About 3 hrs to fix

    QueryStringRegexParser has 27 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class QueryStringRegexParser implements QueryParser {
        /**
         * Whitespace regex including unicode and some control chars
         */
        private const WHITESPACE_REGEX = '/\G[\pZ\pC]+/u';
    Severity: Minor
    Found in includes/Parser/QueryStringRegex/QueryStringRegexParser.php - About 3 hrs to fix

      Function detect has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          public function detect( $text ) {
              $dirs = $this->config->getElement( 'CirrusSearchTextcatModel' );
              if ( !$dirs ) {
                  return null;
              }
      Severity: Minor
      Found in includes/LanguageDetector/TextCat.php - About 3 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 doJob has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function doJob() {
              $profile = $this->searchConfig
                  ->getProfileService()
                  ->loadProfileByName( SearchProfileService::SANEITIZER, $this->params['profile'], false );
      
      
      Severity: Minor
      Found in includes/Job/CheckerJob.php - About 3 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 parse has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          public function parse( string $query, int $start, int $end ) {
              $match = [];
              Assert::precondition( $start < $end, '$start < $end' );
              Assert::precondition( $end <= strlen( $query ), '$end <= strlen( $query )' );
              $ret = preg_match( self::NEGATION, $query, $match, PREG_OFFSET_CAPTURE, $start );
      Severity: Minor
      Found in includes/Parser/QueryStringRegex/NonPhraseParser.php - About 3 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 truncateField has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          private function truncateField( string $field, bool $keyword, int $minFieldLength, int $maxDocSize, string $statBucket ): void {
              if ( !$this->document->has( $field ) ) {
                  return;
              }
              $fieldData = $this->document->get( $field );
      Severity: Minor
      Found in includes/BuildDocument/DocumentSizeLimiter.php - About 3 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

      AnalysisConfigBuilder has 26 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class AnalysisConfigBuilder {
          /**
           * Version number for the core analysis. Increment the major
           * version when the analysis changes in an incompatible way,
           * and change the minor version when it changes but isn't
      Severity: Minor
      Found in includes/Maintenance/AnalysisConfigBuilder.php - About 3 hrs to fix

        UpdateSuggesterIndex has 26 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class UpdateSuggesterIndex extends Maintenance {
            /**
             * @var string language code we're building for
             */
            private $langCode;
        Severity: Minor
        Found in maintenance/UpdateSuggesterIndex.php - About 3 hrs to fix

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

              public function execute() {
                  $this->disablePoolCountersAndLogging();
          
                  $utils = new ConfigUtils( $this->getConnection()->getClient(), $this );
          
          
          Severity: Major
          Found in maintenance/UpdateOneSearchIndexConfig.php - About 3 hrs to fix

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

                protected function bulkResponseExceptionIsJustDocumentMissing(
                    ResponseException $exception, $logCallback = null
                ) {
                    $justDocumentMissing = true;
                    foreach ( $exception->getResponseSet()->getBulkResponses() as $bulkResponse ) {
            Severity: Minor
            Found in includes/DataSender.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 searchTextInternal has a Cognitive Complexity of 21 (exceeds 5 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: Minor
            Found in includes/Searcher.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 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
                      Severity
                      Category
                      Status
                      Source
                      Language