woocommerce/woocommerce

View on GitHub

Showing 3,141 of 4,341 total issues

Function output has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function output( $atts ) {
        if ( ! apply_filters( 'woocommerce_output_cart_shortcode_content', true ) ) {
            return;
        }

Severity: Minor
Found in includes/shortcodes/class-wc-shortcode-cart.php - About 25 mins to fix

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 wc_change_get_terms_defaults has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function wc_change_get_terms_defaults( $defaults, $taxonomies ) {
    if ( is_array( $taxonomies ) && 1 < count( $taxonomies ) ) {
        return $defaults;
    }
    $taxonomy = is_array( $taxonomies ) ? (string) current( $taxonomies ) : $taxonomies;
Severity: Minor
Found in includes/wc-term-functions.php - About 25 mins to fix

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_received has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function order_received( $order_id = 0 ) {
        $order = false;

        // Get the order.
        $order_id  = apply_filters( 'woocommerce_thankyou_order_id', absint( $order_id ) );
Severity: Minor
Found in includes/shortcodes/class-wc-shortcode-checkout.php - About 25 mins to fix

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_zone_by has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function get_zone_by( $by = 'zone_id', $id = 0 ) {
        $zone_id = false;

        switch ( $by ) {
            case 'zone_id':
Severity: Minor
Found in includes/class-wc-shipping-zones.php - About 25 mins to fix

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 wc_track_product_view has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function wc_track_product_view() {
    if ( ! is_singular( 'product' ) || ! is_active_widget( false, false, 'woocommerce_recently_viewed_products', true ) ) {
        return;
    }

Severity: Minor
Found in includes/wc-product-functions.php - About 25 mins to fix

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_tokens has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function get_tokens( $args ) {
        $args = wp_parse_args(
            $args,
            array(
                'token_id'   => '',
Severity: Minor
Found in includes/class-wc-payment-tokens.php - About 25 mins to fix

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_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function update_attributes( &$product, $force = false ) {
        $changes = $product->get_changes();

        if ( $force || array_key_exists( 'attributes', $changes ) ) {
            global $wpdb;
Severity: Minor
Found in includes/data-stores/class-wc-product-variation-data-store-cpt.php - About 25 mins to fix

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 checkout has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function checkout() {
        // Show non-cart errors.
        do_action( 'woocommerce_before_checkout_form_cart_notices' );

        // Check cart has contents.
Severity: Minor
Found in includes/shortcodes/class-wc-shortcode-checkout.php - About 25 mins to fix

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 load_shipping_methods has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function load_shipping_methods( $package = array() ) {
        if ( ! empty( $package ) ) {
            $debug_mode             = 'yes' === get_option( 'woocommerce_shipping_debug_mode', 'no' );
            $shipping_zone          = WC_Shipping_Zones::get_zone_matching_package( $package );
            $this->shipping_methods = $shipping_zone->get_shipping_methods( true );
Severity: Minor
Found in includes/class-wc-shipping.php - About 25 mins to fix

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 is_customer_outside_base has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function is_customer_outside_base() {
        list( $country, $state ) = $this->get_taxable_address();
        if ( $country ) {
            $default = wc_get_base_location();
            if ( $default['country'] !== $country ) {
Severity: Minor
Found in includes/class-wc-customer.php - About 25 mins to fix

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 task has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function task( $callback ) {
        if ( isset( $callback['filter'], $callback['args'] ) ) {
            try {
                WC_Emails::send_queued_transactional_email( $callback['filter'], $callback['args'] );
            } catch ( Exception $e ) {
Severity: Minor
Found in includes/class-wc-background-emailer.php - About 25 mins to fix

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_breadcrumblist_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function generate_breadcrumblist_data( $breadcrumbs ) {
        $crumbs = $breadcrumbs->get_breadcrumb();

        if ( empty( $crumbs ) || ! is_array( $crumbs ) ) {
            return;
Severity: Minor
Found in includes/class-wc-structured-data.php - About 25 mins to fix

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 offsetSet has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function offsetSet( $offset, $value ) {
        wc_deprecated_function( 'WC_Order_Item_Product::offsetSet', '4.4.0', '' );
        if ( 'line_subtotal' === $offset ) {
            $offset = 'subtotal';
        } elseif ( 'line_subtotal_tax' === $offset ) {
Severity: Minor
Found in includes/class-wc-order-item-product.php - About 25 mins to fix

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_customer_personal_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected static function get_customer_personal_data( $user ) {
        $personal_data = array();
        $customer      = new WC_Customer( $user->ID );

        if ( ! $customer ) {
Severity: Minor
Found in includes/class-wc-privacy-exporters.php - About 25 mins to fix

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_items has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_items( $request ) {
        $args            = array();
        $args['order']   = $request['order'];
        $args['orderby'] = $request['orderby'];
        $args['status']  = 'all' === $request['status'] ? '' : $request['status'];

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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function update() {
        $current_db_version = get_option( 'woocommerce_db_version' );
        $loop               = 0;

        foreach ( self::get_db_update_callbacks() as $version => $update_callbacks ) {
Severity: Minor
Found in includes/class-wc-install.php - About 25 mins to fix

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_order has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function update_order( $request ) {
        try {
            $order = $this->prepare_item_for_database( $request );
            $order->save();

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 create_item has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function create_item( $request ) {
        if ( ! empty( $request['id'] ) ) {
            /* translators: %s: post type */
            return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) );
        }

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 prepare_item_for_database has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function prepare_item_for_database( $request ) {
        $data = new stdClass;

        // Post ID.
        if ( isset( $request['id'] ) ) {

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 delete_refund has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function delete_refund() {
        check_ajax_referer( 'order-item', 'security' );

        if ( ! current_user_can( 'edit_shop_orders' ) || ! isset( $_POST['refund_id'] ) ) {
            wp_die( -1 );
Severity: Minor
Found in includes/class-wc-ajax.php - About 25 mins to fix

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

Severity
Category
Status
Source
Language