wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 718 of 718 total issues

Method build has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function build( array $inputDoc, $suggestType, $score, \Elastica\Document $suggestDoc, $targetNamespace ) {
Severity: Minor
Found in includes/BuildDocument/Completion/NaiveSubphrasesSuggestionsBuilder.php - About 35 mins to fix

    Method doApply has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        protected function doApply( SearchContext $context, $key, $value, $quotedValue, $negated ) {
    Severity: Minor
    Found in includes/Query/MoreLikeFeature.php - About 35 mins to fix

      Method doApply has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          protected function doApply( SearchContext $context, $key, $value, $quotedValue, $negated ) {
      Severity: Minor
      Found in includes/Query/TextFieldFilterFeature.php - About 35 mins to fix

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

                $name,
                $type,
                string $indexAnalyzer,
                string $searchAnalyzer,
                string $similarity
        Severity: Minor
        Found in includes/Wikimedia/WeightedTags.php - About 35 mins to fix

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

              protected function getTimeout( $searchType = 'default' ) {
                  $timeout = $this->connection->getConfig()->getElement( 'CirrusSearchSearchShardTimeout', $searchType );
                  if ( $timeout !== null ) {
                      return $timeout;
                  }
          Severity: Minor
          Found in includes/ElasticsearchIntermediary.php and 1 other location - About 35 mins to fix
          includes/ElasticsearchIntermediary.php on lines 350..360

          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 92.

          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

              protected function getClientTimeout( $searchType = 'default' ) {
                  $timeout = $this->connection->getConfig()->getElement( 'CirrusSearchClientSideSearchTimeout', $searchType );
                  if ( $timeout !== null ) {
                      return $timeout;
                  }
          Severity: Minor
          Found in includes/ElasticsearchIntermediary.php and 1 other location - About 35 mins to fix
          includes/ElasticsearchIntermediary.php on lines 334..344

          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 92.

          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 formatMessage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              protected static function formatMessage( array $error ) {
                  if ( isset( $error['actionReasons'] ) ) {
                      $message = $error['type'] . ': ' . $error['reason'];
                      foreach ( $error['actionReasons'] as $actionReason ) {
                          $message .= "  - $actionReason\n";
          Severity: Minor
          Found in includes/ElasticaErrorHandler.php - About 35 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 reformat has a Cognitive Complexity of 7 (exceeds 5 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: Minor
          Found in includes/Api/CheckSanity.php - About 35 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 sendDeletes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function sendDeletes( $docIds, $indexSuffix = null ) {
                  if ( $indexSuffix === null ) {
                      $indexes = $this->connection->getAllIndexSuffixes( Connection::PAGE_DOC_TYPE );
                  } else {
                      $indexes = [ $indexSuffix ];
          Severity: Minor
          Found in includes/DataSender.php - About 35 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 intersect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function intersect( CrossSearchStrategy $other ) {
                  if ( $other === self::hostWikiOnlyStrategy() || $this === self::hostWikiOnlyStrategy() ) {
                      return self::hostWikiOnlyStrategy();
                  }
                  $crossL = $other->crossLanguageSearchSupported && $this->crossLanguageSearchSupported;
          Severity: Minor
          Found in includes/CrossSearchStrategy.php - About 35 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 onLinksUpdateComplete has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function onLinksUpdateComplete( $linksUpdate, $ticket ) {
                  if ( !$this->isEnabled() ) {
                      return;
                  }
                  // defer processing the LinksUpdateComplete hook until other hooks tagged in PageChangeTracker
          Severity: Minor
          Found in includes/ChangeListener.php - About 35 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 preparePageReferencesForLinksUpdate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function preparePageReferencesForLinksUpdate( $pageReferences, int $max, $excludeBadUTF = false ) {
                  $pageReferences = self::pickFromArray( $pageReferences, $max );
                  $dBKeys = [];
                  foreach ( $pageReferences as $pageReference ) {
                      $title = Title::newFromPageReference( $pageReference );
          Severity: Minor
          Found in includes/ChangeListener.php - About 35 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 getDetectors has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getDetectors() {
                  $detectors = [];
                  foreach ( $this->config->get( 'CirrusSearchLanguageDetectors' ) as $name => $klass ) {
                      if ( !class_exists( $klass ) ) {
                          LoggerFactory::getInstance( 'CirrusSearch' )->info(
          Severity: Minor
          Found in includes/LanguageDetector/LanguageDetectorFactory.php - About 35 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 prefixSearch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function prefixSearch( $search, $variants ) {
                  $searcher = $this->makeSearcher();
          
                  if ( $search ) {
                      $searcher->setResultsType( new FancyTitleResultsType( 'prefix' ) );
          Severity: Minor
          Found in includes/CirrusSearch.php - About 35 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 buildLogMessage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              private function buildLogMessage( RequestLog $log, array $context ) {
                  $message = $log->getDescription();
                  $message .= " against {index} took {tookMs} millis";
                  if ( isset( $context['elasticTookMs'] ) ) {
                      $message .= " and {elasticTookMs} Elasticsearch millis";
          Severity: Minor
          Found in includes/RequestLogger.php - About 35 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 getProfiles has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getProfiles( $profileType, User $user = null ) {
                  $profileService = $this->config->getProfileService();
                  $serviceProfileType = null;
                  switch ( $profileType ) {
                      case SearchEngine::COMPLETION_PROFILE_TYPE:
          Severity: Minor
          Found in includes/CirrusSearch.php - About 35 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 checkExisitingPage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              private function checkExisitingPage( $docId, $pageId, $page, array $fromIndex ) {
                  $inIndex = $fromIndex !== [];
                  if ( $this->checkIfRedirect( $page ) ) {
                      if ( $inIndex ) {
                          foreach ( $fromIndex as $indexInfo ) {
          Severity: Minor
          Found in includes/Sanity/Checker.php - About 35 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 completionSearchBackend has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function completionSearchBackend( $search ) {
                  if ( in_array( NS_SPECIAL, $this->namespaces ) ) {
                      // delegate special search to parent
                      return parent::completionSearchBackend( $search );
                  }
          Severity: Minor
          Found in includes/CirrusSearch.php - About 35 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 getAllIndexSuffixes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getAllIndexSuffixes( $documentType = self::PAGE_DOC_TYPE ) {
                  Assert::parameter( $documentType === null || isset( self::SUFFIX_MAPPING[$documentType] ),
                      '$documentType', "Unknown mapping type $documentType" );
                  $indexSuffixes = [];
          
          
          Severity: Minor
          Found in includes/Connection.php - About 35 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 loadProfileByName has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function loadProfileByName( $type, $name, $failIfMissing = true ) {
                  if ( isset( $this->repositories[$type] ) ) {
                      $repos = $this->repositories[$type];
                      foreach ( $repos as $repo ) {
                          $prof = $repo->getProfile( $name );
          Severity: Minor
          Found in includes/Profile/SearchProfileService.php - About 35 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