Showing 241 of 364 total issues
Method term_update
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function term_update( $term_id, $params, $taxonomy, $id_field = 'ID' ) {
if ( 'tag' === $taxonomy ) {
$taxonomy = 'post_tag';
}
$args = array();
Method can_process
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function can_process( WP_REST_Request $request ) {
// unless we specify it here, the method will not be allowed unless the user has configure_salesforce capability.
$http_method = $request->get_method();
$class = $request->get_url_params()['class'];
switch ( $class ) {
Method get_wordpress_object_data
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_wordpress_object_data( $object_type, $object_id, $is_deleted = false ) {
$wordpress_object = array();
$object_table_structure = $this->get_wordpress_table_structure( $object_type );
$meta_table = $object_table_structure['meta_table'];
Function get_all_object_maps
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function get_all_object_maps( $conditions = array(), $reset = false ) {
$table = $this->object_map_table;
$order = ' ORDER BY object_updated, created';
if ( ! empty( $conditions ) ) { // get multiple but with a limitation.
$mappings = 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
Function comment_create
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function comment_create( $params, $id_field = 'comment_ID' ) {
// Load all params with a method_modify of the object structure's content_method into $content.
$content = array();
$structure = $this->get_wordpress_table_structure( 'comment' );
foreach ( $params as $key => $value ) {
- 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 user_update
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function user_update( $user_id, $params, $id_field = 'ID' ) {
$content = array();
$content[ $id_field ] = $user_id;
foreach ( $params as $key => $value ) {
- 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 term_create
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function term_create( $params, $taxonomy, $id_field = 'ID' ) {
if ( 'tag' === $taxonomy ) {
$taxonomy = 'post_tag';
}
// Load all params with a method_modify of the object structure's content_method into $content.
- 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 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 fields_errors
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function fields_errors( $page, $section, $callbacks ) {
add_settings_section( $section, __( 'Mapping Error Settings', 'object-sync-for-salesforce' ), null, $page );
$error_settings = array(
'errors_per_page' => array(
Method prepare_object_map_data
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function prepare_object_map_data() {
$error = false;
$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_SPECIAL_CHARS );
$cachekey = wp_json_encode( $post_data );
if ( false !== $cachekey ) {
Method manual_push
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function manual_push( $object_type, $wordpress_id, $http_method ) {
$object = $this->wordpress->get_wordpress_object_data( $object_type, $wordpress_id );
// run the WordPress trigger that corresponds to the HTTP method.
switch ( $http_method ) {
case 'POST':
Method __toString
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __toString() {
$query = 'SELECT ';
$query .= implode( ', ', $this->fields );
$query .= ' FROM ' . $this->object_type;
Method user_update
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function user_update( $user_id, $params, $id_field = 'ID' ) {
$content = array();
$content[ $id_field ] = $user_id;
foreach ( $params as $key => $value ) {
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 );
Method status
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function status( $sfapi ) {
$contacts = $sfapi->query( 'SELECT Name, Id from Contact LIMIT 100' );
if ( 200 !== $contacts['code'] ) {
Method post_update
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function post_update( $post_id, $params, $id_field = 'ID', $post_type = '' ) {
$content = array();
$content[ $id_field ] = $post_id;
foreach ( $params as $key => $value ) {
if ( 'wp_update_post' === $value['method_modify'] ) {
Method comment_update
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function comment_update( $comment_id, $params, $id_field = 'comment_ID' ) {
$content = array();
$content[ $id_field ] = $comment_id;
foreach ( $params as $key => $value ) {
if ( 'wp_update_comment' === $value['method_modify'] ) {
Method log_trigger_settings
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function log_trigger_settings() {
$triggers_to_log = get_option( $this->option_prefix . 'triggers_to_log', array() );
if ( ! empty( $triggers_to_log ) ) {
// in version 2.0.0 of this plugin, we replaced the bit flags with strings to make them more legible.
// when the database version changes to 2.0.0, we should update the option value to use the new strings.
Method respond_to_salesforce_merge
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function respond_to_salesforce_merge( $object_type, $merged_record ) {
$op = 'Merge';
if ( isset( $merged_record['Id'] ) && true === filter_var( $merged_record['sf:IsDeleted'], FILTER_VALIDATE_BOOLEAN ) && '' !== $merged_record['sf:MasterRecordId'] ) {
$previous_sf_id = $merged_record['Id'];
$new_sf_id = $merged_record['sf:MasterRecordId'];
Method get_wordpress_object_fields
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_wordpress_object_fields( $wordpress_object, $id_field = 'ID' ) {
$object_table_structure = $this->get_wordpress_table_structure( $wordpress_object );
$meta_table = $object_table_structure['meta_table'];