Showing 63 of 63 total issues
Method enqueue_admin_scripts
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function enqueue_admin_scripts() {
global $wp_scripts;
$wp_scripts->queue = array();
// deregister scripts
Similar blocks of code found in 2 locations. Consider refactoring. Open
foreach ( $buttons as $button ):
$href = isset( $button['href'] ) ? $button['href'] : '#';
$action = isset( $button['action'] ) ? 'data-action="' . esc_attr( $button['action'] ) . '"' : '';
$prompt = isset( $button['prompt'] ) ? $button['prompt'] : '';
?>
- 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 110.
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
foreach ( $buttons as $button ):
$href = isset( $button['href'] ) ? $button['href'] : '#';
$action = isset( $button['action'] ) ? 'data-action="' . esc_attr( $button['action'] ) . '"' : '';
$prompt = isset( $button['prompt'] ) ? $button['prompt'] : '';
?>
- 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 110.
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 save_post
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function save_post( $post_id, $post ) {
// If this is an autosave, our form has not been submitted, so we don't want to do anything.
if ( defined( '\DOING_AUTOSAVE' ) && \DOING_AUTOSAVE ) {
return;
- 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 create_order_note_data
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
static public function create_order_note_data( $data, $order_id ) {
if ( ! isset( $data['email'] ) ) {
return $data;
}
Method order_response
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function order_response( $order_data, $order, $fields, $server ) {
// add cashier data
$order_data['cashier'] = $this->add_cashier_details( $order );
Method get_receipt_template
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_receipt_template() {
$this->register_receipt_status();
$settings = wcpos_get_option( 'receipts', 'receipt_options' );
$type = isset( $settings['template_language'] ) ? $settings['template_language'] : 'html';
Method save_post
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function save_post( $post_id, $post ) {
// If this is an autosave, our form has not been submitted, so we don't want to do anything.
if ( defined( '\DOING_AUTOSAVE' ) && \DOING_AUTOSAVE ) {
return;
Method menu
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function menu() {
return apply_filters( 'woocommerce_pos_menu', array(
array(
'id' => 'pos',
Method update_post_metadata
has 32 lines of code (exceeds 25 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' ) {
Function delete
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function delete() {
global $wp_roles;
$roles = $wp_roles->roles;
$caps = array_merge( $this->caps['pos'], $this->caps['woo'] );
- 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 update_check
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function update_check( $transient, $force = false ) {
$locale = get_locale();
// pre_set_site_transient_update_plugins is called twice
// we only want to act on the second run
Function meta_box
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function meta_box(){
var display = $('#pos-visibility-display'),
show = $('#pos-visibility-show'),
select = $('#pos-visibility-select'),
cancel = $('#pos-visibility-cancel'),
Method create_order_data
has 30 lines of code (exceeds 25 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 );
Method get_external_library_locale_js
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
static public function get_external_library_locale_js( $library = '', $version = '' ) {
$cdnjs_url = $locale_js = '';
switch ( $library ) {
case 'select2':
Method get_settings_handler
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function get_settings_handler( $id ) {
if ( ! $id ) {
return new \WP_Error(
'woocommerce_pos_settings_error',
Method pos_visibility_filters
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function pos_visibility_filters( $views ) {
global $wpdb;
$visibility_filters = array(
// 'pos_and_online' => __( 'POS & Online', 'woocommerce-pos' ),
Function complex_search
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function complex_search( array $queries, \WP_User_Query $WP_User_Query ) {
$include = array();
foreach ( $queries as $query ) {
$type = isset( $query['type'] ) ? $query['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
Function get_external_library_locale_js
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
static public function get_external_library_locale_js( $library = '', $version = '' ) {
$cdnjs_url = $locale_js = '';
switch ( $library ) {
case 'select2':
- 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 activate
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function activate( $network_wide ) {
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
if ( $network_wide ) {
- 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"