jpcercal/resource-query-language

View on GitHub

Showing 16 of 16 total issues

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

        foreach ($items as $item) {
            if (empty($item)) {
                continue;
            }

Severity: Major
Found in src/Parser/StringParser.php and 1 other location - About 2 hrs to fix
src/Parser/RequestParser.php on lines 88..107

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

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

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

        foreach ($items as $item) {
            if (empty($item)) {
                continue;
            }

Severity: Major
Found in src/Parser/RequestParser.php and 1 other location - About 2 hrs to fix
src/Parser/StringParser.php on lines 71..90

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

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

Function __construct has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct($field, $rawValue)
    {
        if (!is_string($field)) {
            throw new InvalidExprException('The value of "field" must be a string data type.');
        }
Severity: Minor
Found in src/Expr/InExpr.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

Method __construct has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function __construct($field, $rawValue)
    {
        if (!is_string($field)) {
            throw new InvalidExprException('The value of "field" must be a string data type.');
        }
Severity: Minor
Found in src/Expr/InExpr.php - About 1 hr to fix

    Function parse has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        public function parse()
        {
            $builder = new ExprBuilder();
    
            $items = $this->getData();
    Severity: Minor
    Found in src/Parser/ArrayParser.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 process has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function process(ExprBuilder $builder, $field, $expression, $value)
        {
            if (!Expr::isValidExpression($expression)) {
                throw new ParserException(sprintf(
                    'The expression "%s" is not allowed or not exists.',
    Severity: Minor
    Found in src/Parser/AbstractParser.php - About 1 hr to fix

      Function __construct has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public function __construct($expressions)
          {
              if (!is_string($expressions) && !is_array($expressions)) {
                  throw new InvalidExprException('The value of "expressions" must not be a string or an array data type.');
              }
      Severity: Minor
      Found in src/Expr/OrExpr.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 parse has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function parse()
          {
              $builder = new ExprBuilder();
      
              $queryString = $this->getData()->getUri()->getQuery();
      Severity: Minor
      Found in src/Parser/RequestParser.php - About 1 hr to fix

        Method __construct has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function __construct($expressions)
            {
                if (!is_string($expressions) && !is_array($expressions)) {
                    throw new InvalidExprException('The value of "expressions" must not be a string or an array data type.');
                }
        Severity: Minor
        Found in src/Expr/OrExpr.php - About 1 hr to fix

          Method __construct has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function __construct($currentPageNumber, $maxResultsPerPage)
              {
                  if (!is_int($currentPageNumber) && !is_numeric($currentPageNumber)) {
                      throw new InvalidExprException('The value of "currentPageNumber" must be an int data type.');
                  }
          Severity: Minor
          Found in src/Expr/PaginateExpr.php - About 1 hr to fix

            Method parse has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function parse()
                {
                    $builder = new ExprBuilder();
            
                    $items = $this->getData();
            Severity: Minor
            Found in src/Parser/ArrayParser.php - About 1 hr to fix

              Function parse has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function parse()
                  {
                      $builder = new ExprBuilder();
              
                      $queryString = $this->getData()->getUri()->getQuery();
              Severity: Minor
              Found in src/Parser/RequestParser.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

              Function __construct has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function __construct($currentPageNumber, $maxResultsPerPage)
                  {
                      if (!is_int($currentPageNumber) && !is_numeric($currentPageNumber)) {
                          throw new InvalidExprException('The value of "currentPageNumber" must be an int data type.');
                      }
              Severity: Minor
              Found in src/Expr/PaginateExpr.php - About 55 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

              Function parse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function parse()
                  {
                      $builder = new ExprBuilder();
              
                      $items = explode($this->getSeparator(), $this->getData());
              Severity: Minor
              Found in src/Parser/StringParser.php - About 45 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

              Function process has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function process(ExprQueue $queue)
                  {
                      foreach ($queue as $expr) {
                          if ($expr instanceof BetweenExpr) {
                              $this->processBetweenExpr($expr);
              Severity: Minor
              Found in src/Processor/DoctrineOrmProcessor.php - About 35 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

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

                  public function __construct($field, $from, $to)
                  {
                      if (!is_string($field)) {
                          throw new InvalidExprException('The value of "field" must be a string data type.');
                      }
              Severity: Minor
              Found in src/Expr/BetweenExpr.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

              Severity
              Category
              Status
              Source
              Language