gdbots/query-parser-php

View on GitHub
src/Tokenizer.php

Summary

Maintainability
F
5 days
Test Coverage

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

    private function extractSymbolOrKeyword(string $value): bool
    {
        $len = strlen($value);
        if ($len > 3) {
            return false;
Severity: Major
Found in src/Tokenizer.php - About 5 hrs to fix

    Function extractSymbolOrKeyword has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

        private function extractSymbolOrKeyword(string $value): bool
        {
            $len = strlen($value);
            if ($len > 3) {
                return false;
    Severity: Minor
    Found in src/Tokenizer.php - About 5 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 extractTokens has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        private function extractTokens(string $value): void
        {
            if ('' === $value) {
                if ($this->lastToken->typeEqualsAnyOf([Token::T_REQUIRED, Token::T_PROHIBITED, Token::T_IGNORED])) {
                    // todo: review the process of bool operators following ignored values.
    Severity: Minor
    Found in src/Tokenizer.php - About 5 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 extractTokens has 101 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function extractTokens(string $value): void
        {
            if ('' === $value) {
                if ($this->lastToken->typeEqualsAnyOf([Token::T_REQUIRED, Token::T_PROHIBITED, Token::T_IGNORED])) {
                    // todo: review the process of bool operators following ignored values.
    Severity: Major
    Found in src/Tokenizer.php - About 4 hrs to fix

      File Tokenizer.php has 326 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      declare(strict_types=1);
      
      namespace Gdbots\QueryParser;
      
      
      Severity: Minor
      Found in src/Tokenizer.php - About 3 hrs to fix

        The class Tokenizer has an overall complexity of 94 which is very high. The configured complexity threshold is 50.
        Open

        class Tokenizer
        {
            const REGEX_EMOTICON = '(?<=^|\s)(?:>:\-?\(|:\-?\)|<3|:\'\(|:\-?\|:\-?\/|:\-?\(|:\-?\*|:\-?\||:o\)|:\-?o|=\-?\)|:\-?D|:\-?p|:\-?P|:\-?b|;\-?p|;\-?P|;\-?b|;\-?\))';
            const REGEX_EMOJI = '[\x{2712}\x{2714}\x{2716}\x{271d}\x{2721}\x{2728}\x{2733}\x{2734}\x{2744}\x{2747}\x{274c}\x{274e}\x{2753}-\x{2755}\x{2757}\x{2763}\x{2764}\x{2795}-\x{2797}\x{27a1}\x{27b0}\x{27bf}\x{2934}\x{2935}\x{2b05}-\x{2b07}\x{2b1b}\x{2b1c}\x{2b50}\x{2b55}\x{3030}\x{303d}\x{1f004}\x{1f0cf}\x{1f170}\x{1f171}\x{1f17e}\x{1f17f}\x{1f18e}\x{1f191}-\x{1f19a}\x{1f201}\x{1f202}\x{1f21a}\x{1f22f}\x{1f232}-\x{1f23a}\x{1f250}\x{1f251}\x{1f300}-\x{1f321}\x{1f324}-\x{1f393}\x{1f396}\x{1f397}\x{1f399}-\x{1f39b}\x{1f39e}-\x{1f3f0}\x{1f3f3}-\x{1f3f5}\x{1f3f7}-\x{1f4fd}\x{1f4ff}-\x{1f53d}\x{1f549}-\x{1f54e}\x{1f550}-\x{1f567}\x{1f56f}\x{1f570}\x{1f573}-\x{1f579}\x{1f587}\x{1f58a}-\x{1f58d}\x{1f590}\x{1f595}\x{1f596}\x{1f5a5}\x{1f5a8}\x{1f5b1}\x{1f5b2}\x{1f5bc}\x{1f5c2}-\x{1f5c4}\x{1f5d1}-\x{1f5d3}\x{1f5dc}-\x{1f5de}\x{1f5e1}\x{1f5e3}\x{1f5ef}\x{1f5f3}\x{1f5fa}-\x{1f64f}\x{1f680}-\x{1f6c5}\x{1f6cb}-\x{1f6d0}\x{1f6e0}-\x{1f6e5}\x{1f6e9}\x{1f6eb}\x{1f6ec}\x{1f6f0}\x{1f6f3}\x{1f910}-\x{1f918}\x{1f980}-\x{1f984}\x{1f9c0}\x{3297}\x{3299}\x{a9}\x{ae}\x{203c}\x{2049}\x{2122}\x{2139}\x{2194}-\x{2199}\x{21a9}\x{21aa}\x{231a}\x{231b}\x{2328}\x{2388}\x{23cf}\x{23e9}-\x{23f3}\x{23f8}-\x{23fa}\x{24c2}\x{25aa}\x{25ab}\x{25b6}\x{25c0}\x{25fb}-\x{25fe}\x{2600}-\x{2604}\x{260e}\x{2611}\x{2614}\x{2615}\x{2618}\x{261d}\x{2620}\x{2622}\x{2623}\x{2626}\x{262a}\x{262e}\x{262f}\x{2638}-\x{263a}\x{2648}-\x{2653}\x{2660}\x{2663}\x{2665}\x{2666}\x{2668}\x{267b}\x{267f}\x{2692}-\x{2694}\x{2696}\x{2697}\x{2699}\x{269b}\x{269c}\x{26a0}\x{26a1}\x{26aa}\x{26ab}\x{26b0}\x{26b1}\x{26bd}\x{26be}\x{26c4}\x{26c5}\x{26c8}\x{26ce}\x{26cf}\x{26d1}\x{26d3}\x{26d4}\x{26e9}\x{26ea}\x{26f0}-\x{26f5}\x{26f7}-\x{26fa}\x{26fd}\x{2702}\x{2705}\x{2708}-\x{270d}\x{270f}]|\x{23}\x{20e3}|\x{2a}\x{20e3}|\x{30}\x{20e3}|\x{31}\x{20e3}|\x{32}\x{20e3}|\x{33}\x{20e3}|\x{34}\x{20e3}|\x{35}\x{20e3}|\x{36}\x{20e3}|\x{37}\x{20e3}|\x{38}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1fb}\x{1f1fe}]|\x{1f1f2}[\x{1f1e6}\x{1f1e8}-\x{1f1ed}\x{1f1f0}-\x{1f1ff}]|\x{1f1f3}[\x{1f1e6}\x{1f1e8}\x{1f1ea}-\x{1f1ec}\x{1f1ee}\x{1f1f1}\x{1f1f4}\x{1f1f5}\x{1f1f7}\x{1f1fa}\x{1f1ff}]|\x{1f1f4}\x{1f1f2}|\x{1f1f5}[\x{1f1e6}\x{1f1ea}-\x{1f1ed}\x{1f1f0}-\x{1f1f3}\x{1f1f7}-\x{1f1f9}\x{1f1fc}\x{1f1fe}]|\x{1f1f6}\x{1f1e6}|\x{1f1f7}[\x{1f1ea}\x{1f1f4}\x{1f1f8}\x{1f1fa}\x{1f1fc}]|\x{1f1f8}[\x{1f1e6}-\x{1f1ea}\x{1f1ec}-\x{1f1f4}\x{1f1f7}-\x{1f1f9}\x{1f1fb}\x{1f1fd}-\x{1f1ff}]|\x{1f1f9}[\x{1f1e6}\x{1f1e8}\x{1f1e9}\x{1f1eb}-\x{1f1ed}\x{1f1ef}-\x{1f1f4}\x{1f1f7}\x{1f1f9}\x{1f1fb}\x{1f1fc}\x{1f1ff}]|\x{1f1fa}[\x{1f1e6}\x{1f1ec}\x{1f1f2}\x{1f1f8}\x{1f1fe}\x{1f1ff}]|\x{1f1fb}[\x{1f1e6}\x{1f1e8}\x{1f1ea}\x{1f1ec}\x{1f1ee}\x{1f1f3}\x{1f1fa}]|\x{1f1fc}[\x{1f1eb}\x{1f1f8}]|\x{1f1fd}\x{1f1f0}|\x{1f1fe}[\x{1f1ea}\x{1f1f9}]|\x{1f1ff}[\x{1f1e6}\x{1f1f2}\x{1f1fc}]';
            const REGEX_URL = '[+-]?[\w-]+:\/\/[^\s\/$.?#].[^\s\^~]*';
        Severity: Minor
        Found in src/Tokenizer.php by phpmd

        Since: PHPMD 0.2.5

        The Weighted Method Count (WMC) of a class is a good indicator of how much time and effort is required to modify and maintain this class. The WMC metric is defined as the sum of complexities of all methods declared in a class. A large number of methods also means that this class has a greater potential impact on derived classes.

        Example:

        class Foo {
              public function bar() {
                  if ($a == $b)  {
                      if ($a1 == $b1) {
                          fiddle();
                      } elseif ($a2 == $b2) {
                          fiddle();
                      } else {
                      }
                  }
              }
              public function baz() {
                  if ($a == $b) {
                      if ($a1 == $b1) {
                          fiddle();
                      } elseif ($a2 == $b2) {
                          fiddle();
                      } else {
                      }
                  }
              }
              // Several other complex methods
          }

        Source: http://phpmd.org/rules/codesize.txt

        Method scan has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function scan(string $input): TokenStream
            {
                $input = str_replace('""', '" "', preg_replace('/\s+/', ' ', ' ' . $input));
                $this->input = substr($input, 0, 256);
                $this->inField = false;
        Severity: Minor
        Found in src/Tokenizer.php - About 1 hr to fix

          Avoid too many return statements within this method.
          Open

                      return;
          Severity: Major
          Found in src/Tokenizer.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return;
            Severity: Major
            Found in src/Tokenizer.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return true;
              Severity: Major
              Found in src/Tokenizer.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return true;
                Severity: Major
                Found in src/Tokenizer.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return true;
                  Severity: Major
                  Found in src/Tokenizer.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return false;
                    Severity: Major
                    Found in src/Tokenizer.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return true;
                      Severity: Major
                      Found in src/Tokenizer.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return;
                        Severity: Major
                        Found in src/Tokenizer.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                              return true;
                          Severity: Major
                          Found in src/Tokenizer.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return;
                            Severity: Major
                            Found in src/Tokenizer.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                          return;
                              Severity: Major
                              Found in src/Tokenizer.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                    return;
                                Severity: Major
                                Found in src/Tokenizer.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                  return true;
                                  Severity: Major
                                  Found in src/Tokenizer.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                return;
                                    Severity: Major
                                    Found in src/Tokenizer.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                      return true;
                                      Severity: Major
                                      Found in src/Tokenizer.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                        return true;
                                        Severity: Major
                                        Found in src/Tokenizer.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                          return true;
                                          Severity: Major
                                          Found in src/Tokenizer.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                                    return true;
                                            Severity: Major
                                            Found in src/Tokenizer.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                              return true;
                                              Severity: Major
                                              Found in src/Tokenizer.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                            return;
                                                Severity: Major
                                                Found in src/Tokenizer.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                              return;
                                                  Severity: Major
                                                  Found in src/Tokenizer.php - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

                                                                return;
                                                    Severity: Major
                                                    Found in src/Tokenizer.php - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                                      return true;
                                                      Severity: Major
                                                      Found in src/Tokenizer.php - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                            return true;
                                                        Severity: Major
                                                        Found in src/Tokenizer.php - About 30 mins to fix

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                          return true;
                                                          Severity: Major
                                                          Found in src/Tokenizer.php - About 30 mins to fix

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                            return true;
                                                            Severity: Major
                                                            Found in src/Tokenizer.php - About 30 mins to fix

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                                  return true;
                                                              Severity: Major
                                                              Found in src/Tokenizer.php - About 30 mins to fix

                                                                Avoid too many return statements within this method.
                                                                Open

                                                                                return true;
                                                                Severity: Major
                                                                Found in src/Tokenizer.php - About 30 mins to fix

                                                                  Avoid too many return statements within this method.
                                                                  Open

                                                                                      return true;
                                                                  Severity: Major
                                                                  Found in src/Tokenizer.php - About 30 mins to fix

                                                                    Avoid too many return statements within this method.
                                                                    Open

                                                                                    return true;
                                                                    Severity: Major
                                                                    Found in src/Tokenizer.php - About 30 mins to fix

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

                                                                          public function scan(string $input): TokenStream
                                                                          {
                                                                              $input = str_replace('""', '" "', preg_replace('/\s+/', ' ', ' ' . $input));
                                                                              $this->input = substr($input, 0, 256);
                                                                              $this->inField = false;
                                                                      Severity: Minor
                                                                      Found in src/Tokenizer.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

                                                                      The method extractTokens() has an NPath complexity of 1451520. The configured NPath complexity threshold is 200.
                                                                      Open

                                                                          private function extractTokens(string $value): void
                                                                          {
                                                                              if ('' === $value) {
                                                                                  if ($this->lastToken->typeEqualsAnyOf([Token::T_REQUIRED, Token::T_PROHIBITED, Token::T_IGNORED])) {
                                                                                      // todo: review the process of bool operators following ignored values.
                                                                      Severity: Minor
                                                                      Found in src/Tokenizer.php by phpmd

                                                                      Since: PHPMD 0.1

                                                                      The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                      Example:

                                                                      class Foo {
                                                                            function bar() {
                                                                                // lots of complicated code
                                                                            }
                                                                        }

                                                                      Source: http://phpmd.org/rules/codesize.txt

                                                                      The method extractTokens() has 130 lines of code. Current threshold is set to 100. Avoid really long methods.
                                                                      Open

                                                                          private function extractTokens(string $value): void
                                                                          {
                                                                              if ('' === $value) {
                                                                                  if ($this->lastToken->typeEqualsAnyOf([Token::T_REQUIRED, Token::T_PROHIBITED, Token::T_IGNORED])) {
                                                                                      // todo: review the process of bool operators following ignored values.
                                                                      Severity: Minor
                                                                      Found in src/Tokenizer.php by phpmd

                                                                      The method extractSymbolOrKeyword() has 172 lines of code. Current threshold is set to 100. Avoid really long methods.
                                                                      Open

                                                                          private function extractSymbolOrKeyword(string $value): bool
                                                                          {
                                                                              $len = strlen($value);
                                                                              if ($len > 3) {
                                                                                  return false;
                                                                      Severity: Minor
                                                                      Found in src/Tokenizer.php by phpmd

                                                                      The method extractTokens() has a Cyclomatic Complexity of 27. The configured cyclomatic complexity threshold is 10.
                                                                      Open

                                                                          private function extractTokens(string $value): void
                                                                          {
                                                                              if ('' === $value) {
                                                                                  if ($this->lastToken->typeEqualsAnyOf([Token::T_REQUIRED, Token::T_PROHIBITED, Token::T_IGNORED])) {
                                                                                      // todo: review the process of bool operators following ignored values.
                                                                      Severity: Minor
                                                                      Found in src/Tokenizer.php by phpmd

                                                                      Since: PHPMD 0.1

                                                                      Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                      Example:

                                                                      // Cyclomatic Complexity = 11
                                                                        class Foo {
                                                                        1   public function example() {
                                                                        2       if ($a == $b) {
                                                                        3           if ($a1 == $b1) {
                                                                                        fiddle();
                                                                        4           } elseif ($a2 == $b2) {
                                                                                        fiddle();
                                                                                    } else {
                                                                                        fiddle();
                                                                                    }
                                                                        5       } elseif ($c == $d) {
                                                                        6           while ($c == $d) {
                                                                                        fiddle();
                                                                                    }
                                                                        7        } elseif ($e == $f) {
                                                                        8           for ($n = 0; $n < $h; $n++) {
                                                                                        fiddle();
                                                                                    }
                                                                                } else {
                                                                                    switch ($z) {
                                                                        9               case 1:
                                                                                            fiddle();
                                                                                            break;
                                                                        10              case 2:
                                                                                            fiddle();
                                                                                            break;
                                                                        11              case 3:
                                                                                            fiddle();
                                                                                            break;
                                                                                        default:
                                                                                            fiddle();
                                                                                            break;
                                                                                    }
                                                                                }
                                                                            }
                                                                        }

                                                                      Source: http://phpmd.org/rules/codesize.txt

                                                                      The method extractSymbolOrKeyword() has a Cyclomatic Complexity of 53. The configured cyclomatic complexity threshold is 10.
                                                                      Open

                                                                          private function extractSymbolOrKeyword(string $value): bool
                                                                          {
                                                                              $len = strlen($value);
                                                                              if ($len > 3) {
                                                                                  return false;
                                                                      Severity: Minor
                                                                      Found in src/Tokenizer.php by phpmd

                                                                      Since: PHPMD 0.1

                                                                      Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                      Example:

                                                                      // Cyclomatic Complexity = 11
                                                                        class Foo {
                                                                        1   public function example() {
                                                                        2       if ($a == $b) {
                                                                        3           if ($a1 == $b1) {
                                                                                        fiddle();
                                                                        4           } elseif ($a2 == $b2) {
                                                                                        fiddle();
                                                                                    } else {
                                                                                        fiddle();
                                                                                    }
                                                                        5       } elseif ($c == $d) {
                                                                        6           while ($c == $d) {
                                                                                        fiddle();
                                                                                    }
                                                                        7        } elseif ($e == $f) {
                                                                        8           for ($n = 0; $n < $h; $n++) {
                                                                                        fiddle();
                                                                                    }
                                                                                } else {
                                                                                    switch ($z) {
                                                                        9               case 1:
                                                                                            fiddle();
                                                                                            break;
                                                                        10              case 2:
                                                                                            fiddle();
                                                                                            break;
                                                                        11              case 3:
                                                                                            fiddle();
                                                                                            break;
                                                                                        default:
                                                                                            fiddle();
                                                                                            break;
                                                                                    }
                                                                                }
                                                                            }
                                                                        }

                                                                      Source: http://phpmd.org/rules/codesize.txt

                                                                      The method extractSymbolOrKeyword uses an else expression. Else is never necessary and you can simplify the code to work without else.
                                                                      Open

                                                                                          } else {
                                                                                              $this->addOperatorToken(Token::T_RANGE_EXCL_END);
                                                                                          }
                                                                      Severity: Minor
                                                                      Found in src/Tokenizer.php by phpmd

                                                                      Since: PHPMD 1.4.0

                                                                      An if expression with an else branch is never necessary. You can rewrite the conditions in a way that the else is not necessary and the code becomes simpler to read. To achieve this use early return statements. To achieve this you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                                                                      Example:

                                                                      class Foo
                                                                        {
                                                                            public function bar($flag)
                                                                            {
                                                                                if ($flag) {
                                                                                    // one branch
                                                                                } else {
                                                                                    // another branch
                                                                                }
                                                                            }
                                                                        }

                                                                      Source: http://phpmd.org/rules/cleancode.txt

                                                                      The method extractTokens uses an else expression. Else is never necessary and you can simplify the code to work without else.
                                                                      Open

                                                                                  } else {
                                                                                      $this->addToken(Token::T_IGNORED, $value);
                                                                                  }
                                                                      Severity: Minor
                                                                      Found in src/Tokenizer.php by phpmd

                                                                      Since: PHPMD 1.4.0

                                                                      An if expression with an else branch is never necessary. You can rewrite the conditions in a way that the else is not necessary and the code becomes simpler to read. To achieve this use early return statements. To achieve this you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                                                                      Example:

                                                                      class Foo
                                                                        {
                                                                            public function bar($flag)
                                                                            {
                                                                                if ($flag) {
                                                                                    // one branch
                                                                                } else {
                                                                                    // another branch
                                                                                }
                                                                            }
                                                                        }

                                                                      Source: http://phpmd.org/rules/cleancode.txt

                                                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                                                      Open

                                                                                  case '~':
                                                                                      // can't fuzzy parts of a field, range or sub query
                                                                                      if ($this->inSubquery || 0 !== $this->inRange) {
                                                                                          // fuzzy is ignored
                                                                                          return true;
                                                                      Severity: Minor
                                                                      Found in src/Tokenizer.php and 1 other location - About 55 mins to fix
                                                                      src/Tokenizer.php on lines 367..381

                                                                      Duplicated Code

                                                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                      Tuning

                                                                      This issue has a mass of 82.

                                                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                      Refactorings

                                                                      Further Reading

                                                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                                                      Open

                                                                                  case '^':
                                                                                      // can't boost parts of a field, range or sub query
                                                                                      if ($this->inSubquery || 0 !== $this->inRange) {
                                                                                          // boost is ignored
                                                                                          return true;
                                                                      Severity: Minor
                                                                      Found in src/Tokenizer.php and 1 other location - About 55 mins to fix
                                                                      src/Tokenizer.php on lines 351..365

                                                                      Duplicated Code

                                                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                      Tuning

                                                                      This issue has a mass of 82.

                                                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                      Refactorings

                                                                      Further Reading

                                                                      Line exceeds 120 characters; contains 3787 characters
                                                                      Open

                                                                          const REGEX_EMOJI = '[\x{2712}\x{2714}\x{2716}\x{271d}\x{2721}\x{2728}\x{2733}\x{2734}\x{2744}\x{2747}\x{274c}\x{274e}\x{2753}-\x{2755}\x{2757}\x{2763}\x{2764}\x{2795}-\x{2797}\x{27a1}\x{27b0}\x{27bf}\x{2934}\x{2935}\x{2b05}-\x{2b07}\x{2b1b}\x{2b1c}\x{2b50}\x{2b55}\x{3030}\x{303d}\x{1f004}\x{1f0cf}\x{1f170}\x{1f171}\x{1f17e}\x{1f17f}\x{1f18e}\x{1f191}-\x{1f19a}\x{1f201}\x{1f202}\x{1f21a}\x{1f22f}\x{1f232}-\x{1f23a}\x{1f250}\x{1f251}\x{1f300}-\x{1f321}\x{1f324}-\x{1f393}\x{1f396}\x{1f397}\x{1f399}-\x{1f39b}\x{1f39e}-\x{1f3f0}\x{1f3f3}-\x{1f3f5}\x{1f3f7}-\x{1f4fd}\x{1f4ff}-\x{1f53d}\x{1f549}-\x{1f54e}\x{1f550}-\x{1f567}\x{1f56f}\x{1f570}\x{1f573}-\x{1f579}\x{1f587}\x{1f58a}-\x{1f58d}\x{1f590}\x{1f595}\x{1f596}\x{1f5a5}\x{1f5a8}\x{1f5b1}\x{1f5b2}\x{1f5bc}\x{1f5c2}-\x{1f5c4}\x{1f5d1}-\x{1f5d3}\x{1f5dc}-\x{1f5de}\x{1f5e1}\x{1f5e3}\x{1f5ef}\x{1f5f3}\x{1f5fa}-\x{1f64f}\x{1f680}-\x{1f6c5}\x{1f6cb}-\x{1f6d0}\x{1f6e0}-\x{1f6e5}\x{1f6e9}\x{1f6eb}\x{1f6ec}\x{1f6f0}\x{1f6f3}\x{1f910}-\x{1f918}\x{1f980}-\x{1f984}\x{1f9c0}\x{3297}\x{3299}\x{a9}\x{ae}\x{203c}\x{2049}\x{2122}\x{2139}\x{2194}-\x{2199}\x{21a9}\x{21aa}\x{231a}\x{231b}\x{2328}\x{2388}\x{23cf}\x{23e9}-\x{23f3}\x{23f8}-\x{23fa}\x{24c2}\x{25aa}\x{25ab}\x{25b6}\x{25c0}\x{25fb}-\x{25fe}\x{2600}-\x{2604}\x{260e}\x{2611}\x{2614}\x{2615}\x{2618}\x{261d}\x{2620}\x{2622}\x{2623}\x{2626}\x{262a}\x{262e}\x{262f}\x{2638}-\x{263a}\x{2648}-\x{2653}\x{2660}\x{2663}\x{2665}\x{2666}\x{2668}\x{267b}\x{267f}\x{2692}-\x{2694}\x{2696}\x{2697}\x{2699}\x{269b}\x{269c}\x{26a0}\x{26a1}\x{26aa}\x{26ab}\x{26b0}\x{26b1}\x{26bd}\x{26be}\x{26c4}\x{26c5}\x{26c8}\x{26ce}\x{26cf}\x{26d1}\x{26d3}\x{26d4}\x{26e9}\x{26ea}\x{26f0}-\x{26f5}\x{26f7}-\x{26fa}\x{26fd}\x{2702}\x{2705}\x{2708}-\x{270d}\x{270f}]|\x{23}\x{20e3}|\x{2a}\x{20e3}|\x{30}\x{20e3}|\x{31}\x{20e3}|\x{32}\x{20e3}|\x{33}\x{20e3}|\x{34}\x{20e3}|\x{35}\x{20e3}|\x{36}\x{20e3}|\x{37}\x{20e3}|\x{38}\x{20e3}|\x{39}\x{20e3}|\x{1f1e6}[\x{1f1e8}-\x{1f1ec}\x{1f1ee}\x{1f1f1}\x{1f1f2}\x{1f1f4}\x{1f1f6}-\x{1f1fa}\x{1f1fc}\x{1f1fd}\x{1f1ff}]|\x{1f1e7}[\x{1f1e6}\x{1f1e7}\x{1f1e9}-\x{1f1ef}\x{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]|\x{1f1f4}\x{1f1f2}|\x{1f1f5}[\x{1f1e6}\x{1f1ea}-\x{1f1ed}\x{1f1f0}-\x{1f1f3}\x{1f1f7}-\x{1f1f9}\x{1f1fc}\x{1f1fe}]|\x{1f1f6}\x{1f1e6}|\x{1f1f7}[\x{1f1ea}\x{1f1f4}\x{1f1f8}\x{1f1fa}\x{1f1fc}]|\x{1f1f8}[\x{1f1e6}-\x{1f1ea}\x{1f1ec}-\x{1f1f4}\x{1f1f7}-\x{1f1f9}\x{1f1fb}\x{1f1fd}-\x{1f1ff}]|\x{1f1f9}[\x{1f1e6}\x{1f1e8}\x{1f1e9}\x{1f1eb}-\x{1f1ed}\x{1f1ef}-\x{1f1f4}\x{1f1f7}\x{1f1f9}\x{1f1fb}\x{1f1fc}\x{1f1ff}]|\x{1f1fa}[\x{1f1e6}\x{1f1ec}\x{1f1f2}\x{1f1f8}\x{1f1fe}\x{1f1ff}]|\x{1f1fb}[\x{1f1e6}\x{1f1e8}\x{1f1ea}\x{1f1ec}\x{1f1ee}\x{1f1f3}\x{1f1fa}]|\x{1f1fc}[\x{1f1eb}\x{1f1f8}]|\x{1f1fd}\x{1f1f0}|\x{1f1fe}[\x{1f1ea}\x{1f1f9}]|\x{1f1ff}[\x{1f1e6}\x{1f1f2}\x{1f1fc}]';
                                                                      Severity: Minor
                                                                      Found in src/Tokenizer.php by phpcodesniffer

                                                                      Line exceeds 120 characters; contains 167 characters
                                                                      Open

                                                                          const REGEX_EMOTICON = '(?<=^|\s)(?:>:\-?\(|:\-?\)|<3|:\'\(|:\-?\|:\-?\/|:\-?\(|:\-?\*|:\-?\||:o\)|:\-?o|=\-?\)|:\-?D|:\-?p|:\-?P|:\-?b|;\-?p|;\-?P|;\-?b|;\-?\))';
                                                                      Severity: Minor
                                                                      Found in src/Tokenizer.php by phpcodesniffer

                                                                      There are no issues that match your filters.

                                                                      Category
                                                                      Status