kilbot/WooCommerce-POS

View on GitHub

Showing 57 of 63 total issues

File orders.php has 545 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * POS Orders Class
 * duck punches the WC REST API
Severity: Major
Found in includes/api/legacy/orders.php - About 1 day to fix

    Orders has 35 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Orders {
    
        /** @var string $base the route base */
        protected $base = '/orders';
    
    
    Severity: Minor
    Found in includes/api/legacy/orders.php - About 4 hrs to fix

      Method prefix_query has 96 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function prefix_query( $prefix, $term, \WP_Query $wp_query ) {
              // store original meta_query
              $meta_query = $wp_query->get( 'meta_query' );
              $tax_query  = $wp_query->get( 'tax_query' );
      
      
      Severity: Major
      Found in includes/api/legacy/products.php - About 3 hrs to fix

        Function update_post_metadata has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            public function update_post_metadata( $null, $order_id, $meta_key, $meta_value, $prev_value ) {
        
                // we want last update to _order_shipping after $order->calculate_taxes()
                // set flag true on first pass
                if ( $meta_key == '_order_shipping_tax' ) {
        Severity: Minor
        Found in includes/api/legacy/orders.php - About 3 hrs 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

        File products.php has 320 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        /**
         * POS Product Class
         * duck punches the WC REST API
        Severity: Minor
        Found in includes/api/legacy/products.php - About 3 hrs to fix

          Function prefix_query has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

              private function prefix_query( $prefix, $term, \WP_Query $wp_query ) {
                  // store original meta_query
                  $meta_query = $wp_query->get( 'meta_query' );
                  $tax_query  = $wp_query->get( 'tax_query' );
          
          
          Severity: Minor
          Found in includes/api/legacy/products.php - About 2 hrs 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_capabilities has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

              private function update_capabilities( array $roles ) {
                  foreach ( $roles as $slug => $array ):
          
                      $role = get_role( $slug );
          
          
          Severity: Minor
          Found in includes/admin/settings/access.php - About 2 hrs 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 enqueue_admin_scripts has 66 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function enqueue_admin_scripts() {
                  global $wp_scripts;
                  $wp_scripts->queue = array();
          
                  // deregister scripts
          Severity: Major
          Found in includes/admin/settings.php - About 2 hrs to fix

            Method manual_update has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function manual_update() {
                    ob_start();
                    $locale = get_locale();
                    $creds  = request_filesystem_credentials( $_GET['security'], '', false, false, null );
            
            
            Severity: Minor
            Found in includes/i18n.php - About 2 hrs to fix

              Function manual_update has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function manual_update() {
                      ob_start();
                      $locale = get_locale();
                      $creds  = request_filesystem_credentials( $_GET['security'], '', false, false, null );
              
              
              Severity: Minor
              Found in includes/i18n.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 is_pos has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  function is_pos( $type = 'all' ) {
              
                      // check query_vars, eg: ?wcpos=1 or /pos rewrite rule
                      if ( $type == 'all' || $type == 'query_var' ) {
                          global $wp;
              Severity: Minor
              Found in includes/wc-pos-functions.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 order_response has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function order_response( $order_data, $order, $fields, $server ) {
              
                      // add cashier data
                      $order_data['cashier'] = $this->add_cashier_details( $order );
              
              
              Severity: Minor
              Found in includes/api/legacy/orders.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 get_variation_option has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function get_variation_option( $product, $attribute, $option ) {
                      $name = $option;
              
                      // taxonomy attributes
                      if ( $attribute['is_taxonomy'] ) {
              Severity: Minor
              Found in includes/api/legacy/products.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

              Method remove_admin_emails has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function remove_admin_emails( WC_Emails $wc_emails ) {
                      // send 'woocommerce_low_stock_notification'
                      // send 'woocommerce_no_stock_notification'
                      // send 'woocommerce_product_on_backorder_notification'
                      remove_action(
              Severity: Minor
              Found in includes/api/legacy/orders.php - About 1 hr to fix

                Function create_order_data has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function create_order_data( array $data ) {
                
                        // add filters & actions for create order
                        add_filter( 'woocommerce_product_tax_class', array( $this, 'product_tax_class' ), 10, 2 );
                        add_filter( 'woocommerce_get_product_from_item', array( $this, 'get_product_from_item' ), 10, 3 );
                Severity: Minor
                Found in includes/api/legacy/orders.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

                Method simple_search has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function simple_search( $term, \WP_User_Query $WP_User_Query ) {
                
                        $fields         = isset( $_GET['filter']['qFields'] ) ? $_GET['filter']['qFields'] : array();
                        $fields         = is_array( $fields ) ? $fields : array( $fields );
                        $search_columns = $meta_query = $user_query_ids = $usermeta_query_ids = array();
                Severity: Minor
                Found in includes/api/legacy/customers.php - About 1 hr to fix

                  Method enqueue_admin_scripts has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function enqueue_admin_scripts() {
                          global $wp_scripts;
                          $wp_scripts->queue = array();
                  
                          // deregister scripts
                  Severity: Minor
                  Found in includes/admin/status.php - About 1 hr to fix

                    Function save_post has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function save_post( $post_id, $post ) {
                    
                            // If this is an autosave, our form has not been submitted, so we don't want to do anything.
                            if ( defined( '\DOING_AUTOSAVE' ) && \DOING_AUTOSAVE ) {
                                return;
                    Severity: Minor
                    Found in includes/products/visibility.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

                    Method create_order_note_data has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        static public function create_order_note_data( $data, $order_id ) {
                            if ( ! isset( $data['email'] ) ) {
                                return $data;
                            }
                    
                    
                    Severity: Minor
                    Found in includes/api/legacy/orders.php - About 1 hr to fix

                      Method order_response has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function order_response( $order_data, $order, $fields, $server ) {
                      
                              // add cashier data
                              $order_data['cashier'] = $this->add_cashier_details( $order );
                      
                      
                      Severity: Minor
                      Found in includes/api/legacy/orders.php - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language