wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub
includes/RequestLogger.php

Summary

Maintainability
D
1 day
Test Coverage

Method buildCirrusSearchRequestEvent has 126 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function buildCirrusSearchRequestEvent() {
        global $wgRequest, $wgServerName;
        $webrequest = $wgRequest;

        // for the moment RequestLog::getRequests() is still created in the
Severity: Major
Found in includes/RequestLogger.php - About 5 hrs to fix

    Function buildCirrusSearchRequestEvent has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

        private function buildCirrusSearchRequestEvent() {
            global $wgRequest, $wgServerName;
            $webrequest = $wgRequest;
    
            // for the moment RequestLog::getRequests() is still created in the
    Severity: Minor
    Found in includes/RequestLogger.php - About 4 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

    File RequestLogger.php has 271 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace CirrusSearch;
    
    use ISearchResultSet;
    Severity: Minor
    Found in includes/RequestLogger.php - About 2 hrs to fix

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

          public function addRequest( RequestLog $log, UserIdentity $user = null, $slowMillis = null ) {
              global $wgCirrusSearchLogElasticRequests;
      
              // @todo Is this necessary here? Check on what uses the response value
              $finalContext = $log->getLogVariables() + [
      Severity: Minor
      Found in includes/RequestLogger.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 buildLogMessage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          private function buildLogMessage( RequestLog $log, array $context ) {
              $message = $log->getDescription();
              $message .= " against {index} took {tookMs} millis";
              if ( isset( $context['elasticTookMs'] ) ) {
                  $message .= " and {elasticTookMs} Elasticsearch millis";
      Severity: Minor
      Found in includes/RequestLogger.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

      Avoid too many return statements within this method.
      Open

              return $requestEvent;
      Severity: Major
      Found in includes/RequestLogger.php - About 30 mins to fix

        There are no issues that match your filters.

        Category
        Status