kilbot/WooCommerce-POS

View on GitHub

Showing 63 of 63 total issues

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

    public function deactivate( $network_wide ) {

        if ( function_exists( 'is_multisite' ) && is_multisite() ) {

            if ( $network_wide ) {
Severity: Minor
Found in includes/deactivator.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 simple_search has a Cognitive Complexity of 8 (exceeds 5 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 45 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_note_data has a Cognitive Complexity of 8 (exceeds 5 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 45 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 order_add_product has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function order_add_product( $order_id, $item_id, $product, $qty, $args ) {
Severity: Minor
Found in includes/api/legacy/orders.php - About 35 mins to fix

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

        public function update_post_metadata( $null, $order_id, $meta_key, $meta_value, $prev_value ) {
    Severity: Minor
    Found in includes/api/legacy/orders.php - About 35 mins to fix

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

          public function load_enabled_gateways() {
              $gateways         = $this->load_gateways();
              $enabled          = $this->get_enabled_gateway_ids();
              $default          = $this->get( 'default_gateway' );
              $enabled_gateways = array();
      Severity: Minor
      Found in includes/admin/settings/checkout.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

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

          public function process_payment( $order_id, $data ) {
      
              if ( ! isset( $data['payment_details'] ) ) {
                  return;
              }
      Severity: Minor
      Found in includes/api/legacy/orders.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

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

          public function order_add_shipping( $order_id, $item_id, $rate ) {
              $shipping_line = $this->get_shipping_line( $rate, $item_id );
      
              if ( $shipping_line && isset( $shipping_line['tax'] ) ) {
                  $taxes = array();
      Severity: Minor
      Found in includes/api/legacy/orders.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

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

          public function get_settings( $id = '', $wcpos_admin = null, $defaults = false ) {
      
              // @todo remove this special hack for 'restore default settings'
              if ( $defaults ) {
                  return $this->delete_settings( $id );
      Severity: Minor
      Found in includes/api/legacy/settings.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

      Avoid too many return statements within this method.
      Open

              return new \WP_Error(
                  'woocommerce_pos_settings_error',
                  sprintf( __( 'No handler found for %s settings', 'woocommerce-pos' ), $id ),
                  array( 'status' => 400 )
              );
      Severity: Major
      Found in includes/api/legacy/settings.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return;
        Severity: Major
        Found in includes/products/visibility.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return;
          Severity: Major
          Found in includes/products/visibility.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return;
            Severity: Major
            Found in includes/products/visibility.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return;
              Severity: Major
              Found in includes/products/visibility.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return $transient;
                Severity: Major
                Found in includes/i18n.php - About 30 mins to fix

                  Function init has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function init() {
                          // Check for min requirements to run
                          if ( $this->php_check() && $this->woocommerce_check() ) {
                  
                              // check permalinks
                  Severity: Minor
                  Found in includes/activator.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_check has a Cognitive Complexity of 6 (exceeds 5 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 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 admin_notices has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function admin_notices() {
                          $notices = apply_filters( 'woocommerce_pos_admin_notices', self::$notices );
                          if ( empty( $notices ) ) {
                              return;
                          }
                  Severity: Minor
                  Found in includes/admin/notices.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_settings_handler has a Cognitive Complexity of 6 (exceeds 5 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 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 remove_pos_capability has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      static private function remove_pos_capability() {
                          $roles = array( 'administrator', 'shop_manager' );
                          $caps  = array( 'manage_woocommerce_pos', 'access_woocommerce_pos' );
                          foreach ( $roles as $slug ) :
                              $role = get_role( $slug );
                  Severity: Minor
                  Found in includes/deactivator.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