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();
- 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 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' ) ) {
- 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 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();
File CsFormBuilder.php
has 261 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php namespace WooGateWayCoreLib\admin\builders;
/**
* From Builder
*
File CsWapgCoinCal.php
has 258 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace WooGateWayCoreLib\frontend\functions;
/**
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();
- 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 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(
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;
}
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 ) ) {
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">';
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">
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'] );
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(
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({
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,
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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,
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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,
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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',
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 ) {
?>
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' ) {
- 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"