Showing 63 of 63 total issues
File orders.php
has 545 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* POS Orders Class
* duck punches the WC REST API
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function payment_fields() {
if ( $this->description ) {
echo '<p>' . wp_kses_post( $this->description ) . '</p>';
}
- 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 182.
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
public function payment_fields() {
if ( $this->description ) {
echo '<p>' . wp_kses_post( $this->description ) . '</p>';
}
- 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 182.
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
Orders
has 35 functions (exceeds 20 allowed). Consider refactoring. Open
class Orders {
/** @var string $base the route base */
protected $base = '/orders';
Method prefix_query
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function prefix_query( $prefix, $term, \WP_Query $wp_query ) {
// store original meta_query
$meta_query = $wp_query->get( 'meta_query' );
$tax_query = $wp_query->get( 'tax_query' );
Function update_post_metadata
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public function update_post_metadata( $null, $order_id, $meta_key, $meta_value, $prev_value ) {
// we want last update to _order_shipping after $order->calculate_taxes()
// set flag true on first pass
if ( $meta_key == '_order_shipping_tax' ) {
- 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 products.php
has 320 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* POS Product Class
* duck punches the WC REST API
Function prefix_query
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
private function prefix_query( $prefix, $term, \WP_Query $wp_query ) {
// store original meta_query
$meta_query = $wp_query->get( 'meta_query' );
$tax_query = $wp_query->get( 'tax_query' );
- 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 update_capabilities
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
private function update_capabilities( array $roles ) {
foreach ( $roles as $slug => $array ):
$role = get_role( $slug );
- 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 enqueue_admin_scripts
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function enqueue_admin_scripts() {
global $wp_scripts;
$wp_scripts->queue = array();
// deregister scripts
Method manual_update
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function manual_update() {
ob_start();
$locale = get_locale();
$creds = request_filesystem_credentials( $_GET['security'], '', false, false, null );
Function manual_update
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function manual_update() {
ob_start();
$locale = get_locale();
$creds = request_filesystem_credentials( $_GET['security'], '', false, false, null );
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function __construct() {
$this->id = 'pos_cash';
$this->title = __( 'Cash', 'woocommerce-pos' );
$this->description = '';
$this->icon = apply_filters( 'woocommerce_pos_cash_icon', '' );
- 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 118.
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
public function __construct() {
$this->id = 'pos_card';
$this->title = __( 'Card', 'woocommerce-pos' );
$this->description = '';
$this->icon = apply_filters( 'woocommerce_pos_card_icon', '' );
- 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 118.
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
Function is_pos
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function is_pos( $type = 'all' ) {
// check query_vars, eg: ?wcpos=1 or /pos rewrite rule
if ( $type == 'all' || $type == 'query_var' ) {
global $wp;
- 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 order_response
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function order_response( $order_data, $order, $fields, $server ) {
// add cashier data
$order_data['cashier'] = $this->add_cashier_details( $order );
- 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 get_variation_option
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function get_variation_option( $product, $attribute, $option ) {
$name = $option;
// taxonomy attributes
if ( $attribute['is_taxonomy'] ) {
- 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 remove_admin_emails
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function remove_admin_emails( WC_Emails $wc_emails ) {
// send 'woocommerce_low_stock_notification'
// send 'woocommerce_no_stock_notification'
// send 'woocommerce_product_on_backorder_notification'
remove_action(
Function create_order_data
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function create_order_data( array $data ) {
// add filters & actions for create order
add_filter( 'woocommerce_product_tax_class', array( $this, 'product_tax_class' ), 10, 2 );
add_filter( 'woocommerce_get_product_from_item', array( $this, 'get_product_from_item' ), 10, 3 );
- 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 simple_search
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function simple_search( $term, \WP_User_Query $WP_User_Query ) {
$fields = isset( $_GET['filter']['qFields'] ) ? $_GET['filter']['qFields'] : array();
$fields = is_array( $fields ) ? $fields : array( $fields );
$search_columns = $meta_query = $user_query_ids = $usermeta_query_ids = array();