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
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'] ) {
- Read upRead up
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.
Object_Sync_Sf_Salesforce
has 36 functions (exceeds 20 allowed). Consider refactoring. Open
class Object_Sync_Sf_Salesforce {
/**
* Current version of the plugin
*
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'] ) {
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';
- Read upRead up
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.
- Read upRead up
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';
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' ) );
}
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 );
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 );
- Read upRead up
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,
Function objects
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function objects(
$conditions = array(
'updateable' => true,
'triggerable' => true,
),
- Read upRead up
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 = '' ) {
Method http_request
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function http_request( $url, $data, $headers = array(), $method = 'GET', $options = array() ) {
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' ) {
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' ) {
Method analytics_api
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function analytics_api( $name, $id, $route = '', $params = array(), $method = 'GET' ) {
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(
- Read upRead up
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 correctly; expected 1 space but found 2 spaces Open
$headers = array(
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 1 space but found 2 spaces Open
$headers = array(
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 6 spaces Open
$url = $this->login_url . $this->token_path;
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 6 spaces Open
$url = $this->login_url . $this->token_path;
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 1 space but found 2 spaces Open
$headers = array(
- Exclude checks