wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 718 of 718 total issues

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

    public function build( array $config ): array {
        $langStem = "{$this->langName}_stemmer";

        if ( $this->unpacked ) {
            // Analyzer config for char_filter and filter will be in the order below,
Severity: Minor
Found in includes/Maintenance/AnalyzerBuilder.php - About 5 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 36 (exceeds 5 allowed). Consider refactoring.
Open

    public function build( $inputDocs, $explain = false ) {
        $titleFactory = MediaWikiServices::getInstance()->getTitleFactory();
        // Cross namespace titles
        $crossNsTitles = [];
        $docs = [];
Severity: Minor
Found in includes/BuildDocument/Completion/SuggestBuilder.php - About 5 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 validateParams has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

    private function validateParams() {
        $pageOptionCount = (int)$this->hasOption( 'page' ) + (int)$this->hasOption( 'page-list' )
            + (int)$this->hasOption( 'pageid-list' );
        if ( $pageOptionCount !== 1 ) {
            $this->fatalError( "Exactly one of --page, --page-list and --pageid-list must be used" );
Severity: Minor
Found in maintenance/UpdateWeightedTags.php - About 5 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 build has 133 lines of code (exceeds 25 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: Major
Found in includes/Query/FullTextQueryStringQueryBuilder.php - About 5 hrs to fix

    Function searchMulti has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function searchMulti( MSearchRequests $msearches ) {
            $searches = $msearches->getRequests();
            $contextResultsType = $this->searchContext->getResultsType();
            $cirrusDebugOptions = $this->searchContext->getDebugOptions();
            Assert::precondition( !$cirrusDebugOptions->isCirrusDumpQuery(), 'Must not reach this method when dumping the query' );
    Severity: Minor
    Found in includes/Searcher.php - About 5 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        'wsum_inclinks_pv' => [
            'score_mode' => 'sum',
            'boost_mode' => 'sum',
            'functions' => [
                [
    Severity: Major
    Found in profiles/RescoreFunctionChains.config.php and 1 other location - About 5 hrs to fix
    profiles/RescoreFunctionChains.config.php on lines 134..181

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 188.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        'wsum_inclinks_pv+' => [
            'score_mode' => 'sum',
            'boost_mode' => 'sum',
            'functions' => [
                [
    Severity: Major
    Found in profiles/RescoreFunctionChains.config.php and 1 other location - About 5 hrs to fix
    profiles/RescoreFunctionChains.config.php on lines 84..131

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 188.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method buildCirrusSearchRequestEvent has 126 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function buildCirrusSearchRequestEvent() {
            global $wgRequest, $wgServerName;
            $webrequest = $wgRequest;
    
            // for the moment RequestLog::getRequests() is still created in the
    Severity: Major
    Found in includes/RequestLogger.php - About 5 hrs to fix

      Method searchMulti has 125 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function searchMulti( MSearchRequests $msearches ) {
              $searches = $msearches->getRequests();
              $contextResultsType = $this->searchContext->getResultsType();
              $cirrusDebugOptions = $this->searchContext->getDebugOptions();
              Assert::precondition( !$cirrusDebugOptions->isCirrusDumpQuery(), 'Must not reach this method when dumping the query' );
      Severity: Major
      Found in includes/Searcher.php - About 5 hrs to fix

        Method build has 123 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function build() {
                $resultsType = $this->searchContext->getResultsType();
        
                $query = new Query();
                $query->setTrackTotalHits( $this->searchContext->getTrackTotalHits() );
        Severity: Major
        Found in includes/Search/SearchRequestBuilder.php - About 4 hrs to fix

          Function postProcess has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
          Open

              public function postProcess( CompletionResultsCollector $collector, ResultSet $results, $indexName ) {
                  $suggestResp = $results->getSuggests();
                  if ( $suggestResp === [] ) {
                      // Edge case where the index contains 0 documents and does not even return the 'suggest' field
                      return 0;
          Severity: Minor
          Found in includes/Query/CompSuggestQueryBuilder.php - About 4 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 sendData has 120 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function sendData( $indexSuffix, array $documents ) {
                  if ( !$documents ) {
                      return Status::newGood();
                  }
          
          
          Severity: Major
          Found in includes/DataSender.php - About 4 hrs to fix

            File CirrusSearch.php has 366 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            
            namespace CirrusSearch;
            
            use CirrusSearch\Extra\MultiList\MultiListBuilder;
            Severity: Minor
            Found in includes/CirrusSearch.php - About 4 hrs to fix

              Function buildCirrusSearchRequestEvent has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function buildCirrusSearchRequestEvent() {
                      global $wgRequest, $wgServerName;
                      $webrequest = $wgRequest;
              
                      // for the moment RequestLog::getRequests() is still created in the
              Severity: Minor
              Found in includes/RequestLogger.php - About 4 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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  private function loadFullTextQueryProfiles( SearchProfileService $service, SearchConfig $config ) {
                      $service->registerFileRepository( SearchProfileService::FT_QUERY_BUILDER, self::CIRRUS_BASE,
                          __DIR__ . '/../../profiles/FullTextQueryBuilderProfiles.config.php' );
              
                      $service->registerRepository( new ConfigProfileRepository( SearchProfileService::FT_QUERY_BUILDER, self::CIRRUS_CONFIG,
              Severity: Major
              Found in includes/Profile/SearchProfileServiceFactory.php and 1 other location - About 4 hrs to fix
              includes/Profile/SearchProfileServiceFactory.php on lines 378..392

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 173.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  private function loadFallbackProfiles( SearchProfileService $service, SearchConfig $config ) {
                      $service->registerFileRepository( SearchProfileService::FALLBACKS, self::CIRRUS_BASE,
                          __DIR__ . '/../../profiles/FallbackProfiles.config.php' );
                      $service->registerRepository( new ConfigProfileRepository( SearchProfileService::FALLBACKS, self::CIRRUS_CONFIG,
                          'CirrusSearchFallbackProfiles', $config ) );
              Severity: Major
              Found in includes/Profile/SearchProfileServiceFactory.php and 1 other location - About 4 hrs to fix
              includes/Profile/SearchProfileServiceFactory.php on lines 326..341

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 173.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Function replace has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function replace( array $profile, array $replacement ) {
                      $cur = &$profile;
                      foreach ( $replacement['matches'] as $match ) {
                          if ( !is_array( $cur ) ) {
                              return $profile;
              Severity: Minor
              Found in includes/Profile/ArrayPathSetter.php - About 4 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 sendData has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function sendData( $indexSuffix, array $documents ) {
                      if ( !$documents ) {
                          return Status::newGood();
                      }
              
              
              Severity: Minor
              Found in includes/DataSender.php - About 4 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

              AnalyzerBuilder has 34 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class AnalyzerBuilder {
                  /**
                   * Indicate that filters should be automatically appended or prepended, rather
                   * than inserted before a given filter.
                   */
              Severity: Minor
              Found in includes/Maintenance/AnalyzerBuilder.php - About 4 hrs to fix

                Method getDefaultFields has 108 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function getDefaultFields() {
                        // Note never to set something as type='object' here because that isn't returned by elasticsearch
                        // and is inferred anyway.
                        $titleExtraAnalyzers = [
                            [ 'analyzer' => 'prefix', 'search_analyzer' => 'near_match', 'index_options' => 'docs', 'norms' => false ],
                Severity: Major
                Found in includes/Maintenance/MappingConfigBuilder.php - About 4 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language