Showing 396 of 396 total issues
File class-sv-wc-payment-gateway.php
has 1556 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WooCommerce Payment Gateway Framework
*
* This source file is subject to the GNU General Public License v3.0
SV_WC_Payment_Gateway
has 170 functions (exceeds 20 allowed). Consider refactoring. Open
#[\AllowDynamicProperties]
abstract class SV_WC_Payment_Gateway extends \WC_Payment_Gateway {
/** Sends through sale and request for funds to be charged to cardholder's credit card. */
Function get_tokens
has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring. Open
public function get_tokens( $user_id, $args = array() ) {
// default to current environment
if ( ! isset( $args['environment_id'] ) ) {
$args['environment_id'] = $this->get_environment_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
SV_WC_Plugin
has 71 functions (exceeds 20 allowed). Consider refactoring. Open
#[\AllowDynamicProperties]
abstract class SV_WC_Plugin {
/** Plugin Framework Version */
File class-sv-wc-payment-gateway-direct.php
has 579 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WooCommerce Payment Gateway Framework
*
* This source file is subject to the GNU General Public License v3.0
File class-sv-wc-payment-gateway-plugin.php
has 568 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WooCommerce Payment Gateway Framework
*
* This source file is subject to the GNU General Public License v3.0
File abstract-sv-wc-plugin-admin-setup-wizard.php
has 559 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WooCommerce Plugin Framework
*
* This source file is subject to the GNU General Public License v3.0
SV_WC_Payment_Gateway_Plugin
has 63 functions (exceeds 20 allowed). Consider refactoring. Open
#[\AllowDynamicProperties]
abstract class SV_WC_Payment_Gateway_Plugin extends SV_WC_Plugin {
/** Customer ID feature */
File class-sv-wc-payment-gateway-payment-tokens-handler.php
has 490 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WooCommerce Payment Gateway Framework
*
* This source file is subject to the GNU General Public License v3.0
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ( static::is_cart_block_in_use() ) {
if ( ! $this->is_cart_block_compatible() ) {
$url = get_edit_post_link( wc_get_page_id( 'cart' ) );
- 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 240.
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 2 locations. Consider refactoring. Open
if ( static::is_checkout_block_in_use() ) {
if ( ! $this->is_checkout_block_compatible() ) {
$url = get_edit_post_link( wc_get_page_id( 'checkout' ) );
- 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 240.
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
Setup_Wizard
has 48 functions (exceeds 20 allowed). Consider refactoring. Open
#[\AllowDynamicProperties]
abstract class Setup_Wizard {
/** the "finish" step ID */
Function add_transaction_data
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
public function add_transaction_data( $order, $response = null ) {
// transaction id if available
if ( $response && $response->get_transaction_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 class-sv-wc-plugin.php
has 440 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WooCommerce Plugin Framework
*
* This source file is subject to the GNU General Public License v3.0
File Country_Helper.php
has 436 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WooCommerce Plugin Framework
*
* This source file is subject to the GNU General Public License v3.0
SV_WC_Payment_Gateway_My_Payment_Methods
has 46 functions (exceeds 20 allowed). Consider refactoring. Open
#[\AllowDynamicProperties]
class SV_WC_Payment_Gateway_My_Payment_Methods extends Handlers\Script_Handler {
/** @var SV_WC_Payment_Gateway_Plugin */
File class-sv-wc-helper.php
has 427 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WooCommerce Plugin Framework
*
* This source file is subject to the GNU General Public License v3.0
File class-sv-wc-payment-gateway-payment-form.php
has 413 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WooCommerce Payment Gateway Framework
*
* This source file is subject to the GNU General Public License v3.0
SV_WC_API_Base
has 42 functions (exceeds 20 allowed). Consider refactoring. Open
#[\AllowDynamicProperties]
abstract class SV_WC_API_Base {
/** @var string request method, defaults to POST */
File class-sv-wp-background-job-handler.php
has 401 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WooCommerce Plugin Framework
*
* This source file is subject to the GNU General Public License v3.0