Showing 3,141 of 4,341 total issues
File class-wc-rest-customers-v1-controller.php
has 650 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* REST API Customers controller
*
* Handles requests to the /customers endpoint.
Method prepare_object_for_database
has 288 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function prepare_object_for_database( $request, $creating = false ) {
$id = isset( $request['id'] ) ? absint( $request['id'] ) : 0;
// Type is the most important part here because we need to be using the correct class and methods.
if ( isset( $request['type'] ) ) {
Function getLostPoint
has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring. Open
getLostPoint : function(qrCode) {
var moduleCount = qrCode.getModuleCount();
var lostPoint = 0;
- 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 wc-order-functions.php
has 631 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WooCommerce Order Functions
*
* Functions for order specific things.
Function prepare_object_for_database
has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring. Open
protected function prepare_object_for_database( $request, $creating = false ) {
if ( isset( $request['id'] ) ) {
$variation = wc_get_product( absint( $request['id'] ) );
} else {
$variation = new WC_Product_Variation();
- 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 output
has 277 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function output( $post ) {
wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
$coupon_id = absint( $post->ID );
$coupon = new WC_Coupon( $coupon_id );
File jquery.payment.js
has 613 lines of code (exceeds 250 allowed). Consider refactoring. Open
jQuery( function( $ ) {
// Generated by CoffeeScript 1.7.1
(function() {
var cardFromNumber, cardFromType, cards, defaultFormat, formatBackCardNumber, formatBackExpiry, formatCardNumber, formatExpiry, formatForwardExpiry, formatForwardSlashAndSpace, hasTextSelected, luhnCheck, reFormatCVC, reFormatCardNumber, reFormatExpiry, reFormatNumeric, replaceFullWidthChars, restrictCVC, restrictCardNumber, restrictExpiry, restrictNumeric, safeVal, setCardType,
File jquery.prettyPhoto.js
has 611 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* ------------------------------------------------------------------------
Class: prettyPhoto
Use: Lightbox clone for jQuery
Author: Stephane Caron (http://www.no-margin-for-errors.com)
Version: 3.1.6
File class-wc-admin-post-types.php
has 610 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Post Types Admin
*
* @package WooCommerce\Admin
Method save_product_meta
has 262 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function save_product_meta( $product, $data ) {
global $wpdb;
// Virtual.
if ( isset( $data['virtual'] ) ) {
Method save_product_meta
has 258 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function save_product_meta( $product, $data ) {
global $wpdb;
// Virtual
if ( isset( $data['virtual'] ) ) {
Function prepare_object_for_database
has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring. Open
protected function prepare_object_for_database( $request, $creating = false ) {
if ( isset( $request['id'] ) ) {
$variation = wc_get_product( absint( $request['id'] ) );
} else {
$variation = new WC_Product_Variation();
- 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 prepare_object_for_database
has 256 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function prepare_object_for_database( $request, $creating = false ) {
$id = isset( $request['id'] ) ? absint( $request['id'] ) : 0;
// Type is the most important part here because we need to be using the correct class and methods.
if ( isset( $request['type'] ) ) {
Function get_product_data
has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring. Open
protected function get_product_data( $product, $context = 'view' ) {
/*
* @param WP_REST_Request $request Current request object. For backward compatibility, we pass this argument silently.
*
* TODO: Refactor to fix this behavior when DI gets included to make it obvious and clean.
- 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 add-to-cart-variation.js
has 582 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*global wc_add_to_cart_variation_params */
;(function ( $, window, document, undefined ) {
/**
* VariationForm class which handles variation forms and attributes.
*/
File class-wc-admin-list-table-orders.php
has 576 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* List tables: orders.
*
* @package WooCommerce\Admin
Method get_item_schema
has 244 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_item_schema() {
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'customer',
'type' => 'object',
Function _setup_segments
has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring. Open
private function _setup_segments() {
$this->databaseType = self::GEOIP_COUNTRY_EDITION;
$this->record_length = self::STANDARD_RECORD_LENGTH;
if ( $this->flags & self::GEOIP_SHARED_MEMORY ) {
- 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 add_to_cart
has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring. Open
public function add_to_cart( $product_id = 0, $quantity = 1, $variation_id = 0, $variation = array(), $cart_item_data = array() ) {
try {
$product_id = absint( $product_id );
$variation_id = absint( $variation_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 checkout.js
has 568 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* global wc_checkout_params */
jQuery( function( $ ) {
// wc_checkout_params is required to continue, ensure the object exists
if ( typeof wc_checkout_params === 'undefined' ) {