woothemes/woocommerce

View on GitHub
includes/class-wc-post-data.php

Summary

Maintainability
C
1 day
Test Coverage

WC_Post_Data has 25 functions (exceeds 20 allowed). Consider refactoring.
Open

class WC_Post_Data {

    /**
     * Editing term.
     *
Severity: Minor
Found in includes/class-wc-post-data.php - About 2 hrs to fix

    File class-wc-post-data.php has 274 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Post Data
     *
     * Standardises certain post data on save.
    Severity: Minor
    Found in includes/class-wc-post-data.php - About 2 hrs to fix

      Method delete_post has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function delete_post( $id ) {
              if ( ! current_user_can( 'delete_posts' ) || ! $id ) {
                  return;
              }
      
      
      Severity: Minor
      Found in includes/class-wc-post-data.php - About 1 hr to fix

        Function delete_post has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function delete_post( $id ) {
                if ( ! current_user_can( 'delete_posts' ) || ! $id ) {
                    return;
                }
        
        
        Severity: Minor
        Found in includes/class-wc-post-data.php - About 1 hr 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 wp_insert_post_data has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function wp_insert_post_data( $data ) {
                if ( 'shop_order' === $data['post_type'] && isset( $data['post_date'] ) ) {
                    $order_title = 'Order';
                    if ( $data['post_date'] ) {
                        $order_title .= ' &ndash; ' . date_i18n( 'F j, Y @ h:i A', strtotime( $data['post_date'] ) );
        Severity: Minor
        Found in includes/class-wc-post-data.php - About 55 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

        Method set_object_terms has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public static function set_object_terms( $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ) {
        Severity: Minor
        Found in includes/class-wc-post-data.php - About 45 mins to fix

          Method update_order_item_metadata has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public static function update_order_item_metadata( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
          Severity: Minor
          Found in includes/class-wc-post-data.php - About 35 mins to fix

            Method update_post_metadata has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public static function update_post_metadata( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
            Severity: Minor
            Found in includes/class-wc-post-data.php - About 35 mins to fix

              Method force_default_term has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public static function force_default_term( $object_id, $terms, $tt_ids, $taxonomy, $append ) {
              Severity: Minor
              Found in includes/class-wc-post-data.php - About 35 mins to fix

                Function before_delete_order has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function before_delete_order( $order_id ) {
                        if ( in_array( get_post_type( $order_id ), wc_get_order_types(), true ) ) {
                            // Clean up user.
                            $order = wc_get_order( $order_id );
                
                
                Severity: Minor
                Found in includes/class-wc-post-data.php - About 35 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

                There are no issues that match your filters.

                Category
                Status