kilbot/WooCommerce-POS

View on GitHub

Showing 63 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function payment_fields() {
    
            if ( $this->description ) {
                echo '<p>' . wp_kses_post( $this->description ) . '</p>';
            }
    Severity: Major
    Found in includes/gateways/card.php and 1 other location - About 4 hrs to fix
    includes/gateways/cash.php on lines 42..70

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 182.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function payment_fields() {
    
            if ( $this->description ) {
                echo '<p>' . wp_kses_post( $this->description ) . '</p>';
            }
    Severity: Major
    Found in includes/gateways/cash.php and 1 other location - About 4 hrs to fix
    includes/gateways/card.php on lines 43..70

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 182.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  public function __construct() {
                      $this->id          = 'pos_cash';
                      $this->title       = __( 'Cash', 'woocommerce-pos' );
                      $this->description = '';
                      $this->icon        = apply_filters( 'woocommerce_pos_cash_icon', '' );
              Severity: Major
              Found in includes/gateways/cash.php and 1 other location - About 1 hr to fix
              includes/gateways/card.php on lines 24..38

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 118.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  public function __construct() {
                      $this->id          = 'pos_card';
                      $this->title       = __( 'Card', 'woocommerce-pos' );
                      $this->description = '';
                      $this->icon        = apply_filters( 'woocommerce_pos_card_icon', '' );
              Severity: Major
              Found in includes/gateways/card.php and 1 other location - About 1 hr to fix
              includes/gateways/cash.php on lines 24..37

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 118.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              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
                  Severity
                  Category
                  Status
                  Source
                  Language