mossadal/math-parser

View on GitHub
src/MathParser/Interpreting/ASCIIPrinter.php

Summary

Maintainability
C
1 day
Test Coverage

Function parenthesize has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function parenthesize(Node $node, ExpressionNode $cutoff, $prepend = '', $conservative = false)
    {
        $text = $node->accept($this);

        if ($node instanceof ExpressionNode) {
Severity: Minor
Found in src/MathParser/Interpreting/ASCIIPrinter.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 parenthesize has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function parenthesize(Node $node, ExpressionNode $cutoff, $prepend = '', $conservative = false)
    {
        $text = $node->accept($this);

        if ($node instanceof ExpressionNode) {
Severity: Minor
Found in src/MathParser/Interpreting/ASCIIPrinter.php - About 1 hr to fix

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

        public function visitExpressionNode(ExpressionNode $node)
        {
            $operator = $node->getOperator();
            $left = $node->getLeft();
            $right = $node->getRight();
    Severity: Minor
    Found in src/MathParser/Interpreting/ASCIIPrinter.php - About 1 hr to fix

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

          private function visitFactorialNode(FunctionNode $node)
          {
              $functionName = $node->getName();
              $op = $node->getOperand();
              $operand = $op->accept($this);
      Severity: Minor
      Found in src/MathParser/Interpreting/ASCIIPrinter.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 "($text)";
      Severity: Major
      Found in src/MathParser/Interpreting/ASCIIPrinter.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        return "$leftValue$operator$rightValue";
        Severity: Major
        Found in src/MathParser/Interpreting/ASCIIPrinter.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return 'INF';
          Severity: Major
          Found in src/MathParser/Interpreting/ASCIIPrinter.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return "($text)";
            Severity: Major
            Found in src/MathParser/Interpreting/ASCIIPrinter.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return "($text)";
              Severity: Major
              Found in src/MathParser/Interpreting/ASCIIPrinter.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return "$prepend$text";
                Severity: Major
                Found in src/MathParser/Interpreting/ASCIIPrinter.php - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status