woocommerce/woocommerce

View on GitHub

Showing 3,141 of 4,341 total issues

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

    private static function _helper_plugin_deactivate() {
        $product_id  = isset( $_GET['wc-helper-product-id'] ) ? absint( $_GET['wc-helper-product-id'] ) : 0;
        $deactivated = false;

        if ( empty( $_GET['wc-helper-nonce'] ) || ! wp_verify_nonce( wp_unslash( $_GET['wc-helper-nonce'] ), 'deactivate-plugin:' . $product_id ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
Severity: Minor
Found in includes/admin/helper/class-wc-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 notices has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function notices() {
        if ( isset( $_GET['deleted'] ) ) { // WPCS: input var okay, CSRF ok.
            $deleted = absint( $_GET['deleted'] ); // WPCS: input var okay, CSRF ok.

            /* translators: %d: count */
Severity: Minor
Found in includes/admin/class-wc-admin-webhooks.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 process_admin_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function process_admin_options() {
        $this->init_settings();

        $post_data = $this->get_post_data();

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

    public function actions() {
        if ( $this->is_webhook_settings_page() ) {
            // Save.
            if ( isset( $_POST['save'] ) && isset( $_POST['webhook_id'] ) ) { // WPCS: input var okay, CSRF ok.
                $this->save();
Severity: Minor
Found in includes/admin/class-wc-admin-webhooks.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 setup_screen has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function setup_screen() {
        global $wc_list_table;

        $request_data = $this->request_data();

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

    public function do_ajax_product_import() {
        global $wpdb;

        check_ajax_referer( 'wc-product-import', 'security' );

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

    public static function get_sections() {
        $addon_sections = get_transient( 'wc_addons_sections' );
        if ( false === ( $addon_sections ) ) {
            $raw_sections = wp_safe_remote_get(
                'https://woocommerce.com/wp-json/wccom-extensions/1.0/categories'
Severity: Minor
Found in includes/admin/class-wc-admin-addons.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_wp_textarea_input has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function woocommerce_wp_textarea_input( $field ) {
    global $thepostid, $post;

    $thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
    $field['placeholder']   = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
Severity: Minor
Found in includes/admin/wc-meta-box-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 prepare_downloads has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function prepare_downloads( $file_names, $file_urls, $file_hashes ) {
        $downloads = array();

        if ( ! empty( $file_urls ) ) {
            $file_url_size = count( $file_urls );
Severity: Minor
Found in includes/admin/meta-boxes/class-wc-meta-box-product-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 admin_redirects has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function admin_redirects() {
        // Don't run this fn from Action Scheduler requests, as it would clear _wc_activation_redirect transient.
        // That means OBW would never be shown.
        if ( wc_is_running_from_async_action_scheduler() ) {
            return;
Severity: Minor
Found in includes/admin/class-wc-admin.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 render_order_number_column has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function render_order_number_column() {
        $buyer = '';

        if ( $this->object->get_billing_first_name() || $this->object->get_billing_last_name() ) {
            /* translators: 1: first name 2: last name */
Severity: Minor
Found in includes/admin/list-tables/class-wc-admin-list-table-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 set_status has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function set_status( $new_status ) {
        $old_status = $this->get_status();
        $new_status = 'wc-' === substr( $new_status, 0, 3 ) ? substr( $new_status, 3 ) : $new_status;

        // If setting the status, ensure it's set to a valid status.
Severity: Minor
Found in includes/abstracts/abstract-wc-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 dupe_link has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function dupe_link( $actions, $post ) {
        global $the_product;

        if ( ! current_user_can( apply_filters( 'woocommerce_duplicate_product_capability', 'manage_woocommerce' ) ) ) {
            return $actions;
Severity: Minor
Found in includes/admin/class-wc-admin-duplicate-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 output_column has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function output_column( $block ) {
        if ( isset( $block->container ) && 'column_container_start' === $block->container ) {
            ?>
            <div class="addons-column-section">
            <?php
Severity: Minor
Found in includes/admin/class-wc-admin-addons.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 __clone has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function __clone() {
        $this->maybe_read_meta_data();
        if ( ! empty( $this->meta_data ) ) {
            foreach ( $this->meta_data as $array_key => $meta ) {
                $this->meta_data[ $array_key ] = clone $meta;
Severity: Minor
Found in includes/abstracts/abstract-wc-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 bulk_and_quick_edit_save_post has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function bulk_and_quick_edit_save_post( $post_id, $post ) {
        $request_data = $this->request_data();

        // If this is an autosave, our form has not been submitted, so we don't want to do anything.
        if ( Constants::is_true( 'DOING_AUTOSAVE' ) ) {
Severity: Minor
Found in includes/admin/class-wc-admin-post-types.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 output_wcs_banner_block has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function output_wcs_banner_block( $block = array() ) {
        $is_active = is_plugin_active( 'woocommerce-services/woocommerce-services.php' );
        $location  = wc_get_base_location();

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

function woocommerce_wp_checkbox( $field ) {
    global $thepostid, $post;

    $thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
    $field['class']         = isset( $field['class'] ) ? $field['class'] : 'checkbox';
Severity: Minor
Found in includes/admin/wc-meta-box-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 __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct( $order = 0 ) {
        parent::__construct( $order );

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

    public function get_items( $types = 'line_item' ) {
        $items = array();
        $types = array_filter( (array) $types );

        foreach ( $types as $type ) {
Severity: Minor
Found in includes/abstracts/abstract-wc-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

Severity
Category
Status
Source
Language