wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 691 of 718 total issues

Method collect has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function collect( SearchSuggestion $suggestion, $profileName, $index ) {
        if ( !$this->canCollect( $suggestion->getSuggestedTitleID(), $suggestion->getScore() ) ) {
            return false;
        }

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

    Method finishRequest has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function finishRequest( Connection $connection ) {
            if ( !$this->currentRequestLog ) {
                LoggerFactory::getInstance( 'CirrusSearch' )->warning(
                    'finishRequest called without staring a request'
                );
    Severity: Minor
    Found in includes/ElasticsearchIntermediary.php - About 1 hr to fix

      Method parseValue has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function parseValue( $key, $value, $quotedValue, $valueDelimiter, $suffix, WarningCollector $warningCollector ) {
              $values = explode( '|', $value, self::MAX_CONDITIONS + 1 );
              if ( count( $values ) > self::MAX_CONDITIONS ) {
                  $warningCollector->addWarning(
                      'cirrussearch-feature-too-many-conditions',
      Severity: Minor
      Found in includes/Query/HasTemplateFeature.php - About 1 hr to fix

        Method internalParseValue has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function internalParseValue( $value ) {
                $trimQuote = '/^"([^"]*)"\s*$/';
                $value = preg_replace( $trimQuote, "$1", $value );
                // NS_MAIN by default
                $namespaces = [ NS_MAIN ];
        Severity: Minor
        Found in includes/Query/PrefixFeature.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 score has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function score( \CirrusSearch\Search\SearchQuery $query ) {
                    Assert::parameter( $query->getSearchEngineEntryPoint() === $this->searchEngineEntryPoint,
                        'query',
                        "must be {$this->searchEngineEntryPoint} but {$query->getSearchEngineEntryPoint()} given." );
            
            
            Severity: Minor
            Found in includes/Dispatch/BasicSearchQueryRoute.php - About 1 hr to fix

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

                  private function getCompiledReplacements() {
                      if ( $this->compiledReplacements === null ) {
                          $this->compiledReplacements = [];
                          foreach ( $this->replacements as $repl => $value ) {
                              if ( !is_string( $repl ) ) {
              Severity: Minor
              Found in includes/Profile/ArrayPathSetter.php - About 1 hr to fix

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

                    protected function checkConfig( $actual, array $required, $indent = null ) {
                        foreach ( $required as $key => $value ) {
                            $this->debugCheckConfig( "\n$indent$key: " );
                            if ( !array_key_exists( $key, $actual ) ) {
                                $this->debugCheckConfig( "not found..." );
                Severity: Minor
                Found in includes/Maintenance/Validators/Validator.php - About 1 hr to fix

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

                      private static function getOnWikiBoostTemplates( SearchConfig $config ) {
                          $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
                          $cacheKey = $cache->makeGlobalKey( 'cirrussearch-boost-templates', $config->getWikiId() );
                          if ( $config->getWikiId() == WikiMap::getCurrentWikiId() ) {
                              // Local wiki we can fetch boost templates from system
                  Severity: Minor
                  Found in includes/Util.php - About 1 hr to fix

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

                        public function parseValue( $key, $value, $quotedValue, $valueDelimiter, $suffix, WarningCollector $warningCollector ) {
                            // en:Programming|id:3041512\
                            $categories = explode( '|', $value );// en:programming
                            if ( count( $categories ) > $this->maxConditions ) {
                                $warningCollector->addWarning(
                    Severity: Minor
                    Found in includes/Query/InCategoryFeature.php - About 1 hr to fix

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

                          public function resize( Document $document ): array {
                              $this->stats = [];
                              $this->document = $document;
                              $originalDocLength = self::estimateDataSize( $document );
                              $this->docLength = $originalDocLength;
                      Severity: Minor
                      Found in includes/BuildDocument/DocumentSizeLimiter.php - About 1 hr to fix

                        Consider simplifying this complex logical expression.
                        Open

                                        if ( $optVal === null || $optVal === false || $optName === 'fromId' ||
                                            $optName === 'toId' || $optName === 'buildChunks' ||
                                            ( $optName === 'memory-limit' && $optVal === 'max' )
                                        ) {
                                            continue;
                        Severity: Major
                        Found in includes/Maintenance/ChunkBuilder.php - About 1 hr to fix

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

                                  ParsedNode $root,
                                  $query,
                                  $rawQuery,
                                  $queryCleanups,
                                  ?NamespaceHeaderNode $namespaceHeader,
                          Severity: Major
                          Found in includes/Parser/AST/ParsedQuery.php - About 1 hr to fix

                            Consider simplifying this complex logical expression.
                            Open

                                    if ( $this->hasComplex ) {
                                        $classes[] = self::COMPLEX_QUERY;
                                        // @phan-suppress-next-line PhanSuspiciousValueComparison
                                    } elseif ( $this->maxDepth === 0 && $this->hasWords && !$this->hasSimplePhrase ) {
                                        $classes[] = self::SIMPLE_BAG_OF_WORDS;
                            Severity: Major
                            Found in includes/Parser/BasicQueryClassifier.php - About 1 hr to fix

                              Method onPageUndeleteComplete has 8 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                      ProperPageIdentity $page,
                                      Authority $restorer,
                                      string $reason,
                                      RevisionRecord $restoredRev,
                                      ManualLogEntry $logEntry,
                              Severity: Major
                              Found in includes/ArchiveChangeListener.php - About 1 hr to fix

                                Function run has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                def run(wiki, clusters, index_types, batch_size, start, end, q, stats):
                                Severity: Major
                                Found in scripts/compare-clusters.py - About 1 hr to fix

                                  Function addRequest has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function addRequest( RequestLog $log, UserIdentity $user = null, $slowMillis = null ) {
                                          global $wgCirrusSearchLogElasticRequests;
                                  
                                          // @todo Is this necessary here? Check on what uses the response value
                                          $finalContext = $log->getLogVariables() + [
                                  Severity: Minor
                                  Found in includes/RequestLogger.php - About 55 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 classifyError has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public static function classifyError( \Elastica\Exception\ExceptionInterface $exception = null ) {
                                          if ( $exception === null ) {
                                              return 'unknown';
                                          }
                                          $error = self::extractFullError( $exception );
                                  Severity: Minor
                                  Found in includes/ElasticaErrorHandler.php - About 55 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 getStatus has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function getStatus() {
                                          if ( $this->response ) {
                                              // task complete
                                              return $this->response;
                                          }
                                  Severity: Minor
                                  Found in includes/Elastica/ReindexTask.php - About 55 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 createFromProfile has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      private static function createFromProfile( SearchQuery $query, array $profile, InterwikiResolver $interwikiResolver ): FallbackRunner {
                                          $fallbackMethods = [];
                                          $methodDefs = $profile['methods'] ?? [];
                                          foreach ( $methodDefs as $name => $methodDef ) {
                                              if ( !isset( $methodDef['class'] ) ) {
                                  Severity: Minor
                                  Found in includes/Fallbacks/FallbackRunner.php - About 55 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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language