core/frontend/functions/CsWapgCoinCal.php
Method calcualteCoinPrice
has 137 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function calcualteCoinPrice() {
global $woocommerce;
$coin_id = Util::check_evil_script( ( $_POST['data']['coin_id'] ) );
if ( empty( $coin_id ) ) {
Function calcualteCoinPrice
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
Open
public function calcualteCoinPrice() {
global $woocommerce;
$coin_id = Util::check_evil_script( ( $_POST['data']['coin_id'] ) );
if ( empty( $coin_id ) ) {
- 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 CsWapgCoinCal.php
has 258 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
namespace WooGateWayCoreLib\frontend\functions;
/**
Method get_coin_martket_price
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function get_coin_martket_price( $coin_slug, $coinType ) {
if ( $coinType == 1 ) {
$api_url = sprintf( $this->coinmarketstats_free_api_url, $coin_slug );
} elseif ( $coinType == 2 ) {
$api_url = sprintf( $this->coinmarketstats_api_url, $coin_slug );
Function get_coin_martket_price
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
public function get_coin_martket_price( $coin_slug, $coinType ) {
if ( $coinType == 1 ) {
$api_url = sprintf( $this->coinmarketstats_free_api_url, $coin_slug );
} elseif ( $coinType == 2 ) {
$api_url = sprintf( $this->coinmarketstats_api_url, $coin_slug );
- 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
Avoid too many return
statements within this method. Open
Open
return array(
'error' => true,
'response' => __( 'Probably this currency is out of the market & doesn\'t have any value! Contact administration for more information..', 'woo-altcoin-payment-gateway' ),
);
Avoid too many return
statements within this method. Open
Open
return array(
'error' => true,
'response' => __( 'Coin not found in the exchange portal! Please contact administration.', 'woo-altcoin-payment-gateway' ),
);