pug-php/js-phpize

View on GitHub

Showing 46 of 179 total issues

Method visitFunctionCall has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function visitFunctionCall(FunctionCall $functionCall, $indent)
    {
        $function = $functionCall->function;
        $arguments = $functionCall->arguments;
        $applicant = $functionCall->applicant;
Severity: Minor
Found in src/JsPhpize/Compiler/Compiler.php - About 1 hr to fix

    Method compile has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function compile($input, $filename = null)
        {
            $this->flags = 0;
    
            if ($filename === null) {
    Severity: Minor
    Found in src/JsPhpize/JsPhpize.php - About 1 hr to fix

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

          protected function getVariableChildFromToken(Token $token)
          {
              if ($token->is('.')) {
                  $this->skip();
                  $token = $this->next();
      Severity: Minor
      Found in src/JsPhpize/Parser/TokenExtractor.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

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

          protected function parseFunctionCallChildren($function, $applicant = null)
          {
              $arguments = $this->parseParentheses()->nodes;
              $children = [];
      
      
      Severity: Minor
      Found in src/JsPhpize/Parser/Parser.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

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

          public function next()
          {
              if (!mb_strlen($this->input)) {
                  return false;
              }
      Severity: Minor
      Found in src/JsPhpize/Lexer/Lexer.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

      Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function __construct($operator, Value $leftHand, Value $rightHand, array $before = null, array $after = null)
      Severity: Minor
      Found in src/JsPhpize/Nodes/Dyiade.php - About 35 mins to fix

        Method visitNodesArray has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            protected function visitNodesArray($array, $indent, $glue = '', $pattern = null, $options = 0)
        Severity: Minor
        Found in src/JsPhpize/Compiler/Compiler.php - About 35 mins to fix

          Function readInterpolation has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function readInterpolation($value)
              {
                  while (strlen($value)) {
                      preg_match('/^([\s\S]*)(?:(\\\\|\\${)[\s\S]*)?$/U', $value, $match);
          
          
          Severity: Minor
          Found in src/JsPhpize/Compiler/InterpolationTrait.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 parseKeywordStatement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function parseKeywordStatement($token)
              {
                  $name = $token->value;
                  $keyword = new Block($name);
          
          
          Severity: Minor
          Found in src/JsPhpize/Parser/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 visitFunctionCall has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function visitFunctionCall(FunctionCall $functionCall, $indent)
              {
                  $function = $functionCall->function;
                  $arguments = $functionCall->arguments;
                  $applicant = $functionCall->applicant;
          Severity: Minor
          Found in src/JsPhpize/Compiler/Compiler.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 getInitialValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function getInitialValue($token)
              {
                  if ($token->isFunction()) {
                      return $this->parseFunction();
                  }
          Severity: Minor
          Found in src/JsPhpize/Parser/TokenExtractor.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 parseInstructions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function parseInstructions($block)
              {
                  $initNext = false;
          
                  while ($token = $this->next()) {
          Severity: Minor
          Found in src/JsPhpize/Parser/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

          Avoid too many return statements within this method.
          Open

                      return $this->handleLeftOperator($this->expectValue($this->next(), $token), $token);
          Severity: Major
          Found in src/JsPhpize/Parser/TokenExtractor.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return $this->parseKeyword($token);
            Severity: Major
            Found in src/JsPhpize/Parser/TokenExtractor.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

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

                Avoid too many return statements within this method.
                Open

                            return $this->parseValue($token);
                Severity: Major
                Found in src/JsPhpize/Parser/TokenExtractor.php - About 30 mins to fix

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

                      protected function visitConstant(Constant $constant)
                      {
                          $value = $constant->value;
                  
                          if ($constant->type === 'string') {
                  Severity: Minor
                  Found in src/JsPhpize/Compiler/Compiler.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 visitAssignation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function visitAssignation(Assignation $assignation, $indent)
                      {
                          if ($assignation->leftHand instanceof Constant && $assignation->leftHand->type === 'constant') {
                              return 'define(' .
                                  var_export(strval($assignation->leftHand->value), true) . ', ' .
                  Severity: Minor
                  Found in src/JsPhpize/Compiler/Compiler.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 parseBlock has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function parseBlock($block)
                      {
                          $this->stack[] = $block;
                  
                          if (!$block->multipleInstructions) {
                  Severity: Minor
                  Found in src/JsPhpize/Parser/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

                  The method appendFunctionsCalls() has an NPath complexity of 301. The configured NPath complexity threshold is 200.
                  Open

                      protected function appendFunctionsCalls(&$value, $previousToken = null, $applicant = null)
                      {
                          while ($token = $this->get(0)) {
                              if ($token->is('{') || $token->expectNoLeftMember()) {
                                  throw $this->unexpected($this->next());

                  NPathComplexity

                  Since: 0.1

                  The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                  Example

                  class Foo {
                      function bar() {
                          // lots of complicated code
                      }
                  }

                  Source https://phpmd.org/rules/codesize.html#npathcomplexity

                  Severity
                  Category
                  Status
                  Source
                  Language