woothemes/woocommerce

View on GitHub

Showing 4,341 of 4,341 total issues

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

    public static function get_order_id( $order ) {
        global $post;

        if ( false === $order && is_a( $post, 'WP_Post' ) && 'shop_order' === get_post_type( $post ) ) {
            return absint( $post->ID );
Severity: Minor
Found in includes/class-wc-order-factory.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_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 init_transactional_emails has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function init_transactional_emails() {
        $email_actions = apply_filters(
            'woocommerce_email_actions',
            array(
                'woocommerce_low_stock',
Severity: Minor
Found in includes/class-wc-emails.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 needs_shipping has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function needs_shipping() {
        if ( ! wc_shipping_enabled() || 0 === wc_get_shipping_method_count( true ) ) {
            return false;
        }
        $needs_shipping = false;
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 get_taxes_total has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_taxes_total( $compound = true, $display = true ) {
        $total = 0;
        $taxes = $this->get_taxes();
        foreach ( $taxes as $key => $tax ) {
            if ( ! $compound && WC_Tax::is_compound( $key ) ) {
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 parse_header has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function parse_header( $header ) {
        if ( 'OAuth ' !== substr( $header, 0, 6 ) ) {
            return 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 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 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 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

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

    public static function maybe_set_identity_cookie() {
        // Do not set on AJAX requests.
        if ( Constants::is_true( 'DOING_AJAX' ) ) {
            return;
        }
Severity: Minor
Found in includes/tracks/class-wc-tracks-client.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 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 _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 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_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

Severity
Category
Status
Source
Language