wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub
includes/Query/FullTextQueryStringQueryBuilder.php

Summary

Maintainability
D
1 day
Test Coverage

Method build has 133 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function build( SearchContext $searchContext, $term ) {
        $searchContext->addSyntaxUsed( 'full_text' );
        // Transform MediaWiki specific syntax to filters and extra
        // (pre-escaped) query string
        foreach ( $this->features as $feature ) {
Severity: Major
Found in includes/Query/FullTextQueryStringQueryBuilder.php - About 5 hrs to fix

    File FullTextQueryStringQueryBuilder.php has 344 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace CirrusSearch\Query;
    
    use CirrusSearch\Extra\Query\TokenCountRouter;
    Severity: Minor
    Found in includes/Query/FullTextQueryStringQueryBuilder.php - About 4 hrs to fix

      Function build has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          public function build( SearchContext $searchContext, $term ) {
              $searchContext->addSyntaxUsed( 'full_text' );
              // Transform MediaWiki specific syntax to filters and extra
              // (pre-escaped) query string
              foreach ( $this->features as $feature ) {
      Severity: Minor
      Found in includes/Query/FullTextQueryStringQueryBuilder.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

      Avoid too many return statements within this method.
      Open

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

        Avoid too many return statements within this method.
        Open

                        return [
                            'escaped' => self::switchSearchToExactForWildcards( $searchContext, $term ),
                            'nonAll' => self::switchSearchToExactForWildcards( $searchContext, $term )
                        ];
        Severity: Major
        Found in includes/Query/FullTextQueryStringQueryBuilder.php - About 30 mins to fix

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

              private static function replacePartsOfQuery( $queryPart, $regex, $callable ) {
                  $destination = [];
                  $matches = [];
                  $offset = 0;
                  while ( preg_match( $regex, $queryPart, $matches, PREG_OFFSET_CAPTURE, $offset ) ) {
          Severity: Minor
          Found in includes/Query/FullTextQueryStringQueryBuilder.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