j84reginato/my-eval

View on GitHub
src/Solving/ASCIIPrinter.php

Summary

Maintainability
D
1 day
Test Coverage

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

    public function parenthesize(
        ?Node $node,
        InfixExpressionNode $cutoff,
        string $prepend = '',
        bool $conservative = false
Severity: Minor
Found in src/Solving/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 visitInfixExpressionNode has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function visitInfixExpressionNode(InfixExpressionNode $node): string
    {
        $left     = $node->getLeft();
        $operator = $node->operator;
        $right    = $node->getRight();
Severity: Major
Found in src/Solving/ASCIIPrinter.php - About 2 hrs to fix

    Method parenthesize has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function parenthesize(
            ?Node $node,
            InfixExpressionNode $cutoff,
            string $prepend = '',
            bool $conservative = false
    Severity: Minor
    Found in src/Solving/ASCIIPrinter.php - About 1 hr to fix

      Avoid too many return statements within this method.
      Open

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

        Avoid too many return statements within this method.
        Open

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

          Avoid too many return statements within this method.
          Open

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

            Avoid too many return statements within this method.
            Open

                            return "$leftValue>=$rightValue";
            Severity: Major
            Found in src/Solving/ASCIIPrinter.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return "$leftValue<=$rightValue";
              Severity: Major
              Found in src/Solving/ASCIIPrinter.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

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

                  Avoid too many return statements within this method.
                  Open

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

                    Avoid too many return statements within this method.
                    Open

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

                      Avoid too many return statements within this method.
                      Open

                                      return "$leftValue<>$rightValue";
                      Severity: Major
                      Found in src/Solving/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/Solving/ASCIIPrinter.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

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

                            Avoid too many return statements within this method.
                            Open

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

                              Avoid too many return statements within this method.
                              Open

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

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

                                    private function visitFactorialNode(FunctionNode $node): string
                                    {
                                        $functionName = $node->operator;
                                        $operand      = $node->operand;
                                        $op           = $operand->accept($this);
                                Severity: Minor
                                Found in src/Solving/ASCIIPrinter.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