tuhin18003/WooCommerce-AltCoin-Payment-Gateway

View on GitHub
core/frontend/functions/CsWapgCoinCal.php

Summary

Maintainability
D
1 day
Test Coverage

Method calcualteCoinPrice has 137 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function calcualteCoinPrice() {
        global $woocommerce;

        $coin_id = Util::check_evil_script( ( $_POST['data']['coin_id'] ) );
        if ( empty( $coin_id ) ) {
Severity: Major
Found in core/frontend/functions/CsWapgCoinCal.php - About 5 hrs to fix

    Function calcualteCoinPrice has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        public function calcualteCoinPrice() {
            global $woocommerce;
    
            $coin_id = Util::check_evil_script( ( $_POST['data']['coin_id'] ) );
            if ( empty( $coin_id ) ) {
    Severity: Minor
    Found in core/frontend/functions/CsWapgCoinCal.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

    File CsWapgCoinCal.php has 258 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace WooGateWayCoreLib\frontend\functions;
    
    /**
    Severity: Minor
    Found in core/frontend/functions/CsWapgCoinCal.php - About 2 hrs to fix

      Method get_coin_martket_price has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      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 );
      Severity: Minor
      Found in core/frontend/functions/CsWapgCoinCal.php - About 1 hr to fix

        Function get_coin_martket_price has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        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 );
        Severity: Minor
        Found in core/frontend/functions/CsWapgCoinCal.php - About 1 hr 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 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' ),
                        );
        Severity: Major
        Found in core/frontend/functions/CsWapgCoinCal.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return array(
                      'error'    => true,
                      'response' => __( 'Coin not found in the exchange portal! Please contact administration.', 'woo-altcoin-payment-gateway' ),
                  );
          Severity: Major
          Found in core/frontend/functions/CsWapgCoinCal.php - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status