wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub

Showing 718 of 718 total issues

Function execute has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $this->disablePoolCountersAndLogging();

        $utils = new ConfigUtils( $this->getConnection()->getClient(), $this );

Severity: Minor
Found in maintenance/UpdateOneSearchIndexConfig.php - About 1 hr 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 execute has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $this->metaStore = $this->getMetaStore();

        if ( $this->hasOption( 'dump' ) ) {
            $this->dump();
Severity: Minor
Found in maintenance/Metastore.php - About 1 hr 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 main has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def main(
    allow_updates: bool,
    page_id_exclusions_file: TextIO,
    verbose: bool,
    weighted_tags_queries: Sequence[str],
Severity: Minor
Found in scripts/cleanup_weighted_tags.py - About 1 hr 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 execute has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function execute() {
        $service = $this->service;
        $verbose = $this->getParameter( 'verbose' );
        $contexts = [];
        foreach ( $service->listProfileTypes() as $type ) {
Severity: Minor
Found in includes/Api/ProfilesDump.php - About 1 hr to fix

    Method getProfiles has 31 lines of code (exceeds 25 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 1 hr to fix

      Method buildConfig has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function buildConfig() {
              $suggest = [
                  'dynamic' => false,
                  '_source' => [ 'enabled' => true ],
                  'properties' => [
      Severity: Minor
      Found in includes/Maintenance/SuggesterMappingConfigBuilder.php - About 1 hr to fix

        Method validate has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function validate() {
                $this->outputIndented( "Validating mappings..." );
                if ( $this->optimizeIndexForExperimentalHighlighter &&
                    !in_array( 'experimental-highlighter', $this->availablePlugins ) ) {
                    $this->output( "impossible!\n" );
        Severity: Minor
        Found in includes/Maintenance/Validators/MappingValidator.php - About 1 hr to fix

          Method buildGlobalCustomFilters has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static function buildGlobalCustomFilters(): array {
                  $gcf = [
                      //////////////////////////
                      // char filters
                      'globo_norm' => new GlobalCustomFilter( 'char_filter' ),
          Severity: Minor
          Found in includes/Maintenance/AnalysisConfigBuilder.php - About 1 hr to fix

            Method finalize has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function finalize( Document $doc, bool $enforceLatest = true, RevisionRecord $revision = null ): bool {
                    $flags = CirrusIndexField::getHint( $doc, self::HINT_FLAGS );
                    if ( $flags !== null ) {
                        $docRevision = $doc->get( 'version' );
                        if ( $revision !== null && $docRevision !== $revision->getId() ) {
            Severity: Minor
            Found in includes/BuildDocument/BuildDocument.php - About 1 hr to fix

              Method extractDisplayTitle has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private static function extractDisplayTitle( Title $title, ParserOutput $output ): ?string {
                      $titleText = $title->getText();
                      $titlePrefixedText = $title->getPrefixedText();
              
                      $raw = $output->getDisplayTitle();
              Severity: Minor
              Found in includes/BuildDocument/ParserOutputPageProperties.php - About 1 hr to fix

                Method successApproximation has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function successApproximation( FallbackRunnerContext $context ) {
                        $firstPassResults = $context->getInitialResultSet();
                        if ( !$this->query->isAllowRewrite() ) {
                            return 0.0;
                        }
                Severity: Minor
                Found in includes/Fallbacks/LangDetectFallbackMethod.php - About 1 hr to fix

                  Method doTitleSnippet has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function doTitleSnippet( Title $title, \Elastica\Result $result, array $highlights ) {
                          $matched = false;
                          foreach ( $this->highligtedFields[ArrayCirrusSearchResult::TITLE_SNIPPET] as $hlField ) {
                              if ( isset( $highlights[$hlField->getFieldName()] ) ) {
                                  $nstext = $title->getNamespace() === 0 ? '' : $this->titleHelper->getNamespaceText( $title ) . ':';
                  Severity: Minor
                  Found in includes/Search/FullTextCirrusSearchResultBuilder.php - About 1 hr to fix

                    Method copyQueryForCrossSearch has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private static function copyQueryForCrossSearch( SearchConfig $config, SearchQuery $original ): SearchQueryBuilder {
                            Assert::precondition( $original->getContextualFilters() === [], 'The initial must not have contextual filters' );
                            $builder = new self();
                            $builder->parsedQuery = $original->getParsedQuery();
                            $builder->searchEngineEntryPoint = $original->getSearchEngineEntryPoint();
                    Severity: Minor
                    Found in includes/Search/SearchQueryBuilder.php - About 1 hr to fix

                      Method isProfileNamespaceSupported has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function isProfileNamespaceSupported( array $profile ) {
                              if ( !is_array( $profile['supported_namespaces'] ) ) {
                                  switch ( $profile['supported_namespaces'] ) {
                                      case 'all':
                                          return true;
                      Severity: Minor
                      Found in includes/Search/Rescore/RescoreBuilder.php - About 1 hr to fix

                        Method pickIndexIdentifierFromOption has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function pickIndexIdentifierFromOption( $option, $typeName ): Status {
                                if ( $option === 'now' ) {
                                    $identifier = strval( time() );
                                    $this->outputIndented( "Setting index identifier...{$typeName}_{$identifier}\n" );
                                    return Status::newGood( $identifier );
                        Severity: Minor
                        Found in includes/Maintenance/ConfigUtils.php - About 1 hr to fix

                          Method fetchCategories has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function fetchCategories( $rootCategory, WarningCollector $warningCollector ) {
                                  $title = Title::makeTitleSafe( NS_CATEGORY, $rootCategory );
                                  if ( $title === null ) {
                                      $warningCollector->addWarning( 'cirrussearch-feature-deepcat-invalid-title' );
                                      return [];
                          Severity: Minor
                          Found in includes/Query/DeepcatFeature.php - About 1 hr to fix

                            Method isIndexLive has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function isIndexLive( $indexName ): Status {
                                    try {
                                        // primary check, verify no aliases point at our index. This invokes
                                        // the endpoint directly, rather than Index::getAliases, as that method
                                        // does not check http status codes and can incorrectly report no aliases.
                            Severity: Minor
                            Found in includes/Maintenance/ConfigUtils.php - About 1 hr to fix

                              Method collectTitlesFromDB has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  private function collectTitlesFromDB( $term ) {
                                      $titles = [];
                                      $found = [];
                                      $titleFactory = MediaWikiServices::getInstance()->getTitleFactory();
                                      $wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
                              Severity: Minor
                              Found in includes/Query/MoreLikeTrait.php - About 1 hr to fix

                                Method finishInitializeBatch has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function finishInitializeBatch(): void {
                                        if ( !$this->linkCountClosures ) {
                                            return;
                                        }
                                        $linkCountClosureCount = count( $this->linkCountClosures );
                                Severity: Minor
                                Found in includes/BuildDocument/RedirectsAndIncomingLinks.php - About 1 hr to fix

                                  Method identifyNamespace has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public static function identifyNamespace( $namespace, $method = 'naive', Language $language = null ) {
                                          static $naive = null;
                                          static $utr30 = null;
                                  
                                          $normalizer = null;
                                  Severity: Minor
                                  Found in includes/Util.php - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language