woocommerce/woocommerce

View on GitHub

Showing 3,141 of 4,341 total issues

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

function wc_update_450_sanitize_coupons_code() {
    global $wpdb;

    $coupon_id      = 0;
    $last_coupon_id = get_option( 'woocommerce_update_450_last_coupon_id', '0' );
Severity: Minor
Found in includes/wc-update-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_availability_text has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function get_availability_text() {
        if ( ! $this->is_in_stock() ) {
            $availability = __( 'Out of stock', 'woocommerce' );
        } elseif ( $this->managing_stock() && $this->is_on_backorder( 1 ) ) {
            $availability = $this->backorders_require_notification() ? __( 'Available on backorder', 'woocommerce' ) : '';
Severity: Minor
Found in includes/abstracts/abstract-wc-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 is_available has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function is_available( $package ) {
        $available = $this->is_enabled();

        // Country availability (legacy, for non-zone based methods).
        if ( ! $this->instance_id && $available ) {
Severity: Minor
Found in includes/abstracts/abstract-wc-shipping-method.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 price_filter_post_clauses has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function price_filter_post_clauses( $args, $wp_query ) {
        global $wpdb;

        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
        if ( ! $wp_query->is_main_query() || ( ! isset( $_GET['max_price'] ) && ! isset( $_GET['min_price'] ) ) ) {
Severity: Minor
Found in includes/class-wc-query.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_cross_sells has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_cross_sells() {
        $cross_sells = array();
        $in_cart     = array();
        if ( ! $this->is_empty() ) {
            foreach ( $this->get_cart() as $cart_item_key => $values ) {
Severity: Minor
Found in includes/class-wc-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 join_with_equals_sign has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function join_with_equals_sign( $params, $query_params = array(), $key = '' ) {
        foreach ( $params as $param_key => $param_value ) {
            if ( $key ) {
                $param_key = $key . '%5B' . $param_key . '%5D'; // Handle multi-dimensional array.
            }
Severity: Minor
Found in includes/class-wc-rest-authentication.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 check_permissions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function check_permissions( $method ) {
        $permissions = $this->user->permissions;

        switch ( $method ) {
            case 'HEAD':
Severity: Minor
Found in includes/class-wc-rest-authentication.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_update_220_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function wc_update_220_attributes() {
    global $wpdb;
    // Update taxonomy names with correct sanitized names.
    $attribute_taxonomies = $wpdb->get_results( 'SELECT attribute_name, attribute_id FROM ' . $wpdb->prefix . 'woocommerce_attribute_taxonomies' );

Severity: Minor
Found in includes/wc-update-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 download_database has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function download_database( $license_key ) {
        $download_uri = add_query_arg(
            array(
                'edition_id'  => self::DATABASE,
                'license_key' => urlencode( wc_clean( $license_key ) ),

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

    public function get_product_category( $id, $fields = null ) {
        try {
            $id = absint( $id );

            // Validate ID
Severity: Minor
Found in includes/legacy/api/v3/class-wc-api-products.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_coupon has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function update_coupon( $item, $args ) {
        wc_deprecated_function( 'WC_Order::update_coupon', '3.0', 'an interaction with the WC_Order_Item_Coupon class' );
        if ( is_numeric( $item ) ) {
            $item = $this->get_item( $item );
        }
Severity: Minor
Found in includes/legacy/abstract-wc-legacy-order.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_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function get_attributes( $product ) {

        $attributes = array();

        if ( $product->is_type( 'variation' ) ) {
Severity: Minor
Found in includes/legacy/api/v3/class-wc-api-products.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 check_permission has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function check_permission( $post, $context ) {
        $permission = false;

        if ( ! is_a( $post, 'WP_Post' ) ) {
            $post = get_post( $post );
Severity: Minor
Found in includes/legacy/api/v3/class-wc-api-resource.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_save_product_price has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function _wc_save_product_price( $product_id, $regular_price, $sale_price = '', $date_from = '', $date_to = '' ) {
    wc_doing_it_wrong( '_wc_save_product_price()', 'This function is not for developer use and is deprecated.', '3.0' );

    $product_id    = absint( $product_id );
    $regular_price = wc_format_decimal( $regular_price );
Severity: Minor
Found in includes/wc-deprecated-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 tracks_coupons_events has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function tracks_coupons_events() {
        if ( isset( $_GET['post_type'] ) && 'shop_coupon' === $_GET['post_type'] ) {

            $this->tracks_coupons_bulk_actions();

Severity: Minor
Found in includes/tracks/events/class-wc-coupons-tracking.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 check_api_key_permissions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function check_api_key_permissions( $key_permissions ) {
        switch ( WC()->api->server->method ) {

            case 'HEAD':
            case 'GET':
Severity: Minor
Found in includes/legacy/api/v3/class-wc-api-authentication.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_product_attribute_term has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_product_attribute_term( $attribute_id, $id, $fields = null ) {
        global $wpdb;

        try {
            $id = absint( $id );
Severity: Minor
Found in includes/legacy/api/v3/class-wc-api-products.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 delete_version_transients has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function delete_version_transients( $version = '' ) {
        if ( ! wp_using_ext_object_cache() && ! empty( $version ) ) {
            global $wpdb;

            $limit = apply_filters( 'woocommerce_delete_version_transients_limit', 1000 );
Severity: Minor
Found in includes/class-wc-cache-helper.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 __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct( $path ) {

        if ( empty( $path ) ) {
            if ( isset( $_SERVER['PATH_INFO'] ) ) {
                $path = $_SERVER['PATH_INFO'];
Severity: Minor
Found in includes/legacy/api/v3/class-wc-api-server.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 delete_order_note has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function delete_order_note( $order_id, $id ) {
        try {
            $order_id = $this->validate_request( $order_id, $this->post_type, 'delete' );

            if ( is_wp_error( $order_id ) ) {
Severity: Minor
Found in includes/legacy/api/v3/class-wc-api-orders.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