woocommerce/woocommerce

View on GitHub

Showing 3,141 of 4,341 total issues

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

    protected function create_order( $request ) {
        try {
            // Make sure customer exists.
            if ( ! is_null( $request['customer_id'] ) && 0 !== $request['customer_id'] && false === get_user_by( 'id', $request['customer_id'] ) ) {
                throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id',__( 'Customer ID is invalid.', 'woocommerce' ), 400 );
Severity: Minor
Found in includes/legacy/api/class-wc-rest-legacy-orders-controller.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/v2/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_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/v2/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/v1/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 check_permission has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function check_permission( $post, $context ) {

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

        public function trigger( $user_login = '', $reset_key = '' ) {
            $this->setup_locale();

            if ( $user_login && $reset_key ) {
                $this->object     = get_user_by( 'login', $user_login );
Severity: Minor
Found in includes/emails/class-wc-email-customer-reset-password.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 ) {
        if ( 'item_meta_array' === $offset ) {
            foreach ( $value as $meta_id => $meta ) {
                $this->update_meta_data( $meta->key, $meta->value, $meta_id );
            }
Severity: Minor
Found in includes/class-wc-order-item.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 calc_inclusive_tax has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function calc_inclusive_tax( $price, $rates ) {
        $taxes          = array();
        $compound_rates = array();
        $regular_rates  = array();

Severity: Minor
Found in includes/class-wc-tax.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/v2/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 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();

Severity: Minor
Found in includes/legacy/api/class-wc-rest-legacy-orders-controller.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_order has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_order( $id, $fields = null ) {

        // ensure order ID is valid & user has permission to read
        $id = $this->validate_request( $id, 'shop_order', 'read' );

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

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

        if ( $data instanceof WC_Webhook ) {
            $this->set_id( absint( $data->get_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 find_shipping_rates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function find_shipping_rates( $args = array() ) {
        $rates          = self::find_rates( $args );
        $shipping_rates = array();

        if ( is_array( $rates ) ) {
Severity: Minor
Found in includes/class-wc-tax.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_customers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function query_customers( $args = array() ) {

        // default users per page
        $users_per_page = get_option( 'posts_per_page' );

Severity: Minor
Found in includes/legacy/api/v1/class-wc-api-customers.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/v2/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 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/v2/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 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/v1/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 should_rotate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function should_rotate( $handle ) {
        $file = self::get_log_file_path( $handle );
        if ( $file ) {
            if ( $this->is_open( $handle ) ) {
                $file_stat = fstat( $this->handles[ $handle ] );
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 get_wp_api_payload has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function get_wp_api_payload( $resource, $resource_id, $event ) {
        switch ( $resource ) {
            case 'coupon':
            case 'customer':
            case 'order':
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

Severity
Category
Status
Source
Language