kahlan/kahlan

View on GitHub
src/Jit/Patcher/Monkey.php

Summary

Maintainability
C
1 day
Test Coverage
A
100%

Function _monkeyPatch has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    protected function _monkeyPatch($node, $parent, $index)
    {
        if (!preg_match_all($this->_regex, $node->body, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
            return;
        }
Severity: Minor
Found in src/Jit/Patcher/Monkey.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

Function _addClosingParenthesis has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    protected function _addClosingParenthesis($pos, $index, $parent)
    {
        $count = 0;
        $nodes = $parent->tree;
        $total = count($nodes);
Severity: Minor
Found in src/Jit/Patcher/Monkey.php - About 3 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 _monkeyPatch has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function _monkeyPatch($node, $parent, $index)
    {
        if (!preg_match_all($this->_regex, $node->body, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
            return;
        }
Severity: Minor
Found in src/Jit/Patcher/Monkey.php - About 2 hrs to fix

    Method _addClosingParenthesis has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function _addClosingParenthesis($pos, $index, $parent)
        {
            $count = 0;
            $nodes = $parent->tree;
            $total = count($nodes);
    Severity: Minor
    Found in src/Jit/Patcher/Monkey.php - About 1 hr to fix

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

          protected function _processTree($parent)
          {
              $hasScope = $parent instanceof FunctionDef || $parent->type === 'namespace' | $parent->type === 'declare';
              if ($hasScope) {
                  $this->_variables[++$this->_depth] = [];
      Severity: Minor
      Found in src/Jit/Patcher/Monkey.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

      There are no issues that match your filters.

      Category
      Status