nishimura/laiz-parsec

View on GitHub

Showing 31 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

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

          function endBy1(...$args)
          {
              $f = function(Parser $p, Parser $sep){
                  $p2 = $p->bind(function($x) use ($sep){
                      return $sep->bind(function($_) use ($x){
          Severity: Major
          Found in src/combinator.php and 1 other location - About 2 hrs to fix
          src/combinator.php on lines 273..287

          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

          function endBy(...$args)
          {
              $f = function(Parser $p, Parser $sep){
                  $p2 = $p->bind(function($x) use ($sep){
                      return $sep->bind(function($_) use ($x){
          Severity: Major
          Found in src/combinator.php and 1 other location - About 2 hrs to fix
          src/combinator.php on lines 255..269

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

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

            namespace Laiz\Parsec\Show;
            use Laiz\Func\Loader;
            use function Laiz\Func\f;
            
            Loader::setMethod('show', 'Show', 'Laiz\Parsec');
            Severity: Major
            Found in src/functions.php and 1 other location - About 1 hr to fix
            src/functions.php on lines 434..449

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

            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

            function sepBy(...$args)
            {
                $f = function(Parser $p, Parser $sep){
                    return sepBy1($p, $sep)->aor(parserReturn([]));
                };
            Severity: Major
            Found in src/combinator.php and 1 other location - About 1 hr to fix
            src/combinator.php on lines 241..250

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

            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

            namespace Laiz\Parsec\Stream;
            use Laiz\Func\Loader;
            use function Laiz\Func\f;
            
            Loader::setMethod('uncons', 'Stream', 'Laiz\Parsec');
            Severity: Major
            Found in src/functions.php and 1 other location - About 1 hr to fix
            src/functions.php on lines 451..466

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

            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

            function sepEndBy(...$args)
            {
                $f = function(Parser $p, Parser $sep){
                    return sepEndBy1($p, $sep)->aor(parserReturn([]));
                };
            Severity: Major
            Found in src/combinator.php and 1 other location - About 1 hr to fix
            src/combinator.php on lines 207..216

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

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

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

              function parserPlus(...$args)
              {
                  $f = function($m, $n){
                      return new Parser(['_call_plus', [$m, $n]]);
                  };
              Severity: Minor
              Found in src/functions.php and 2 other locations - About 35 mins to fix
              src/functions.php on lines 138..147
              src/functions.php on lines 180..189

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

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

              function parserMap(...$args)
              {
                  $f = function($f, $p){
                      return new Parser(['_call_map', [$f, $p]]);
                  };
              Severity: Minor
              Found in src/functions.php and 2 other locations - About 35 mins to fix
              src/functions.php on lines 168..177
              src/functions.php on lines 180..189

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

              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

                  if (is_string($args[1]))
                      $rm = \Laiz\Parsec\Stream\TypeString::uncons($args[1]);
                  else if (is_array($args[1]))
                      $rm = \Laiz\Parsec\Stream\TypeArray::uncons($args[1]);
                  else
              Severity: Minor
              Found in src/fast.php and 1 other location - About 35 mins to fix
              src/fast.php on lines 262..267

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

              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