chris-kruining/utilities

View on GitHub
src/Parser/Expression.php

Summary

Maintainability
D
2 days
Test Coverage

Function split has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

        private function split(string $query): Collection
        {
            $out = [];
            $pos = 0;
        
Severity: Minor
Found in src/Parser/Expression.php - About 4 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 Expression.php has 324 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace CPB\Utilities\Parser
{
    use CPB\Utilities\Collections\Collection;
Severity: Minor
Found in src/Parser/Expression.php - About 3 hrs to fix

    Method split has 86 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            private function split(string $query): Collection
            {
                $out = [];
                $pos = 0;
            
    Severity: Major
    Found in src/Parser/Expression.php - About 3 hrs to fix

      Method parseOperator has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              private function parseOperator($left, ?string $operator, $right)
              {
                  switch($operator)
                  {
                      // NOTE(Chris Kruining)
      Severity: Major
      Found in src/Parser/Expression.php - About 2 hrs to fix

        Method resolveKey has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                private function resolveKey($key)
                {
                    $trimmed = \trim($key);
                
                    if(\strlen($trimmed) === 0)
        Severity: Minor
        Found in src/Parser/Expression.php - About 1 hr to fix

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

                  private function parseParameters(string $parameters): Collection
                  {
                      $out = [];
                      $pos = 0;
                      $level = 0;
          Severity: Minor
          Found in src/Parser/Expression.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 parseParameters has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  private function parseParameters(string $parameters): Collection
                  {
                      $out = [];
                      $pos = 0;
                      $level = 0;
          Severity: Minor
          Found in src/Parser/Expression.php - About 1 hr to fix

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

                    private function parseOperator($left, ?string $operator, $right)
                    {
                        switch($operator)
                        {
                            // NOTE(Chris Kruining)
            Severity: Minor
            Found in src/Parser/Expression.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

            Avoid too many return statements within this method.
            Open

                                return $right;
            Severity: Major
            Found in src/Parser/Expression.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                                  return $this->resolvable->{substr($trimmed, 1)};
              Severity: Major
              Found in src/Parser/Expression.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                    return $key;
                Severity: Major
                Found in src/Parser/Expression.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                      return $this->variables[substr($trimmed, 2, -2)];
                  Severity: Major
                  Found in src/Parser/Expression.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                        return static::init(substr($trimmed, 1, -1))($this->resolvable, $this->variables);
                    Severity: Major
                    Found in src/Parser/Expression.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                          return $callable(...$parameters);
                      Severity: Major
                      Found in src/Parser/Expression.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

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

                          Avoid too many return statements within this method.
                          Open

                                              return $this->resolvable->$callable(...$parameters);
                          Severity: Major
                          Found in src/Parser/Expression.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                                return $this->resolvable->resolve(substr($trimmed, 1));
                            Severity: Major
                            Found in src/Parser/Expression.php - About 30 mins to fix

                              There are no issues that match your filters.

                              Category
                              Status