kilbot/WooCommerce-POS

View on GitHub

Showing 63 of 63 total issues

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

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

                foreach ( $buttons as $button ):
                    $href = isset( $button['href'] ) ? $button['href'] : '#';
                    $action = isset( $button['action'] ) ? 'data-action="' . esc_attr( $button['action'] ) . '"' : '';
                    $prompt = isset( $button['prompt'] ) ? $button['prompt'] : '';
                    ?>
    Severity: Major
    Found in includes/views/support/tmpl-status.php and 1 other location - About 1 hr to fix
    includes/admin/settings/views/status.php on lines 34..41

    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 110.

    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

                    foreach ( $buttons as $button ):
                        $href = isset( $button['href'] ) ? $button['href'] : '#';
                        $action = isset( $button['action'] ) ? 'data-action="' . esc_attr( $button['action'] ) . '"' : '';
                        $prompt = isset( $button['prompt'] ) ? $button['prompt'] : '';
                        ?>
    Severity: Major
    Found in includes/admin/settings/views/status.php and 1 other location - About 1 hr to fix
    includes/views/support/tmpl-status.php on lines 20..27

    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 110.

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

        Method get_receipt_template has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function get_receipt_template() {
                $this->register_receipt_status();
        
                $settings = wcpos_get_option( 'receipts', 'receipt_options' );
                $type     = isset( $settings['template_language'] ) ? $settings['template_language'] : 'html';
        Severity: Minor
        Found in includes/api/legacy/templates.php - About 1 hr to fix

          Method save_post has 32 lines of code (exceeds 25 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

            Method menu has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function menu() {
            
                    return apply_filters( 'woocommerce_pos_menu', array(
                        array(
                            'id'    => 'pos',
            Severity: Minor
            Found in includes/api/legacy/params.php - About 1 hr to fix

              Method update_post_metadata has 32 lines of code (exceeds 25 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 1 hr to fix

                Function delete has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function delete() {
                        global $wp_roles;
                
                        $roles = $wp_roles->roles;
                        $caps  = array_merge( $this->caps['pos'], $this->caps['woo'] );
                Severity: Minor
                Found in includes/admin/settings/access.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 update_check has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function update_check( $transient, $force = false ) {
                        $locale = get_locale();
                
                        // pre_set_site_transient_update_plugins is called twice
                        // we only want to act on the second run
                Severity: Minor
                Found in includes/i18n.php - About 1 hr to fix

                  Function meta_box has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    function meta_box(){
                      var display = $('#pos-visibility-display'),
                          show = $('#pos-visibility-show'),
                          select = $('#pos-visibility-select'),
                          cancel = $('#pos-visibility-cancel'),
                  Severity: Minor
                  Found in assets/js/src/products.js - About 1 hr to fix

                    Method create_order_data has 30 lines of code (exceeds 25 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

                      Method get_external_library_locale_js has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          static public function get_external_library_locale_js( $library = '', $version = '' ) {
                              $cdnjs_url = $locale_js = '';
                      
                              switch ( $library ) {
                                  case 'select2':
                      Severity: Minor
                      Found in includes/i18n.php - About 1 hr to fix

                        Method get_settings_handler has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function get_settings_handler( $id ) {
                        
                                if ( ! $id ) {
                                    return new \WP_Error(
                                        'woocommerce_pos_settings_error',
                        Severity: Minor
                        Found in includes/api/legacy/settings.php - About 1 hr to fix

                          Method pos_visibility_filters has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function pos_visibility_filters( $views ) {
                                  global $wpdb;
                          
                                  $visibility_filters = array(
                                      // 'pos_and_online' => __( 'POS & Online', 'woocommerce-pos' ),
                          Severity: Minor
                          Found in includes/products/visibility.php - About 1 hr to fix

                            Function complex_search has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private function complex_search( array $queries, \WP_User_Query $WP_User_Query ) {
                                    $include = array();
                            
                                    foreach ( $queries as $query ) {
                                        $type = isset( $query['type'] ) ? $query['type'] : '';
                            Severity: Minor
                            Found in includes/api/legacy/customers.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

                            Function get_external_library_locale_js has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                                static public function get_external_library_locale_js( $library = '', $version = '' ) {
                                    $cdnjs_url = $locale_js = '';
                            
                                    switch ( $library ) {
                                        case 'select2':
                            Severity: Minor
                            Found in includes/i18n.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

                            Function activate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function activate( $network_wide ) {
                                    if ( function_exists( 'is_multisite' ) && is_multisite() ) {
                            
                                        if ( $network_wide ) {
                            
                            
                            Severity: Minor
                            Found in includes/activator.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

                            Severity
                            Category
                            Status
                            Source
                            Language