Function map_params
has a Cognitive Complexity of 125 (exceeds 5 allowed). Consider refactoring. Open
public function map_params( $mapping, $object, $trigger, $use_soap = false, $is_new = true, $object_id_field = '' ) {
$params = array();
$has_missing_required_salesforce_field = false;
- 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
File class-object-sync-sf-mapping.php
has 750 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Map objects and records between WordPress and Salesforce
*
* @class Object_Sync_Sf_Mapping
Function setup_fieldmap_data
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
private function setup_fieldmap_data( $posted = array(), $wordpress_fields = array(), $salesforce_fields = array() ) {
$data = array(
'label' => $posted['label'],
'name' => sanitize_title( $posted['label'] ),
'salesforce_object' => $posted['salesforce_object'],
- 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 maybe_upgrade_sync_triggers
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
private function maybe_upgrade_sync_triggers( $sync_triggers, $mapping_version, $mapping_id = '' ) {
// in v2 of this plugin, we replaced the bit flags with strings to make them more legible.
if ( version_compare( $mapping_version, '2.0.0', '<' ) ) {
// check if the triggers stored in the database are up to date. if not, update them.
$intersect = array_intersect( $sync_triggers, array_merge( $this->wordpress_events, $this->salesforce_events ) );
- 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 map_params
has 154 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function map_params( $mapping, $object, $trigger, $use_soap = false, $is_new = true, $object_id_field = '' ) {
$params = array();
$has_missing_required_salesforce_field = false;
Function get_fieldmaps
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
public function get_fieldmaps( $id = null, $conditions = array(), $reset = false ) {
$table = $this->fieldmap_table;
if ( null !== $id ) { // get one fieldmap.
$map = $this->wpdb->get_row( 'SELECT * FROM ' . $table . ' WHERE id = ' . $id, ARRAY_A );
$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
Method setup_fieldmap_data
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function setup_fieldmap_data( $posted = array(), $wordpress_fields = array(), $salesforce_fields = array() ) {
$data = array(
'label' => $posted['label'],
'name' => sanitize_title( $posted['label'] ),
'salesforce_object' => $posted['salesforce_object'],
Object_Sync_Sf_Mapping
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
class Object_Sync_Sf_Mapping {
/**
* Current version of the plugin
*
Function get_mapped_fields
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function get_mapped_fields( $mapping, $directions = array() ) {
$mapped_fields = array();
foreach ( $mapping['fields'] as $fields ) {
if ( empty( $directions ) || in_array( $fields['direction'], $directions, 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
Function get_object_maps
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public function get_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
Method get_fieldmaps
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_fieldmaps( $id = null, $conditions = array(), $reset = false ) {
$table = $this->fieldmap_table;
if ( null !== $id ) { // get one fieldmap.
$map = $this->wpdb->get_row( 'SELECT * FROM ' . $table . ' WHERE id = ' . $id, ARRAY_A );
$mappings = array();
Method maybe_upgrade_sync_triggers
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function maybe_upgrade_sync_triggers( $sync_triggers, $mapping_version, $mapping_id = '' ) {
// in v2 of this plugin, we replaced the bit flags with strings to make them more legible.
if ( version_compare( $mapping_version, '2.0.0', '<' ) ) {
// check if the triggers stored in the database are up to date. if not, update them.
$intersect = array_intersect( $sync_triggers, array_merge( $this->wordpress_events, $this->salesforce_events ) );
Method __construct
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct() {
$this->version = object_sync_for_salesforce()->version;
$this->file = object_sync_for_salesforce()->file;
$this->wpdb = object_sync_for_salesforce()->wpdb;
$this->slug = object_sync_for_salesforce()->slug;
Method create_object_map
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function create_object_map( $posted = array() ) {
$data = $this->setup_object_map_data( $posted );
$data['created'] = current_time( 'mysql' );
// Check to see if we don't know the salesforce id and it is not a temporary id, or if this is pending.
// If it is using a temporary id, the map will get updated after it finishes running; it won't call this method unless there's an error, which we should log.
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
Method get_object_maps
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_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();
Function delete_object_map
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function delete_object_map( $id = '' ) {
if ( is_string( $id ) || is_int( $id ) ) {
$data = array(
'id' => $id,
);
- 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 map_params
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function map_params( $mapping, $object, $trigger, $use_soap = false, $is_new = true, $object_id_field = '' ) {
Function create_object_map
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function create_object_map( $posted = array() ) {
$data = $this->setup_object_map_data( $posted );
$data['created'] = current_time( 'mysql' );
// Check to see if we don't know the salesforce id and it is not a temporary id, or if this is pending.
// If it is using a temporary id, the map will get updated after it finishes running; it won't call this method unless there's an error, which we should log.
- 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
Use placeholders and $wpdb->prepare(); found interpolated variable $table at "SELECT * FROM $table ORDER BY fieldmap_status
" Open
$mappings = $this->wpdb->get_results( "SELECT * FROM $table ORDER BY `fieldmap_status`", ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found $table Open
$mappings = $this->wpdb->get_results( 'SELECT * FROM ' . $table . $order, ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found interpolated variable $offset at "SELECT * FROM {$table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0 LIMIT {$offset}, {$items_per_page}" Open
$all_errors = $this->wpdb->get_results( "SELECT * FROM {$table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0 LIMIT {$offset}, {$items_per_page}", ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found $id Open
$error_row = $this->wpdb->get_row( 'SELECT * FROM ' . $table . ' WHERE id = "' . $id . '"', ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found interpolated variable $table at "SELECT id
, label
, wordpress_object
, salesforce_object
, salesforce_record_types_allowed
, salesforce_record_type_default
, fields
, pull_trigger_field
, sync_triggers
, push_async
, push_drafts
, weight
FROM $table" Open
$mappings = $this->wpdb->get_results( "SELECT `id`, `label`, `wordpress_object`, `salesforce_object`, `salesforce_record_types_allowed`, `salesforce_record_type_default`, `fields`, `pull_trigger_field`, `sync_triggers`, `push_async`, `push_drafts`, `weight` FROM $table", ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found $id Open
$map = $this->wpdb->get_row( 'SELECT * FROM ' . $table . ' WHERE id = ' . $id, ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found interpolated variable $this at "DESC {$this->object_map_table}" Open
$allowed_fields = $this->wpdb->get_col( "DESC {$this->object_map_table}", 0 );
- Exclude checks
Use placeholders and $wpdb->prepare(); found $order Open
$mappings = $this->wpdb->get_results( 'SELECT * FROM ' . $table . $order, ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found interpolated variable $table at "SELECT id
, label
, wordpress_object
, salesforce_object
, salesforce_record_types_allowed
, salesforce_record_type_default
, fields
, pull_trigger_field
, sync_triggers
, push_async
, push_drafts
, weight
, version
FROM $table" Open
$mappings = $this->wpdb->get_results( "SELECT `id`, `label`, `wordpress_object`, `salesforce_object`, `salesforce_record_types_allowed`, `salesforce_record_type_default`, `fields`, `pull_trigger_field`, `sync_triggers`, `push_async`, `push_drafts`, `weight`, `version` FROM $table", ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found interpolated variable $this at "DELETE FROM $this->object_map_table WHERE ID IN ($ids)" Open
$delete = $this->wpdb->query( "DELETE FROM $this->object_map_table WHERE ID IN ($ids)" );
- Exclude checks
Use placeholders and $wpdb->prepare(); found $where Open
$mappings = $this->wpdb->get_results( 'SELECT * FROM ' . $table . $where . $order, ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found interpolated variable $table at "SELECT * FROM {$table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0 LIMIT {$offset}, {$items_per_page}" Open
$all_errors = $this->wpdb->get_results( "SELECT * FROM {$table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0 LIMIT {$offset}, {$items_per_page}", ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found $where Open
$mappings = $this->wpdb->get_results( 'SELECT * FROM ' . $table . $where . ' ORDER BY `fieldmap_status`, `weight`', ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found interpolated variable $table at "SELECT id
, label
, wordpress_object
, salesforce_object
, salesforce_record_types_allowed
, salesforce_record_type_default
, fields
, pull_trigger_field
, sync_triggers
, push_async
, push_drafts
, pull_to_drafts
, weight
, version
FROM $table" Open
$mappings = $this->wpdb->get_results( "SELECT `id`, `label`, `wordpress_object`, `salesforce_object`, `salesforce_record_types_allowed`, `salesforce_record_type_default`, `fields`, `pull_trigger_field`, `sync_triggers`, `push_async`, `push_drafts`, `pull_to_drafts`, `weight`, `version` FROM $table", ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found interpolated variable $items_per_page at "SELECT * FROM {$table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0 LIMIT {$offset}, {$items_per_page}" Open
$all_errors = $this->wpdb->get_results( "SELECT * FROM {$table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0 LIMIT {$offset}, {$items_per_page}", ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found interpolated variable $table at "SELECT COUNT(id
) FROM {$table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0" Open
$errors_total = $this->wpdb->get_var( "SELECT COUNT(`id`) FROM {$table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0" );
- Exclude checks
Use placeholders and $wpdb->prepare(); found $table Open
$map = $this->wpdb->get_row( 'SELECT * FROM ' . $table . ' WHERE id = ' . $id, ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found $table Open
$mappings = $this->wpdb->get_results( 'SELECT * FROM ' . $table . $order, ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found $table Open
$mappings = $this->wpdb->get_results( 'SELECT * FROM ' . $table . $where . ' ORDER BY `fieldmap_status`, `weight`', ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found $table Open
$mappings = $this->wpdb->get_results( 'SELECT * FROM ' . $table . $where . $order, ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found $where Open
$mappings = $this->wpdb->get_results( 'SELECT * FROM ' . $table . $where . $order, ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found $order Open
$mappings = $this->wpdb->get_results( 'SELECT * FROM ' . $table . $where . $order, ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found interpolated variable $ids at "DELETE FROM $this->object_map_table WHERE ID IN ($ids)" Open
$delete = $this->wpdb->query( "DELETE FROM $this->object_map_table WHERE ID IN ($ids)" );
- Exclude checks
Use placeholders and $wpdb->prepare(); found $table Open
$mappings = $this->wpdb->get_results( 'SELECT * FROM ' . $table . $where . $order, ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found $order Open
$mappings = $this->wpdb->get_results( 'SELECT * FROM ' . $table . $order, ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found $table Open
$error_row = $this->wpdb->get_row( 'SELECT * FROM ' . $table . ' WHERE id = "' . $id . '"', ARRAY_A );
- Exclude checks
Use placeholders and $wpdb->prepare(); found $order Open
$mappings = $this->wpdb->get_results( 'SELECT * FROM ' . $table . $where . $order, ARRAY_A );
- Exclude checks