File QueryStringRegexParser.php
has 507 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace CirrusSearch\Parser\QueryStringRegex;
use CirrusSearch\Parser\AST\BooleanClause;
Function expression
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
private function expression() {
$clauses = [];
$left = null;
// Last boolean operator seen, -1 means none
$lastBoolType = -1;
- Read upRead up
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 expression
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function expression() {
$clauses = [];
$left = null;
// Last boolean operator seen, -1 means none
$lastBoolType = -1;
QueryStringRegexParser
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
class QueryStringRegexParser implements QueryParser {
/**
* Whitespace regex including unicode and some control chars
*/
private const WHITESPACE_REGEX = '/\G[\pZ\pC]+/u';
Method parse
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parse( string $query ): ParsedQuery {
$this->reInit( $query );
$queryLen = mb_strlen( $query );
if ( $queryLen > self::QUERY_LEN_HARD_LIMIT ) {
throw new SearchQueryParseException( 'cirrussearch-query-too-long',
Method nextToken
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function nextToken() {
Assert::precondition( $this->token->getStart() < $this->offset,
'You should not call nextToken() twice on the same offsets' );
$this->token->copyTo( $this->lookBehind );
$this->token->reset();
Function parse
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function parse( string $query ): ParsedQuery {
$this->reInit( $query );
$queryLen = mb_strlen( $query );
if ( $queryLen > self::QUERY_LEN_HARD_LIMIT ) {
throw new SearchQueryParseException( 'cirrussearch-query-too-long',
- Read upRead up
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 checkQueryLen
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function checkQueryLen(): void {
Assert::precondition( $this->query !== null, "Query must be set" );
$maxLen = $this->maxQueryLen;
$exemptKeywords = [];
foreach ( $this->preTaggedNodes as $node ) {
- Read upRead up
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 __construct
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
\CirrusSearch\Parser\KeywordRegistry $keywordRegistry,
Escaper $escaper,
$qmarkStripLevel,
ParsedQueryClassifiersRepository $classifierRepository,
NamespacePrefixParser $namespacePrefixParser,
Function nextToken
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function nextToken() {
Assert::precondition( $this->token->getStart() < $this->offset,
'You should not call nextToken() twice on the same offsets' );
$this->token->copyTo( $this->lookBehind );
$this->token->reset();
- Read upRead up
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 true;
Avoid too many return
statements within this method. Open
return true;
Function cleanup
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function cleanup() {
$query = $this->rawQuery;
$nquery = Util::stripQuestionMarks( $query, $this->questionMarkStripLevel );
if ( $nquery !== $query ) {
$this->queryCleanups[ParsedQuery::CLEANUP_QMARK_STRIPPING] = true;
- Read upRead up
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"