wikimedia/mediawiki-core

View on GitHub
includes/search/TitleMatcher.php

Summary

Maintainability
D
2 days
Test Coverage

Function getNearMatchInternal has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getNearMatchInternal( $searchterm ) {
        $allSearchTerms = [ $searchterm ];

        if ( $this->languageConverter->hasVariants() ) {
            $allSearchTerms = array_unique( array_merge(
Severity: Minor
Found in includes/search/TitleMatcher.php - About 6 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 getNearMatchInternal has 94 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function getNearMatchInternal( $searchterm ) {
        $allSearchTerms = [ $searchterm ];

        if ( $this->languageConverter->hasVariants() ) {
            $allSearchTerms = array_unique( array_merge(
Severity: Major
Found in includes/search/TitleMatcher.php - About 3 hrs to fix

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

            ServiceOptions $options,
            Language $contentLanguage,
            LanguageConverterFactory $languageConverterFactory,
            HookContainer $hookContainer,
            WikiPageFactory $wikiPageFactory,
    Severity: Major
    Found in includes/search/TitleMatcher.php - About 1 hr to fix

      Avoid too many return statements within this method.
      Open

                      return $title;
      Severity: Major
      Found in includes/search/TitleMatcher.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        return $title;
        Severity: Major
        Found in includes/search/TitleMatcher.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return $title;
          Severity: Major
          Found in includes/search/TitleMatcher.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return $title;
            Severity: Major
            Found in includes/search/TitleMatcher.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return $title;
              Severity: Major
              Found in includes/search/TitleMatcher.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return $title;
                Severity: Major
                Found in includes/search/TitleMatcher.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return Title::makeTitle( NS_MEDIAWIKI, $this->language->ucfirst( $title->getText() ) );
                  Severity: Major
                  Found in includes/search/TitleMatcher.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return $title;
                    Severity: Major
                    Found in includes/search/TitleMatcher.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return $this->getNearMatch( $matches[1] );
                      Severity: Major
                      Found in includes/search/TitleMatcher.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return $title;
                        Severity: Major
                        Found in includes/search/TitleMatcher.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                              return $title;
                          Severity: Major
                          Found in includes/search/TitleMatcher.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                            return SpecialPage::getTitleFor( 'Contributions', $title->getDBkey() );
                            Severity: Major
                            Found in includes/search/TitleMatcher.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                      return null;
                              Severity: Major
                              Found in includes/search/TitleMatcher.php - About 30 mins to fix

                                There are no issues that match your filters.

                                Category
                                Status