wikimedia/mediawiki-core

View on GitHub
includes/api/ApiQuerySearch.php

Summary

Maintainability
F
3 days
Test Coverage

Function run has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

    private function run( $resultPageSet = null ) {
        $params = $this->extractRequestParams();

        // Extract parameters
        $query = $params['search'];
Severity: Minor
Found in includes/api/ApiQuerySearch.php - About 7 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 run has 126 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function run( $resultPageSet = null ) {
        $params = $this->extractRequestParams();

        // Extract parameters
        $query = $params['search'];
Severity: Major
Found in includes/api/ApiQuerySearch.php - About 5 hrs to fix

    File ApiQuerySearch.php has 340 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Copyright © 2007 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
     *
     * This program is free software; you can redistribute it and/or modify
    Severity: Minor
    Found in includes/api/ApiQuerySearch.php - About 4 hrs to fix

      Function getSearchResultData has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          private function getSearchResultData( SearchResult $result, $prop ) {
              // Silently skip broken and missing titles
              if ( $result->isBrokenTitle() || $result->isMissingRevision() ) {
                  return null;
              }
      Severity: Minor
      Found in includes/api/ApiQuerySearch.php - About 3 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 getAllowedParams has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getAllowedParams() {
              $allowedParams = $this->buildCommonApiParams() + [
                  'what' => [
                      ParamValidator::PARAM_TYPE => [
                          'title',
      Severity: Major
      Found in includes/api/ApiQuerySearch.php - About 2 hrs to fix

        Method getSearchResultData has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function getSearchResultData( SearchResult $result, $prop ) {
                // Silently skip broken and missing titles
                if ( $result->isBrokenTitle() || $result->isMissingRevision() ) {
                    return null;
                }
        Severity: Major
        Found in includes/api/ApiQuerySearch.php - About 2 hrs to fix

          Function addInterwikiResults has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              private function addInterwikiResults(
                  ISearchResultSet $matches, ApiResult $apiResult, $prop,
                  $section, $type
              ) {
                  $totalhits = null;
          Severity: Minor
          Found in includes/api/ApiQuerySearch.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 addInterwikiResults has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function addInterwikiResults(
                  ISearchResultSet $matches, ApiResult $apiResult, $prop,
                  $section, $type
              ) {
                  $totalhits = null;
          Severity: Minor
          Found in includes/api/ApiQuerySearch.php - About 1 hr to fix

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

                    ISearchResultSet $matches, ApiResult $apiResult, $prop,
                    $section, $type
            Severity: Minor
            Found in includes/api/ApiQuerySearch.php - About 35 mins to fix

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

                      ApiQuery $query,
                      $moduleName,
                      SearchEngineConfig $searchEngineConfig,
                      SearchEngineFactory $searchEngineFactory,
                      TitleMatcher $titleMatcher
              Severity: Minor
              Found in includes/api/ApiQuerySearch.php - About 35 mins to fix

                There are no issues that match your filters.

                Category
                Status