wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub
includes/Search/Rescore/FunctionScoreChain.php

Summary

Maintainability
C
1 day
Test Coverage

Method getImplementation has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function getImplementation( $func ) {
        $weight = $func['weight'] ?? 1;
        $config = $this->context->getConfig();
        switch ( $func['type'] ) {
            case 'boostlinks':
Severity: Major
Found in includes/Search/Rescore/FunctionScoreChain.php - About 2 hrs to fix

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

        private function getImplementation( $func ) {
            $weight = $func['weight'] ?? 1;
            $config = $this->context->getConfig();
            switch ( $func['type'] ) {
                case 'boostlinks':
    Severity: Minor
    Found in includes/Search/Rescore/FunctionScoreChain.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

    Avoid too many return statements within this method.
    Open

                    return new NamespacesFunctionScoreBuilder( $config, $this->context->getNamespaces(), $weight );
    Severity: Major
    Found in includes/Search/Rescore/FunctionScoreChain.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                      return $builder;
      Severity: Major
      Found in includes/Search/Rescore/FunctionScoreChain.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        return new ScriptScoreFunctionScoreBuilder( $config, $weight, $func['script'] );
        Severity: Major
        Found in includes/Search/Rescore/FunctionScoreChain.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return new LangWeightFunctionScoreBuilder( $config, $weight );
          Severity: Major
          Found in includes/Search/Rescore/FunctionScoreChain.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return new SatuFunctionScoreBuilder( $config, $weight, $func['params'] );
            Severity: Major
            Found in includes/Search/Rescore/FunctionScoreChain.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return new CustomFieldFunctionScoreBuilder( $config, $weight, $func['params'] );
              Severity: Major
              Found in includes/Search/Rescore/FunctionScoreChain.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return new GeoMeanFunctionScoreBuilder( $config, $weight, $func['params'] );
                Severity: Major
                Found in includes/Search/Rescore/FunctionScoreChain.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return new LogScaleBoostFunctionScoreBuilder( $config, $weight, $func['params'] );
                  Severity: Major
                  Found in includes/Search/Rescore/FunctionScoreChain.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return new LogMultFunctionScoreBuilder( $config, $weight, $func['params'] );
                    Severity: Major
                    Found in includes/Search/Rescore/FunctionScoreChain.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return new TermBoostScoreBuilder( $config, $weight, $func['params'] );
                      Severity: Major
                      Found in includes/Search/Rescore/FunctionScoreChain.php - About 30 mins to fix

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

                            public function buildRescoreQuery() {
                                if ( !isset( $this->chain['functions'] ) ) {
                                    throw new InvalidRescoreProfileException( "No functions defined in chain {$this->chainName}." );
                                }
                                foreach ( $this->chain['functions'] as $func ) {
                        Severity: Minor
                        Found in includes/Search/Rescore/FunctionScoreChain.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