woocommerce/woocommerce

View on GitHub

Showing 4,341 of 4,341 total issues

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

    protected static function format_entry( $timestamp, $level, $message, $context ) {

        if ( isset( $context['_legacy'] ) && true === $context['_legacy'] ) {
            if ( isset( $context['source'] ) && $context['source'] ) {
                $handle = $context['source'];
Severity: Minor
Found in includes/log-handlers/class-wc-log-handler-file.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 log_delivery has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function log_delivery( $delivery_id, $request, $response, $duration ) {
        $logger  = wc_get_logger();
        $message = array(
            'Webhook Delivery' => array(
                'Delivery ID' => $delivery_id,
Severity: Minor
Found in includes/class-wc-webhook.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_type_of_file_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_type_of_file_path( $file_path = '' ) {
        $file_path = $file_path ? $file_path : $this->get_file();
        $parsed_url = parse_url( $file_path );
        if (
            $parsed_url &&
Severity: Minor
Found in includes/class-wc-product-download.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( $download_log = 0 ) {
        parent::__construct( $download_log );

        if ( is_numeric( $download_log ) && $download_log > 0 ) {
            $this->set_id( $download_log );
Severity: Minor
Found in includes/class-wc-customer-download-log.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 create_order_shipping_lines has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function create_order_shipping_lines( &$order, $chosen_shipping_methods, $packages ) {
        foreach ( $packages as $package_key => $package ) {
            if ( isset( $chosen_shipping_methods[ $package_key ], $package['rates'][ $chosen_shipping_methods[ $package_key ] ] ) ) {
                $shipping_rate            = $package['rates'][ $chosen_shipping_methods[ $package_key ] ];
                $item                     = new WC_Order_Item_Shipping();
Severity: Minor
Found in includes/class-wc-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 download_headers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function download_headers( $file_path, $filename, $download_range = array() ) {
        self::check_server_config();
        self::clean_buffers();
        wc_nocache_headers();

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

    protected function delete_template_action( $template_type ) {
        $template = $this->get_template( $template_type );

        if ( $template ) {
            if ( ! empty( $template ) ) {
Severity: Minor
Found in includes/emails/class-wc-email.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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function update( &$webhook ) {
        global $wpdb;

        $changes = $webhook->get_changes();
        $trigger = isset( $changes['delivery_url'] );
Severity: Minor
Found in includes/data-stores/class-wc-webhook-data-store.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_file_xsendfile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function download_file_xsendfile( $file_path, $filename ) {
        $parsed_file_path = self::parse_file_path( $file_path );

        /**
         * Fallback on force download method for remote files. This is because:
Severity: Minor
Found in includes/class-wc-download-handler.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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function delete( &$zone, $args = array() ) {
        $zone_id = $zone->get_id();

        if ( $zone_id ) {
            global $wpdb;
Severity: Minor
Found in includes/data-stores/class-wc-shipping-zone-data-store.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 woocommerce_taxonomy_archive_description has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    function woocommerce_taxonomy_archive_description() {
        if ( is_product_taxonomy() && 0 === absint( get_query_var( 'paged' ) ) ) {
            $term = get_queried_object();

            if ( $term && ! empty( $term->description ) ) {
Severity: Minor
Found in includes/wc-template-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 decode_json has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function decode_json( $arr ) {
        foreach ( $arr as $key => $value ) {
            if ( '[' === substr( $value, 0, 1 ) || '{' === substr( $value, 0, 1 ) ) {
                $arr[ $key ] = json_decode( $value, true );
            } else {
Severity: Minor
Found in includes/cli/class-wc-cli-rest-command.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_file_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function parse_file_path( $file_path ) {
        $wp_uploads     = wp_upload_dir();
        $wp_uploads_dir = $wp_uploads['basedir'];
        $wp_uploads_url = $wp_uploads['baseurl'];

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

    public function find_shipping_classes( $package ) {
        $found_shipping_classes = array();

        foreach ( $package['contents'] as $item_id => $values ) {
            if ( $values['data']->needs_shipping() ) {
Severity: Minor
Found in includes/shipping/flat-rate/class-wc-shipping-flat-rate.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_session has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_session( $customer_id, $default = false ) {
        global $wpdb;

        if ( Constants::is_defined( 'WP_SETUP_CONFIG' ) ) {
            return false;
Severity: Minor
Found in includes/class-wc-session-handler.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 api_request_url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function api_request_url( $request, $ssl = null ) {
        if ( is_null( $ssl ) ) {
            $scheme = wp_parse_url( home_url(), PHP_URL_SCHEME );
        } elseif ( $ssl ) {
            $scheme = 'https';
Severity: Minor
Found in includes/class-woocommerce.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 find_shipping_classes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function find_shipping_classes( $package ) {
        $found_shipping_classes = array();

        foreach ( $package['contents'] as $item_id => $values ) {
            if ( $values['data']->needs_shipping() ) {

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

    public function get_item( $args, $assoc_args ) {
        $route                           = $this->get_filled_route( $args );
        list( $status, $body, $headers ) = $this->do_request( 'GET', $route, $assoc_args );

        if ( ! empty( $assoc_args['fields'] ) ) {
Severity: Minor
Found in includes/cli/class-wc-cli-rest-command.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 query has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function query( $query_vars ) {
        $args = $this->get_wp_query_args( $query_vars );

        if ( ! empty( $args['errors'] ) ) {
            $query = (object) array(
Severity: Minor
Found in includes/data-stores/class-wc-order-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 get_related_products_query has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_related_products_query( $cats_array, $tags_array, $exclude_ids, $limit ) {
        global $wpdb;

        $include_term_ids            = array_merge( $cats_array, $tags_array );
        $exclude_term_ids            = array();
Severity: Minor
Found in includes/data-stores/class-wc-product-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

Severity
Category
Status
Source
Language