woothemes/woocommerce

View on GitHub
includes/class-wc-rest-authentication.php

Summary

Maintainability
D
1 day
Test Coverage

File class-wc-rest-authentication.php has 322 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * REST API Authentication
 *
 * @package  WooCommerce\RestApi
Severity: Minor
Found in includes/class-wc-rest-authentication.php - About 3 hrs to fix

    WC_REST_Authentication has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class WC_REST_Authentication {
    
        /**
         * Authentication error.
         *
    Severity: Minor
    Found in includes/class-wc-rest-authentication.php - About 2 hrs to fix

      Method get_oauth_parameters has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function get_oauth_parameters() {
              $params = array_merge( $_GET, $_POST ); // WPCS: CSRF ok.
              $params = wp_unslash( $params );
              $header = $this->get_authorization_header();
      
      
      Severity: Minor
      Found in includes/class-wc-rest-authentication.php - About 1 hr to fix

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

            private function check_oauth_timestamp_and_nonce( $user, $timestamp, $nonce ) {
                global $wpdb;
        
                $valid_window = 15 * 60; // 15 minute window.
        
        
        Severity: Minor
        Found in includes/class-wc-rest-authentication.php - About 1 hr to fix

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

              public function get_oauth_parameters() {
                  $params = array_merge( $_GET, $_POST ); // WPCS: CSRF ok.
                  $params = wp_unslash( $params );
                  $header = $this->get_authorization_header();
          
          
          Severity: Minor
          Found in includes/class-wc-rest-authentication.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 perform_basic_authentication has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              private function perform_basic_authentication() {
                  $this->auth_method = 'basic_auth';
                  $consumer_key      = '';
                  $consumer_secret   = '';
          
          
          Severity: Minor
          Found in includes/class-wc-rest-authentication.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_authorization_header has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function get_authorization_header() {
                  if ( ! empty( $_SERVER['HTTP_AUTHORIZATION'] ) ) {
                      return wp_unslash( $_SERVER['HTTP_AUTHORIZATION'] ); // WPCS: sanitization ok.
                  }
          
          
          Severity: Minor
          Found in includes/class-wc-rest-authentication.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 check_oauth_timestamp_and_nonce has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              private function check_oauth_timestamp_and_nonce( $user, $timestamp, $nonce ) {
                  global $wpdb;
          
                  $valid_window = 15 * 60; // 15 minute window.
          
          
          Severity: Minor
          Found in includes/class-wc-rest-authentication.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 true;
          Severity: Major
          Found in includes/class-wc-rest-authentication.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return $this->user->user_id;
            Severity: Major
            Found in includes/class-wc-rest-authentication.php - About 30 mins to fix

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

                  private function join_with_equals_sign( $params, $query_params = array(), $key = '' ) {
                      foreach ( $params as $param_key => $param_value ) {
                          if ( $key ) {
                              $param_key = $key . '%5B' . $param_key . '%5D'; // Handle multi-dimensional array.
                          }
              Severity: Minor
              Found in includes/class-wc-rest-authentication.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 check_permissions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function check_permissions( $method ) {
                      $permissions = $this->user->permissions;
              
                      switch ( $method ) {
                          case 'HEAD':
              Severity: Minor
              Found in includes/class-wc-rest-authentication.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 parse_header has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function parse_header( $header ) {
                      if ( 'OAuth ' !== substr( $header, 0, 6 ) ) {
                          return array();
                      }
              
              
              Severity: Minor
              Found in includes/class-wc-rest-authentication.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

              There are no issues that match your filters.

              Category
              Status