gdbots/query-parser-php

View on GitHub

Showing 305 of 305 total issues

File test-queries.php has 1596 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
declare(strict_types=1);

use Gdbots\QueryParser\Enum\BoolOperator;
use Gdbots\QueryParser\Enum\ComparisonOperator;
Severity: Major
Found in tests/Fixtures/test-queries.php - About 4 days to fix

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

    <?php
    declare(strict_types=1);
    
    namespace Gdbots\QueryParser\Node;
    
    
    Severity: Major
    Found in src/Node/Url.php and 4 other locations - About 1 day to fix
    src/Node/Emoji.php on lines 1..57
    src/Node/Emoticon.php on lines 1..57
    src/Node/Hashtag.php on lines 1..57
    src/Node/Mention.php on lines 1..57

    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 226.

    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 5 locations. Consider refactoring.
    Open

    <?php
    declare(strict_types=1);
    
    namespace Gdbots\QueryParser\Node;
    
    
    Severity: Major
    Found in src/Node/Emoji.php and 4 other locations - About 1 day to fix
    src/Node/Emoticon.php on lines 1..57
    src/Node/Hashtag.php on lines 1..57
    src/Node/Mention.php on lines 1..57
    src/Node/Url.php on lines 1..57

    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 226.

    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 5 locations. Consider refactoring.
    Open

    <?php
    declare(strict_types=1);
    
    namespace Gdbots\QueryParser\Node;
    
    
    Severity: Major
    Found in src/Node/Hashtag.php and 4 other locations - About 1 day to fix
    src/Node/Emoji.php on lines 1..57
    src/Node/Emoticon.php on lines 1..57
    src/Node/Mention.php on lines 1..57
    src/Node/Url.php on lines 1..57

    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 226.

    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 5 locations. Consider refactoring.
    Open

    <?php
    declare(strict_types=1);
    
    namespace Gdbots\QueryParser\Node;
    
    
    Severity: Major
    Found in src/Node/Emoticon.php and 4 other locations - About 1 day to fix
    src/Node/Emoji.php on lines 1..57
    src/Node/Hashtag.php on lines 1..57
    src/Node/Mention.php on lines 1..57
    src/Node/Url.php on lines 1..57

    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 226.

    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 5 locations. Consider refactoring.
    Open

    <?php
    declare(strict_types=1);
    
    namespace Gdbots\QueryParser\Node;
    
    
    Severity: Major
    Found in src/Node/Mention.php and 4 other locations - About 1 day to fix
    src/Node/Emoji.php on lines 1..57
    src/Node/Emoticon.php on lines 1..57
    src/Node/Hashtag.php on lines 1..57
    src/Node/Url.php on lines 1..57

    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 226.

    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

        [
            'name'            => 'required mentions',
            'input'           => '+@user +@user_name +@user.name +@user-name',
            'expected_tokens' => [
                T::T_REQUIRED,
    Severity: Major
    Found in tests/Fixtures/test-queries.php and 1 other location - About 6 hrs to fix
    tests/Fixtures/test-queries.php on lines 547..566

    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 170.

    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

        [
            'name'            => 'prohibited mentions',
            'input'           => '-@user -@user_name -@user.name -@user-name',
            'expected_tokens' => [
                T::T_PROHIBITED,
    Severity: Major
    Found in tests/Fixtures/test-queries.php and 1 other location - About 6 hrs to fix
    tests/Fixtures/test-queries.php on lines 526..545

    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 170.

    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

    AbstractQueryBuilder has 42 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class AbstractQueryBuilder implements QueryBuilder
    {
        /** @var Field */
        private $currentField;
    
    
    Severity: Minor
    Found in src/Builder/AbstractQueryBuilder.php - About 5 hrs to fix

      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

        File AbstractQueryBuilder.php has 370 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

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

          File QueryParser.php has 370 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

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

            File ElasticaQueryBuilder.php has 356 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

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

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

                      'expected_tokens' => [
                          [T::T_FIELD_START, 'field'],
                          T::T_RANGE_EXCL_START,
                          [T::T_NUMBER, 1.1],
                          T::T_TO,
              Severity: Major
              Found in tests/Fixtures/test-queries.php and 1 other location - About 4 hrs to fix
              tests/Fixtures/test-queries.php on lines 863..879

              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 138.

              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

                      'expected_tokens' => [
                          [T::T_FIELD_START, 'field'],
                          T::T_RANGE_INCL_START,
                          [T::T_NUMBER, 1.0],
                          T::T_TO,
              Severity: Major
              Found in tests/Fixtures/test-queries.php and 1 other location - About 4 hrs to fix
              tests/Fixtures/test-queries.php on lines 907..923

              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 138.

              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

              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

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

                          switch ($this->stream->getCurrent()->getType()) {
                              case Token::T_NUMBER:
                                  $lowerNode = $this->createNumber($this->stream->getCurrent()->getValue());
                                  break;
                  
                  
                  Severity: Major
                  Found in src/QueryParser.php and 1 other location - About 3 hrs to fix
                  src/QueryParser.php on lines 224..241

                  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 126.

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language