nishimura/laiz-parsec

View on GitHub

Showing 20 of 31 total issues

Function _runParser has a Cognitive Complexity of 160 (exceeds 5 allowed). Consider refactoring.
Open

function _runParser(Parser $p, State $state)
{
    $call = []; // function: [goto label, context]
    $args = []; // function arguments
    $context = []; // function context: function foo() use(...$context)
Severity: Minor
Found in src/fast.php - About 3 days 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 _runParser has 357 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function _runParser(Parser $p, State $state)
{
    $call = []; // function: [goto label, context]
    $args = []; // function arguments
    $context = []; // function context: function foo() use(...$context)
Severity: Major
Found in src/fast.php - About 1 day to fix

    File fast.php has 376 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Laiz\Parsec;
    
    use Laiz\Func\Maybe;
    Severity: Minor
    Found in src/fast.php - About 5 hrs to fix

      Function showErrorMessages has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

      function showErrorMessages($msgOr, $msgUnknown, $msgExpecting, $msgUnExpected,
                                 $msgEndOfInput, $msgs){
          if (!$msgs)
              return $msgUnknown;
      
      
      Severity: Minor
      Found in src/Show/ParseError.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 functions.php has 323 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace Laiz\Parsec;
      
      use Laiz\Func;
      Severity: Minor
      Found in src/functions.php - About 3 hrs to fix

        File combinator.php has 286 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        namespace Laiz\Parsec;
        
        use Laiz\Func;
        Severity: Minor
        Found in src/combinator.php - About 2 hrs to fix

          Method showErrorMessages has 61 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function showErrorMessages($msgOr, $msgUnknown, $msgExpecting, $msgUnExpected,
                                     $msgEndOfInput, $msgs){
              if (!$msgs)
                  return $msgUnknown;
          
          
          Severity: Major
          Found in src/Show/ParseError.php - About 2 hrs to fix

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

            function mergeError(ParseError $e1, ParseError $e2)
            {
                $msgs1 = $e1->msgs();
                $msgs2 = $e2->msgs();
                if (!$msgs2 && $msgs1)
            Severity: Minor
            Found in src/functions.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 updatePosString has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            function updatePosString(...$args){
                $f = function(SourcePos $pos, $str){
                    $len = strlen($str);
                    $name = $pos->name();
                    $line = $pos->line();
            Severity: Minor
            Found in src/functions.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 showErrorMessages has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function showErrorMessages($msgOr, $msgUnknown, $msgExpecting, $msgUnExpected,
                                       $msgEndOfInput, $msgs){
            Severity: Minor
            Found in src/Show/ParseError.php - About 45 mins to fix

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

              function tokens(...$args){
                  $f = function($showTokens, $nextPoss, $tts){
                      if (is_string($tts))
                          $maybeTts = \Laiz\Parsec\Stream\TypeString::uncons($tts);
                      else if (is_array($tts))
              Severity: Minor
              Found in src/functions.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 updatePosChar has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              function updatePosChar(...$args){
                  $f = function(SourcePos $pos, $char){
                      if ($char === "\n"){
                          return new SourcePos($pos->name(),
                                               $pos->line() + 1,
              Severity: Minor
              Found in src/functions.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

              Avoid too many return statements within this method.
              Open

                          return $msg->msg();
              Severity: Major
              Found in src/Show/ParseError.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return $commasOr($ret);
                Severity: Major
                Found in src/Show/ParseError.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

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

                    Avoid too many return statements within this method.
                    Open

                        return "\n" . implode("\n", $clean($ret));
                    Severity: Major
                    Found in src/Show/ParseError.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

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

                        Avoid too many return statements within this method.
                        Open

                                return implode(', ', $ms) . " " . $msgOr . " " . $last;
                        Severity: Major
                        Found in src/Show/ParseError.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                  return $pre . " " . $commasOr($ret);
                          Severity: Major
                          Found in src/Show/ParseError.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                    return f($f, ...$args);
                            Severity: Major
                            Found in src/functions.php - About 30 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language