wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub
includes/Hooks.php

Summary

Maintainability
D
2 days
Test Coverage

File Hooks.php has 420 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace CirrusSearch;

use CirrusSearch\Search\FancyTitleResultsType;
Severity: Minor
Found in includes/Hooks.php - About 6 hrs to fix

    Hooks has 30 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Hooks implements
        UserGetDefaultOptionsHook,
        GetPreferencesHook,
        APIAfterExecuteHook,
        ApiBeforeMainHook,
    Severity: Minor
    Found in includes/Hooks.php - About 3 hrs to fix

      Function overrideMoreLikeThisOptionsFromMessage has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function overrideMoreLikeThisOptionsFromMessage() {
              global $wgCirrusSearchMoreLikeThisConfig,
                  $wgCirrusSearchMoreLikeThisAllowedFields,
                  $wgCirrusSearchMoreLikeThisMaxQueryTermsLimit,
                  $wgCirrusSearchMoreLikeThisFields;
      Severity: Minor
      Found in includes/Hooks.php - About 2 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 overrideMoreLikeThisOptionsFromMessage has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static function overrideMoreLikeThisOptionsFromMessage() {
              global $wgCirrusSearchMoreLikeThisConfig,
                  $wgCirrusSearchMoreLikeThisAllowedFields,
                  $wgCirrusSearchMoreLikeThisMaxQueryTermsLimit,
                  $wgCirrusSearchMoreLikeThisFields;
      Severity: Major
      Found in includes/Hooks.php - About 2 hrs to fix

        Method handleSearchGetNearMatch has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function handleSearchGetNearMatch( $term, &$titleResult ) {
                global $wgSearchType;
                if ( $wgSearchType !== 'CirrusSearch' ) {
                    return true;
                }
        Severity: Minor
        Found in includes/Hooks.php - About 1 hr to fix

          Method initializeForRequest has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function initializeForRequest( WebRequest $request ) {
                  global $wgCirrusSearchPhraseRescoreWindowSize,
                      $wgCirrusSearchFunctionRescoreWindowSize,
                      $wgCirrusSearchFragmentSize,
                      $wgCirrusSearchPhraseRescoreBoost,
          Severity: Minor
          Found in includes/Hooks.php - About 1 hr to fix

            Method onShowSearchHitTitle has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function onShowSearchHitTitle( &$title, &$text, $result, $terms, $page, &$query, &$attributes ) {
            Severity: Major
            Found in includes/Hooks.php - About 50 mins to fix

              Method onBeforeInitialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public function onBeforeInitialize( $title, $unused, $outputPage, $user, $request, $mediaWiki ) {
              Severity: Minor
              Found in includes/Hooks.php - About 45 mins to fix

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

                    private static function overrideSecret( &$dest, $secret, WebRequest $request, $name, $value = true ) {
                Severity: Minor
                Found in includes/Hooks.php - About 35 mins to fix

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

                          &$dest,
                          WebRequest $request,
                          $name,
                          $limit = null,
                          $upperLimit = true
                  Severity: Minor
                  Found in includes/Hooks.php - About 35 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return true;
                    Severity: Major
                    Found in includes/Hooks.php - About 30 mins to fix

                      Function handleSearchGetNearMatch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public static function handleSearchGetNearMatch( $term, &$titleResult ) {
                              global $wgSearchType;
                              if ( $wgSearchType !== 'CirrusSearch' ) {
                                  return true;
                              }
                      Severity: Minor
                      Found in includes/Hooks.php - About 25 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 prefixSearchExtractNamespaceWithConnection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public static function prefixSearchExtractNamespaceWithConnection(
                              Connection $connection,
                              &$namespaces,
                              &$search
                          ) {
                      Severity: Minor
                      Found in includes/Hooks.php - About 25 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

                      There are no issues that match your filters.

                      Category
                      Status