Showing 364 of 364 total issues
Method get_salesforce_object_description
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_salesforce_object_description( $data = array() ) {
$ajax = false;
if ( empty( $data ) ) {
$data = filter_input_array( INPUT_POST, FILTER_SANITIZE_SPECIAL_CHARS );
$ajax = true;
Method prepare_fieldmap_data
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function prepare_fieldmap_data() {
$error = false;
$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_SPECIAL_CHARS );
$cachekey = wp_json_encode( $post_data );
if ( false !== $cachekey ) {
Method update_wp_meta
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function update_wp_meta( $params, $parent_object_id, $parent_object_type ) {
$success = true;
$changed = false;
$errors = array();
if ( ! is_wp_error( $parent_object_id ) && is_array( $params ) && ! empty( $params ) ) {
Function loadFieldOptions
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function loadFieldOptions( system, objectName ) {
var data = {
'action': 'get_' + system + '_object_fields'
};
var selectField = '.column-' + system + '_field select';
Method attachment_create
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function attachment_create( $params, $id_field = '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( 'attachment' );
// WP requires post_title, post_content (can be empty), post_status, and post_mime_type to create an attachment.
Method term_create
has 44 lines of code (exceeds 25 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.
Function status
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function status( $sfapi ) {
$contacts = $sfapi->query( 'SELECT Name, Id from Contact LIMIT 100' );
if ( 200 !== $contacts['code'] ) {
- 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 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.
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ( true === $disable_mapped_fields ) {
$key = null;
$needle = $salesforce_field['name']; // the current Salesforce field.
// check the already mapped fields for the current field.
array_walk(
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 115.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ( true === $disable_mapped_fields ) {
$key = null;
$needle = $wordpress_field['key']; // the current WP field.
// check the already mapped fields for the current field.
array_walk(
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 115.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method object_delete
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function object_delete( $name, $id ) {
$structure = $this->get_wordpress_table_structure( $name );
$id_field = $structure['id_field'];
switch ( $name ) {
Method post_actions
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function post_actions( $post_id, $post ) {
// if this runs on a non-object due to another operation, don't continue.
if ( ! is_object( $post ) ) {
return;
Function loadFieldOptions
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function loadFieldOptions( system, objectName ) {
var data = {
'action': 'get_' + system + '_object_fields'
};
var selectField = '.column-' + system + '_field select';
- 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 display_notices
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function display_notices() {
// before a notice is displayed, we should make sure we are on a page related to this plugin.
if ( ! isset( $_GET['page'] ) || $this->admin_settings_url_param !== $_GET['page'] ) {
return;
- 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 can_process
has a Cognitive Complexity of 13 (exceeds 5 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 ) {
- 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 attachment_create
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function attachment_create( $params, $id_field = '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( 'attachment' );
// WP requires post_title, post_content (can be empty), post_status, and post_mime_type to create an attachment.
- 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 display_select
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function display_select( $args ) {
$type = $args['type'];
$id = $args['label_for'];
$name = $args['name'];
$desc = $args['desc'];
Method display_checkboxes
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function display_checkboxes( $args ) {
$type = 'checkbox';
$name = $args['name'];
$options = get_option( $name, array() );
$group_desc = $args['desc'];
Method get_next_record_batch
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function get_next_record_batch( $last_sync, $salesforce_mapping, $map_sync_triggers, $type, $version_path, $query_options, $response ) {
// Handle next batch of records if it exists.
$next_records_url = isset( $response['nextRecordsUrl'] ) ? str_replace( $version_path, '', $response['nextRecordsUrl'] ) : false;
while ( $next_records_url ) {
// shouldn't cache this either. it's going into the queue if it exists anyway.
Method add_actions
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function add_actions() {
$db_version = get_option( $this->option_prefix . 'db_version', false );
if ( $db_version === $this->version ) {
foreach ( $this->mappings->get_fieldmaps( null, $this->mappings->active_fieldmap_conditions ) as $mapping ) {
$object_type = $mapping['wordpress_object'];