kilbot/WooCommerce-POS

View on GitHub

Showing 57 of 63 total issues

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

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

                  private function add_pos_capability( $roles ) {
              
                      foreach ( $roles as $slug => $caps ) {
                          $role = get_role( $slug );
                          if ( $role ) {
              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 order_add_product has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function order_add_product( $order_id, $item_id, $product, $qty, $args ) {
              
                      $id = isset( $product->id ) ? $product->id : false;
                      $id = isset( $product->variation_id ) ? $product->variation_id : $id;
              
              
              Severity: Minor
              Found in includes/api/legacy/orders.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 set_customer_roles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function set_customer_roles( \WP_User_Query $WP_User_Query ) {
                      global $wp_version;
              
                      $WP_User_Query->query_vars['role'] = '';
              
              
              Severity: Minor
              Found in includes/api/legacy/customers.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