MinnPost/object-sync-for-salesforce

View on GitHub
classes/class-object-sync-sf-salesforce.php

Summary

Maintainability
F
6 days
Test Coverage

File class-object-sync-sf-salesforce.php has 686 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Authorize and communicate with the Salesforce REST API. This class can make read and write calls to Salesforce, and also cache the responses in WordPress.
 *
 * @class   Object_Sync_Sf_Salesforce
Severity: Major
Found in classes/class-object-sync-sf-salesforce.php - About 1 day to fix

    Function api_http_request has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function api_http_request( $path, $params, $method, $options = array(), $type = 'rest' ) {
            // this merge will override a value in $this->options with the one in $options parameter if there is a matching key.
            $options = array_merge( $this->options, $options );
            $url     = $this->get_api_endpoint( $type ) . $path;
            if ( isset( $options['full_url'] ) && true === $options['full_url'] ) {
    Severity: Minor
    Found in classes/class-object-sync-sf-salesforce.php - About 5 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 http_request has 120 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function http_request( $url, $data, $headers = array(), $method = 'GET', $options = array() ) {
            // Build the request, including path and headers. Internal use.
    
            /**
             * Short-circuits the return value of an HTTP API call.
    Severity: Major
    Found in classes/class-object-sync-sf-salesforce.php - About 4 hrs to fix

      Object_Sync_Sf_Salesforce has 36 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Object_Sync_Sf_Salesforce {
      
          /**
           * Current version of the plugin
           *
      Severity: Minor
      Found in classes/class-object-sync-sf-salesforce.php - About 4 hrs to fix

        Method api_http_request has 103 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function api_http_request( $path, $params, $method, $options = array(), $type = 'rest' ) {
                // this merge will override a value in $this->options with the one in $options parameter if there is a matching key.
                $options = array_merge( $this->options, $options );
                $url     = $this->get_api_endpoint( $type ) . $path;
                if ( isset( $options['full_url'] ) && true === $options['full_url'] ) {
        Severity: Major
        Found in classes/class-object-sync-sf-salesforce.php - About 4 hrs to fix

          Function run_analytics_report has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

              public function run_analytics_report( $id, $async = true, $clear_cache = false, $params = array(), $method = 'GET', $report_cache_expiration = '', $cache_instance = true, $instance_cache_expiration = '' ) {
          
                  $id         = $this->convert_id( $id );
                  $report_url = 'analytics/reports/' . $id . '/instances';
          
          
          Severity: Minor
          Found in classes/class-object-sync-sf-salesforce.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

          Function http_request has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function http_request( $url, $data, $headers = array(), $method = 'GET', $options = array() ) {
                  // Build the request, including path and headers. Internal use.
          
                  /**
                   * Short-circuits the return value of an HTTP API call.
          Severity: Minor
          Found in classes/class-object-sync-sf-salesforce.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

          Method run_analytics_report has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function run_analytics_report( $id, $async = true, $clear_cache = false, $params = array(), $method = 'GET', $report_cache_expiration = '', $cache_instance = true, $instance_cache_expiration = '' ) {
          
                  $id         = $this->convert_id( $id );
                  $report_url = 'analytics/reports/' . $id . '/instances';
          
          
          Severity: Major
          Found in classes/class-object-sync-sf-salesforce.php - About 2 hrs to fix

            Method refresh_token has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function refresh_token() {
                    $refresh_token = $this->get_refresh_token();
                    if ( empty( $refresh_token ) ) {
                        throw new Object_Sync_Sf_Exception( esc_html__( 'There is no refresh token.', 'object-sync-for-salesforce' ) );
                    }
            Severity: Minor
            Found in classes/class-object-sync-sf-salesforce.php - About 1 hr to fix

              Method api_call has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function api_call( $path, $params = array(), $method = 'GET', $options = array(), $type = 'rest' ) {
                      if ( ! $this->get_access_token() ) {
                          $this->refresh_token();
                      }
                      $this->response = $this->api_http_request( $path, $params, $method, $options, $type );
              Severity: Minor
              Found in classes/class-object-sync-sf-salesforce.php - About 1 hr to fix

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

                    public function api_call( $path, $params = array(), $method = 'GET', $options = array(), $type = 'rest' ) {
                        if ( ! $this->get_access_token() ) {
                            $this->refresh_token();
                        }
                        $this->response = $this->api_http_request( $path, $params, $method, $options, $type );
                Severity: Minor
                Found in classes/class-object-sync-sf-salesforce.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 request_token has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function request_token( $code ) {
                        $data = array(
                            'code'          => $code,
                            'grant_type'    => 'authorization_code',
                            'client_id'     => $this->consumer_key,
                Severity: Minor
                Found in classes/class-object-sync-sf-salesforce.php - About 1 hr to fix

                  Function objects has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function objects(
                          $conditions = array(
                              'updateable'  => true,
                              'triggerable' => true,
                          ),
                  Severity: Minor
                  Found in classes/class-object-sync-sf-salesforce.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 run_analytics_report has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public function run_analytics_report( $id, $async = true, $clear_cache = false, $params = array(), $method = 'GET', $report_cache_expiration = '', $cache_instance = true, $instance_cache_expiration = '' ) {
                  Severity: Major
                  Found in classes/class-object-sync-sf-salesforce.php - About 1 hr to fix

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

                        protected function http_request( $url, $data, $headers = array(), $method = 'GET', $options = array() ) {
                    Severity: Minor
                    Found in classes/class-object-sync-sf-salesforce.php - About 35 mins to fix

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

                          public function api_call( $path, $params = array(), $method = 'GET', $options = array(), $type = 'rest' ) {
                      Severity: Minor
                      Found in classes/class-object-sync-sf-salesforce.php - About 35 mins to fix

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

                            public function analytics_api( $name, $id, $route = '', $params = array(), $method = 'GET' ) {
                        Severity: Minor
                        Found in classes/class-object-sync-sf-salesforce.php - About 35 mins to fix

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

                              protected function api_http_request( $path, $params, $method, $options = array(), $type = 'rest' ) {
                          Severity: Minor
                          Found in classes/class-object-sync-sf-salesforce.php - About 35 mins to fix

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

                                public function object_describe( $name, $reset = false ) {
                                    if ( empty( $name ) ) {
                                        return array();
                                    }
                                    $options = array(
                            Severity: Minor
                            Found in classes/class-object-sync-sf-salesforce.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

                            Equals sign not aligned with surrounding assignments; expected 1 space but found 2 spaces
                            Open

                                    $headers  = array(

                            Equals sign not aligned with surrounding assignments; expected 5 spaces but found 6 spaces
                            Open

                                    $url      = $this->login_url . $this->token_path;

                            Equals sign not aligned with surrounding assignments; expected 1 space but found 2 spaces
                            Open

                                    $headers  = array(

                            Equals sign not aligned with surrounding assignments; expected 5 spaces but found 6 spaces
                            Open

                                    $url      = $this->login_url . $this->token_path;

                            Equals sign not aligned correctly; expected 1 space but found 2 spaces
                            Open

                                    $headers  = array(

                            There are no issues that match your filters.

                            Category
                            Status