tuhin18003/WooCommerce-AltCoin-Payment-Gateway

View on GitHub

Showing 92 of 92 total issues

Method show_more_less has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private static function show_more_less() {
        ?>
            <script type="text/javascript">
                jQuery(document).ready(function( $ ){
                    $('.address').each(function( e ){
Severity: Minor
Found in core/admin/options/Scripts_Settings.php - About 1 hr to fix

    Function _cs_wapg_custom_call has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function _cs_wapg_custom_call() {
    
            if ( ! isset( $_REQUEST['cs_token'] ) || false === check_ajax_referer( SECURE_AUTH_SALT, 'cs_token', false ) ) {
                wp_send_json(
                    array(
    Severity: Minor
    Found in core/actions/CustomAjax.php - About 55 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

    Function udpate_coin has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function udpate_coin( $user_data ) {
            global $wpdb, $wapg_tables;
            $coin_info           = Util::check_evil_script( $user_data['cs_add_new'] );
            $more_address_fields = Util::check_evil_script( $user_data['more_coin_address'] );
    
    
    Severity: Minor
    Found in core/admin/functions/CsAdminQuery.php - About 45 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

    Function generate_select_field has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        private function generate_select_field( $field_name, $field, $field_id ) {
            $value = '';
            if ( isset( $field['value'] ) && ! empty( $field['value'] ) ) {
                $value = $field['value'];
                unset( $field['value'] );
    Severity: Minor
    Found in core/admin/builders/CsFormBuilder.php - About 45 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            if ( empty( $coin_id = $this->get_coin_id( $coin_info['coin_name'], $coin_info['checkout_type'] ) ) ) {
                wp_send_json(
                    array(
                        'status' => false,
                        'title'  => __( 'Error', 'woo-altcoin-payment-gateway' ),
    Severity: Minor
    Found in core/admin/functions/CsAdminQuery.php and 1 other location - About 40 mins to fix
    core/admin/functions/CsAdminQuery.php on lines 55..70

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 94.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            if ( empty( $coin_web_id = $this->get_coin_id( $coin_info['coin_name'], $coin_info['checkout_type'] ) ) ) {
                wp_send_json(
                    array(
                        'status' => false,
                        'title'  => __( 'Error', 'woo-altcoin-payment-gateway' ),
    Severity: Minor
    Found in core/admin/functions/CsAdminQuery.php and 1 other location - About 40 mins to fix
    core/admin/functions/CsAdminQuery.php on lines 147..162

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 94.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method error_handler has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public static function error_handler( $errno, $errstr, $errfile, $errline, $errcontext ) {
    Severity: Minor
    Found in core/admin/notices/wapgNotice.php - About 35 mins to fix

      Function cs_dokan_withdrawl_method has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function cs_dokan_withdrawl_method( $methods ) {
              global $wpdb, $wapg_tables;
              $coins = $wpdb->get_results( "select * from {$wapg_tables['coins']} order by name desc" );
              if ( $coins ) {
                  foreach ( $coins as $coin ) {
      Severity: Minor
      Found in core/actions/VendorDokan.php - About 35 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

      Function init_gateway has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              public static function init_gateway() {
                   $CsNotice = self::$namespace . "\admin\\notices\\wapgAdminNotice";
                  if ( class_exists( 'WC_Payment_Gateway' ) ) {
                      self::set_constant( 'IS_WOOCOMMERCE_INSTALLED', true );
                      $CsAutoOrder = self::$namespace . "\\admin\\functions\\CsAutomaticOrderConfirmationSettings";
      Severity: Minor
      Found in woocommerce-altcoin-payment.php - About 35 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

      Function load_admin_settings_scripts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function load_admin_settings_scripts( $page_id ) {
              global $altcoin_menu;
      
              if ( isset( $altcoin_menu['add_new_coin'] ) && $page_id == $altcoin_menu['add_new_coin'] ) {
                  wp_enqueue_style( 'jquery-typehead', CS_WAPG_PLUGIN_ASSET_URI . 'plugins/jquery-typeahead/jquery.typeahead.min.css', false );
      Severity: Minor
      Found in core/admin/options/Scripts_Settings.php - About 35 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

      Function notice_html has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function notice_html( $notice ) {
               $notice_class = '';
              if ( isset( $notice['error'] ) && true === $notice['error'] ) {
                  $notice_class = 'error-notice';
              } elseif ( isset( $notice['success'] ) && ( true === $notice['success'] || false === $notice['success'] ) ) {
      Severity: Minor
      Found in core/lib/Util.php - About 35 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

      Function customForm has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function customForm( $refObj ) {
              global $wp;
      
              $active_coins = CsAdminQuery::get_coins( array( 'where' => ' c.status = 1 ' ) );
              if ( empty( $active_coins ) ) {
      Severity: Minor
      Found in core/admin/builders/CsWapgForm.php - About 35 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

      Function cs_dokan_seller_active_withdrawl_methods has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function cs_dokan_seller_active_withdrawl_methods( $active_payment_methods, $vendor_id = 0 ) {
              $vendor_id       = $vendor_id ? $vendor_id : dokan_get_current_user_id();
              $payment_methods = get_user_meta( $vendor_id, 'dokan_profile_settings' );
              if ( isset( $payment_methods[0]['payment'] ) ) {
                  foreach ( $payment_methods[0]['payment'] as $payment_method => $item ) {
      Severity: Minor
      Found in core/actions/VendorDokan.php - About 35 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

      Function process_payment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function process_payment( $order_id ) {
      
              $order           = wc_get_order( $order_id );
              $payment_confirm = isset( $_POST['payment_confirm'] ) ? $this->validate_text_field( false, $_POST['payment_confirm'] ) : '';
              $payment_info    = $this->validate_text_field( false, $_POST['payment_info'] );
      Severity: Minor
      Found in core/admin/functions/CsWapgFunctions.php - About 35 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

      Function hasPaid has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function hasPaid() {
              $getSettings = get_option( self::$settings_key );
              if ( $getSettings ) {
                  if ( isset( $getSettings['id'] ) && isset( $getSettings['cms_username'] ) && isset( $getSettings['cms_pass'] ) ) {
                      if ( $getSettings['id'] == md5( trim( $getSettings['cms_username'] ) . trim( $getSettings['cms_pass'] ) . 'paid' ) ) {
      Severity: Minor
      Found in core/admin/functions/CsAutomaticOrderConfirmationSettings.php - About 35 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

      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

        Avoid too many return statements within this method.
        Open

                        return wp_send_json(
                            Util::notice_html(
                                array(
                                    'error'    => true,
                                    'response' => isset( $response->response ) ? $response->response : $response->message,
        Severity: Major
        Found in core/frontend/functions/CsWapgAutoOrderConfirm.php - About 30 mins to fix

          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 wp_send_json(
                            array(
                                'success'  => false,
                                'response' => 'Please select "Payment Confirmation Type" at first!',
                            )
            Severity: Major
            Found in core/admin/functions/CsAdminQuery.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return wp_send_json(
                                  Util::notice_html(
                                      array(
                                          'success'  => true,
                                          'response' => __( 'Thank you! Transaction completed successfully. Your order is processing right now!', 'woo-altcoin-payment-gateway' ),
              Severity: Major
              Found in core/frontend/functions/CsWapgAutoOrderConfirm.php - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language