tuhin18003/WooCommerce-AltCoin-Payment-Gateway

View on GitHub

Showing 92 of 92 total issues

Function generate_html_fields has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public function generate_html_fields( $fields, $return_array = false ) {
        if ( empty( $fields ) ) {
            return false; }

        $html_fields = array();
Severity: Minor
Found in core/admin/builders/CsFormBuilder.php - About 2 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

Function generate_attribute has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    private function generate_attribute( $field_name, $field, $field_id ) {
        // pre_print($field);
        $input_item = '';
        foreach ( $field as $item_id => $item_val ) {
            if ( $field['type'] == 'select' && ( $item_id == 'placeholder' || $item_id == 'type' ) ) {
Severity: Minor
Found in core/admin/builders/CsFormBuilder.php - About 2 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 check_db_status has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function check_db_status() {
        global $wapg_current_db_version, $wpdb, $wapg_tables;
        $get_installed_db_version = get_site_option( 'wapg_db_version' );
        if ( empty( $get_installed_db_version ) ) {
            self::on_activate();
Severity: Major
Found in core/install/Activate.php - About 2 hrs to fix

    File CsFormBuilder.php has 261 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php namespace WooGateWayCoreLib\admin\builders;
    
    /**
     * From Builder
     *
    Severity: Minor
    Found in core/admin/builders/CsFormBuilder.php - About 2 hrs to fix

      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

        Function import_coin_symbol has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function import_coin_symbol() {
                global $wapg_current_db_version, $wpdb, $wapg_tables;
        
                $CsAdminQuery = new CsAdminQuery();
        
        
        Severity: Minor
        Found in core/install/Activate.php - About 2 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 on_activate has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function on_activate() {
                global $wpdb, $wapg_tables;
                $charset_collate = $wpdb->get_charset_collate();
        
                $sqls = array(
        Severity: Minor
        Found in core/install/Activate.php - About 1 hr to fix

          Method order_summary has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function order_summary( $order ) {
                  $payment_details = cartFunctions::get_payment_info( $order->id );
                  if ( empty( $payment_details ) ) {
                      return;
                  }
          Severity: Minor
          Found in core/frontend/functions/CsWapgCustomTy.php - About 1 hr to fix

            Method get_coin_name has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function get_coin_name( $user_input ) {
                    $oc_type = $user_input['oc_type'];
                    if ( $oc_type == 1 ) {
                        $query = $user_input['query'];
                        if ( empty( $query ) ) {
            Severity: Minor
            Found in core/admin/functions/CsAdminQuery.php - About 1 hr to fix

              Method generate_field has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function generate_field( $field_name, $field, $field_id ) {
                      $input  = '<div class="label"><label>';
                      $input .= $this->generate_title( $field );
                      $input .= '</label></div>';
                      $input .= '<div class="input-group">';
              Severity: Minor
              Found in core/admin/builders/CsFormBuilder.php - About 1 hr to fix

                Method order_metabox_coin_details has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function order_metabox_coin_details( $post ) {
                        $order_id        = isset( $post->ID ) ? $post->ID : Util::check_evil_script( $_GET['post'] );
                        $payment_details = cartFunctions::get_payment_info( $order_id );
                        ?>
                        <table class="cs-coin-info">
                Severity: Minor
                Found in core/admin/functions/CsOrderDetails.php - About 1 hr to fix

                  Method process_payment has 45 lines of code (exceeds 25 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 1 hr to fix

                    Method _cs_wapg_custom_call has 45 lines of code (exceeds 25 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 1 hr to fix

                      Method load_jquery_typehead has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

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

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

                                    'cs_altcoin_config[loader_gif_url]'          => array(
                                        'title'                  => __( 'Calculator Gif URL', 'woo-altcoin-payment-gateway' ),
                                        'type'                   => 'text',
                                        'class'                  => 'form-control coin_name',
                                        'required'               => true,
                        Severity: Major
                        Found in core/admin/options/pages/checkoutPageSettings.php and 2 other locations - About 1 hr to fix
                        core/admin/options/pages/checkoutPageSettings.php on lines 107..120
                        core/admin/options/pages/defaultSettings.php on lines 81..94

                        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 115.

                        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 3 locations. Consider refactoring.
                        Open

                                    'cs_altcoin_config[payment_icon_url]' => array(
                                        'title'                  => __( 'Payment Gateway Icon', 'woo-altcoin-payment-gateway' ),
                                        'type'                   => 'text',
                                        'class'                  => 'form-control coin_name',
                                        'required'               => true,
                        Severity: Major
                        Found in core/admin/options/pages/defaultSettings.php and 2 other locations - About 1 hr to fix
                        core/admin/options/pages/checkoutPageSettings.php on lines 93..106
                        core/admin/options/pages/checkoutPageSettings.php on lines 107..120

                        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 115.

                        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 3 locations. Consider refactoring.
                        Open

                                    'cs_altcoin_config[autotracking_gif_url]'    => array(
                                        'title'                  => __( 'Coin Tracking Gif URL', 'woo-altcoin-payment-gateway' ),
                                        'type'                   => 'text',
                                        'class'                  => 'form-control coin_name',
                                        'required'               => true,
                        Severity: Major
                        Found in core/admin/options/pages/checkoutPageSettings.php and 2 other locations - About 1 hr to fix
                        core/admin/options/pages/checkoutPageSettings.php on lines 93..106
                        core/admin/options/pages/defaultSettings.php on lines 81..94

                        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 115.

                        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 wapg_checkout_scripts has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function wapg_checkout_scripts() {
                        
                                wp_enqueue_style(
                                    'wapg-checkout',
                                    CS_WAPG_PLUGIN_ASSET_URI . '/css/checkout.min.css',
                        Severity: Minor
                        Found in core/admin/functions/CsWapgFunctions.php - About 1 hr to fix

                          Method special_discount_offer_box has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static function special_discount_offer_box() {
                                  $offers   = CsAdminQuery::get_offers_info();
                                  $settings = CsPaymentGateway::get_checkout_page_options();
                                  if ( $offers ) {
                                      ?>
                          Severity: Minor
                          Found in core/frontend/functions/CsWapgCustomBlocks.php - About 1 hr to fix

                            Function generate_hidden_div has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private function generate_hidden_div( $field_name, $args, $fields_number ) {
                                    $attributes = '';
                                    if ( isset( $args['attributes'] ) ) {
                                        foreach ( $args['attributes'] as $attr_key => $attr_val ) {
                                            if ( $attr_key == 'id' ) {
                            Severity: Minor
                            Found in core/admin/builders/CsFormBuilder.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

                            Severity
                            Category
                            Status
                            Source
                            Language