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()
- Read upRead up
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;
- Read upRead up
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()
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
- Read upRead up
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' ) ) {
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;
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
Avoid too many return
statements within this method. Open
return self::trigger( "unexpected ','" );
Avoid too many return
statements within this method. Open
return self::trigger( "internal error" );
Avoid too many return
statements within this method. Open
return self::trigger( "expecting ')'" ); // if there are (s on the stack, ()s were unbalanced
Avoid too many return
statements within this method. Open
return $output;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return self::trigger( "internal error" );
Avoid too many return
statements within this method. Open
return $stack->pop();
Avoid too many return
statements within this method. Open
return self::trigger( "an unexpected error occurred" );
Avoid too many return
statements within this method. Open
return self::trigger( "unexpected ','" ); // oops, never had a (
Avoid too many return
statements within this method. Open
return self::trigger( "unexpected ')'" );
Avoid too many return
statements within this method. Open
return self::trigger( "unexpected operator '$op'" );
Avoid too many return
statements within this method. Open
return self::pfx( self::nfx( $expr ) ); // straight up evaluation, woo
Avoid too many return
statements within this method. Open
return false; // see if it can be converted to postfix
Avoid too many return
statements within this method. Open
return self::trigger( "undefined variable '$token' in function definition" );
Avoid too many return
statements within this method. Open
return self::trigger( "undefined variable '$token'" );
Avoid too many return
statements within this method. Open
return self::trigger( "operator '$op' lacks operand" );
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)" );