kahlan/kahlan

View on GitHub
src/Jit/Parser.php

Summary

Maintainability
F
4 days
Test Coverage
A
96%

File Parser.php has 652 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace Kahlan\Jit;

use Kahlan\Jit\Node\NodeDef;
use Kahlan\Jit\Node\FunctionDef;
Severity: Major
Found in src/Jit/Parser.php - About 1 day to fix

    Function _parser has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function _parser($content)
        {
            $this->_initLines($content);
            $this->_stream = new TokenStream(['source' => $content, 'wrap' => $this->_states['php']]);
    
    
    Severity: Minor
    Found in src/Jit/Parser.php - About 6 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 _parser has 146 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function _parser($content)
        {
            $this->_initLines($content);
            $this->_stream = new TokenStream(['source' => $content, 'wrap' => $this->_states['php']]);
    
    
    Severity: Major
    Found in src/Jit/Parser.php - About 5 hrs to fix

      Parser has 28 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Parser
      {
          /**
           * @var int
           * @internal
      Severity: Minor
      Found in src/Jit/Parser.php - About 3 hrs to fix

        Function _parseArgs has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function _parseArgs()
            {
                $cpt = 0;
                $value = $name = '';
                $args = [];
        Severity: Minor
        Found in src/Jit/Parser.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 _useNode has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function _useNode()
            {
                $current = $this->_states['current'];
                $token = $this->_stream->current(true);
                $last = $alias = $use = '';
        Severity: Minor
        Found in src/Jit/Parser.php - About 1 hr to fix

          Method _parseArgs has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function _parseArgs()
              {
                  $cpt = 0;
                  $value = $name = '';
                  $args = [];
          Severity: Minor
          Found in src/Jit/Parser.php - About 1 hr to fix

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

                protected function _functionNode()
                {
                    $node = new FunctionDef();
                    $token = $this->_stream->current(true);
                    $parent = $this->_states['current'];
            Severity: Minor
            Found in src/Jit/Parser.php - About 1 hr to fix

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

                  protected function _classNode()
                  {
                      if (substr($this->_states['body'], -2) === '::') { // Bails out on `::class`
                          $this->_states['body'] .= 'class';
                          return;
              Severity: Minor
              Found in src/Jit/Parser.php - About 1 hr to fix

                Method debug has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function debug($content)
                    {
                        $root = is_object($content) ? $content : static::parse($content, ['lines' => true]);
                        $result = '';
                
                
                Severity: Minor
                Found in src/Jit/Parser.php - About 1 hr to fix

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

                      protected function _useNode()
                      {
                          $current = $this->_states['current'];
                          $token = $this->_stream->current(true);
                          $last = $alias = $use = '';
                  Severity: Minor
                  Found in src/Jit/Parser.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 _classNode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function _classNode()
                      {
                          if (substr($this->_states['body'], -2) === '::') { // Bails out on `::class`
                              $this->_states['body'] .= 'class';
                              return;
                  Severity: Minor
                  Found in src/Jit/Parser.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 _annotationNode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function _annotationNode()
                      {
                          $cpt = 1; //because #[
                          $this->_codeNode();
                          $token = $this->_stream->current(true);
                  Severity: Minor
                  Found in src/Jit/Parser.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 _functionNode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function _functionNode()
                      {
                          $node = new FunctionDef();
                          $token = $this->_stream->current(true);
                          $parent = $this->_states['current'];
                  Severity: Minor
                  Found in src/Jit/Parser.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

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

                      protected function _normalizeClass($name)
                      {
                          if (!$name || $name[0] === '\\') {
                              return $name;
                          }
                  Severity: Minor
                  Found in src/Jit/Parser.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

                  There are no issues that match your filters.

                  Category
                  Status