wikimedia/mediawiki-extensions-CirrusSearch

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

Summary

Maintainability
C
1 day
Test Coverage

Function getSupportedProfile has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    private function getSupportedProfile( $profileName ) {
        $profile = $this->context->getConfig()
            ->getProfileService()
            ->loadProfileByName( SearchProfileService::RESCORE, $profileName );
        if ( !is_array( $profile ) ) {
Severity: Minor
Found in includes/Search/Rescore/RescoreBuilder.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

Function isProfileSyntaxSupported has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private function isProfileSyntaxSupported( array $profile ) {
        if ( ( $profile['supported_syntax'] ?? [] ) !== [] ) {
            $supportedSyntax = false;
            foreach ( $profile['supported_syntax'] as $supported ) {
                if ( $this->context->isSyntaxUsed( $supported ) ) {
Severity: Minor
Found in includes/Search/Rescore/RescoreBuilder.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

Method getSupportedProfile has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function getSupportedProfile( $profileName ) {
        $profile = $this->context->getConfig()
            ->getProfileService()
            ->loadProfileByName( SearchProfileService::RESCORE, $profileName );
        if ( !is_array( $profile ) ) {
Severity: Minor
Found in includes/Search/Rescore/RescoreBuilder.php - About 1 hr to fix

    Function isProfileNamespaceSupported has a Cognitive Complexity of 13 (exceeds 5 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

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

      Function prepareQueryParams has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          private function prepareQueryParams( array $settings ) {
              $def = [];
              foreach ( self::$rescoreMainParams as $param ) {
                  if ( !isset( $settings[$param] ) ) {
                      continue;
      Severity: Minor
      Found in includes/Search/Rescore/RescoreBuilder.php - About 55 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 build has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function build() {
              $rescores = [];
              foreach ( $this->profile['rescore'] as $rescoreDef ) {
                  $windowSize = $this->windowSize( $rescoreDef );
                  if ( $windowSize <= 0 ) {
      Severity: Minor
      Found in includes/Search/Rescore/RescoreBuilder.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

      There are no issues that match your filters.

      Category
      Status