woothemes/woocommerce

View on GitHub
includes/libraries/class-wc-eval-math.php

Summary

Maintainability
F
5 days
Test Coverage

Function nfx has a Cognitive Complexity of 100 (exceeds 5 allowed). Consider refactoring.
Open

        private static function nfx( $expr ) {

            $index = 0;
            $stack = new WC_Eval_Math_Stack;
            $output = array(); // postfix form of expression, to be passed to pfx()
Severity: Minor
Found in includes/libraries/class-wc-eval-math.php - About 2 days 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 pfx has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

        private static function pfx( $tokens, $vars = array() ) {
            if ( false == $tokens ) {
                return false;
            }
            $stack = new WC_Eval_Math_Stack;
Severity: Minor
Found in includes/libraries/class-wc-eval-math.php - About 5 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 nfx has 115 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        private static function nfx( $expr ) {

            $index = 0;
            $stack = new WC_Eval_Math_Stack;
            $output = array(); // postfix form of expression, to be passed to pfx()
Severity: Major
Found in includes/libraries/class-wc-eval-math.php - About 4 hrs to fix

    Function evaluate has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

            public static function evaluate( $expr ) {
                self::$last_error = null;
                $expr = trim( $expr );
                if ( substr( $expr, -1, 1 ) == ';' ) {
                    $expr = substr( $expr, 0, strlen( $expr ) -1 ); // strip semicolons at the end
    Severity: Minor
    Found in includes/libraries/class-wc-eval-math.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

    File class-wc-eval-math.php has 266 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    use Automattic\Jetpack\Constants;
    
    if ( ! defined( 'ABSPATH' ) ) {
    Severity: Minor
    Found in includes/libraries/class-wc-eval-math.php - About 2 hrs to fix

      Method pfx has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              private static function pfx( $tokens, $vars = array() ) {
                  if ( false == $tokens ) {
                      return false;
                  }
                  $stack = new WC_Eval_Math_Stack;
      Severity: Minor
      Found in includes/libraries/class-wc-eval-math.php - About 2 hrs to fix

        Method evaluate has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                public static function evaluate( $expr ) {
                    self::$last_error = null;
                    $expr = trim( $expr );
                    if ( substr( $expr, -1, 1 ) == ';' ) {
                        $expr = substr( $expr, 0, strlen( $expr ) -1 ); // strip semicolons at the end
        Severity: Minor
        Found in includes/libraries/class-wc-eval-math.php - About 1 hr to fix

          Avoid too many return statements within this method.
          Open

                                  return self::trigger( "unexpected ','" );
          Severity: Major
          Found in includes/libraries/class-wc-eval-math.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                                        return self::trigger( "internal error" );
            Severity: Major
            Found in includes/libraries/class-wc-eval-math.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                                  return self::trigger( "expecting ')'" ); // if there are (s on the stack, ()s were unbalanced
              Severity: Major
              Found in includes/libraries/class-wc-eval-math.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return $output;
                Severity: Major
                Found in includes/libraries/class-wc-eval-math.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return true;
                  Severity: Major
                  Found in includes/libraries/class-wc-eval-math.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return self::trigger( "internal error" );
                    Severity: Major
                    Found in includes/libraries/class-wc-eval-math.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return $stack->pop();
                      Severity: Major
                      Found in includes/libraries/class-wc-eval-math.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                            return self::trigger( "an unexpected error occurred" );
                        Severity: Major
                        Found in includes/libraries/class-wc-eval-math.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                                      return self::trigger( "unexpected ','" ); // oops, never had a (
                          Severity: Major
                          Found in includes/libraries/class-wc-eval-math.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                                return self::trigger( "unexpected ')'" );
                            Severity: Major
                            Found in includes/libraries/class-wc-eval-math.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                                  return self::trigger( "unexpected operator '$op'" );
                              Severity: Major
                              Found in includes/libraries/class-wc-eval-math.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                return self::pfx( self::nfx( $expr ) ); // straight up evaluation, woo
                                Severity: Major
                                Found in includes/libraries/class-wc-eval-math.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                      return false; // see if it can be converted to postfix
                                  Severity: Major
                                  Found in includes/libraries/class-wc-eval-math.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                                return self::trigger( "undefined variable '$token' in function definition" );
                                    Severity: Major
                                    Found in includes/libraries/class-wc-eval-math.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                              return self::trigger( "undefined variable '$token'" );
                                      Severity: Major
                                      Found in includes/libraries/class-wc-eval-math.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                                return self::trigger( "operator '$op' lacks operand" );
                                        Severity: Major
                                        Found in includes/libraries/class-wc-eval-math.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                                          return self::trigger( "wrong number of arguments ($arg_count given, " . count( self::$f[ $fnn ]['args'] ) . " expected)" );
                                          Severity: Major
                                          Found in includes/libraries/class-wc-eval-math.php - About 30 mins to fix

                                            There are no issues that match your filters.

                                            Category
                                            Status