File class-object-sync-sf-wordpress.php
has 1686 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Work with the WordPress data. This class can make read and write calls to the WordPress database, and also cache the responses.
*
* @class Object_Sync_Sf_WordPress
Function comment_upsert
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
private function comment_upsert( $key, $value, $methods, $params, $id_field = 'comment_ID', $pull_to_drafts = false, $check_only = false ) {
$method = isset( $methods['method_match'] ) ? $methods['method_match'] : '';
if ( 'get_comment' === $method ) {
$method = 'get_comments';
}
- 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 post_upsert
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
private function post_upsert( $key, $value, $methods, $params, $id_field = 'ID', $pull_to_drafts = false, $post_type = 'post', $check_only = false ) {
$method = isset( $methods['method_match'] ) ? $methods['method_match'] : '';
if ( '' !== $method ) {
// By default, posts use get_posts as the method. args can be like this.
- 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_wordpress_table_structure
has 154 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_wordpress_table_structure( $object_type ) {
if ( 'attachment' === $object_type ) {
$object_table_structure = array(
'object_name' => 'post',
'content_methods' => array(
Function term_upsert
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
private function term_upsert( $key, $value, $methods, $params, $taxonomy, $id_field = 'ID', $pull_to_drafts = false, $check_only = false ) {
if ( 'tag' === $taxonomy ) {
$taxonomy = 'post_tag';
}
$method = isset( $methods['method_match'] ) ? $methods['method_match'] : '';
- 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_upsert
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
private function attachment_upsert( $key, $value, $methods, $params, $id_field = 'ID', $check_only = false ) {
$method = isset( $methods['method_match'] ) ? $methods['method_match'] : '';
if ( '' !== $method ) {
// Get_posts is more helpful here, so that is the method attachment uses for 'read'.
- 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_upsert
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
private function user_upsert( $key, $value, $methods, $params, $id_field = 'ID', $pull_to_drafts = false, $check_only = false ) {
// If the key is user_email, we need to make it just email because that is how the WordPress method reads it.
$method = isset( $methods['method_match'] ) ? $methods['method_match'] : '';
if ( '' !== $method ) {
- 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
Object_Sync_Sf_WordPress
has 38 functions (exceeds 20 allowed). Consider refactoring. Open
class Object_Sync_Sf_WordPress {
/**
* Current version of the plugin
*
Method comment_upsert
has 123 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function comment_upsert( $key, $value, $methods, $params, $id_field = 'comment_ID', $pull_to_drafts = false, $check_only = false ) {
$method = isset( $methods['method_match'] ) ? $methods['method_match'] : '';
if ( 'get_comment' === $method ) {
$method = 'get_comments';
}
Method post_upsert
has 112 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function post_upsert( $key, $value, $methods, $params, $id_field = 'ID', $pull_to_drafts = false, $post_type = 'post', $check_only = false ) {
$method = isset( $methods['method_match'] ) ? $methods['method_match'] : '';
if ( '' !== $method ) {
// By default, posts use get_posts as the method. args can be like this.
Method attachment_upsert
has 107 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function attachment_upsert( $key, $value, $methods, $params, $id_field = 'ID', $check_only = false ) {
$method = isset( $methods['method_match'] ) ? $methods['method_match'] : '';
if ( '' !== $method ) {
// Get_posts is more helpful here, so that is the method attachment uses for 'read'.
Method term_upsert
has 97 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function term_upsert( $key, $value, $methods, $params, $taxonomy, $id_field = 'ID', $pull_to_drafts = false, $check_only = false ) {
if ( 'tag' === $taxonomy ) {
$taxonomy = 'post_tag';
}
$method = isset( $methods['method_match'] ) ? $methods['method_match'] : '';
Method user_upsert
has 92 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function user_upsert( $key, $value, $methods, $params, $id_field = 'ID', $pull_to_drafts = false, $check_only = false ) {
// If the key is user_email, we need to make it just email because that is how the WordPress method reads it.
$method = isset( $methods['method_match'] ) ? $methods['method_match'] : '';
if ( '' !== $method ) {
Function update_wp_meta
has a Cognitive Complexity of 24 (exceeds 5 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 ) ) {
- 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 object_fields
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
private function object_fields( $object_name, $id_field, $content_table, $content_methods, $meta_table, $meta_methods, $where, $ignore_keys = array() ) {
// These two queries load all the fields from the specified object unless they have been specified as ignore fields.
// They also load the fields that are meta_keys from the specified object's meta table.
// Maybe a box for a custom query, since custom fields get done in so many ways.
// Eventually this would be the kind of thing we could use fields api for, if it ever gets done.
- 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_update
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
private function attachment_update( $attachment_id, $params, $id_field = 'ID' ) {
$content = array();
$content[ $id_field ] = $attachment_id;
foreach ( $params as $key => $value ) {
if ( 'wp_insert_attachment' === $value['method_modify'] ) { // Should also be insert attachment maybe.
- 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 object_fields
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function object_fields( $object_name, $id_field, $content_table, $content_methods, $meta_table, $meta_methods, $where, $ignore_keys = array() ) {
// These two queries load all the fields from the specified object unless they have been specified as ignore fields.
// They also load the fields that are meta_keys from the specified object's meta table.
// Maybe a box for a custom query, since custom fields get done in so many ways.
// Eventually this would be the kind of thing we could use fields api for, if it ever gets done.
Function post_create
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
private function post_create( $params, $id_field = 'ID', $post_type = 'post' ) {
// Load all params with a method_modify of the object structure's content_method into $content.
$content = array();
$structure = $this->get_wordpress_table_structure( $post_type );
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
Method attachment_update
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function attachment_update( $attachment_id, $params, $id_field = 'ID' ) {
$content = array();
$content[ $id_field ] = $attachment_id;
foreach ( $params as $key => $value ) {
if ( 'wp_insert_attachment' === $value['method_modify'] ) { // Should also be insert attachment maybe.
Method post_create
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function post_create( $params, $id_field = 'ID', $post_type = 'post' ) {
// Load all params with a method_modify of the object structure's content_method into $content.
$content = array();
$structure = $this->get_wordpress_table_structure( $post_type );
foreach ( $params as $key => $value ) {
Function user_create
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private function user_create( $params, $id_field = 'ID' ) {
// Allow username to be email address or username.
// The username could be autogenerated before this point for the sake of URLs.
$username = $params['user_email']['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
Method user_create
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function user_create( $params, $id_field = 'ID' ) {
// Allow username to be email address or username.
// The username could be autogenerated before this point for the sake of URLs.
$username = $params['user_email']['value'];
Method comment_create
has 48 lines of code (exceeds 25 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 ) {
Method object_upsert
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function object_upsert( $name, $key, $value, $methods, $params, $pull_to_drafts = false, $check_only = false ) {
$structure = $this->get_wordpress_table_structure( $name );
$id_field = $structure['id_field'];
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 ) ) {
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.
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 ) {
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 object_update
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function object_update( $name, $id, $params, $mapping_object = array() ) {
$structure = $this->get_wordpress_table_structure( $name );
$id_field = $structure['id_field'];
Method object_create
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function object_create( $name, $params ) {
$structure = $this->get_wordpress_table_structure( $name );
$id_field = $structure['id_field'];
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 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 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 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 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 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'];
Function create_wp_meta
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function create_wp_meta( $params, $parent_object_id, $parent_object_type ) {
$success = true;
$errors = array();
if ( ! is_wp_error( $parent_object_id ) && is_array( $params ) && ! empty( $params ) ) {
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
Method create_wp_meta
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function create_wp_meta( $params, $parent_object_id, $parent_object_type ) {
$success = true;
$errors = array();
if ( ! is_wp_error( $parent_object_id ) && is_array( $params ) && ! empty( $params ) ) {
foreach ( $params as $key => $value ) {
Function object_upsert
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function object_upsert( $name, $key, $value, $methods, $params, $pull_to_drafts = false, $check_only = false ) {
$structure = $this->get_wordpress_table_structure( $name );
$id_field = $structure['id_field'];
- 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_wordpress_object_fields
has a Cognitive Complexity of 10 (exceeds 5 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'];
- 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 object_fields
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
private function object_fields( $object_name, $id_field, $content_table, $content_methods, $meta_table, $meta_methods, $where, $ignore_keys = array() ) {
Method post_upsert
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
private function post_upsert( $key, $value, $methods, $params, $id_field = 'ID', $pull_to_drafts = false, $post_type = 'post', $check_only = false ) {
Method term_upsert
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
private function term_upsert( $key, $value, $methods, $params, $taxonomy, $id_field = 'ID', $pull_to_drafts = false, $check_only = false ) {
Function get_wordpress_table_structure
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function get_wordpress_table_structure( $object_type ) {
if ( 'attachment' === $object_type ) {
$object_table_structure = array(
'object_name' => 'post',
'content_methods' => 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 object_delete
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function object_delete( $name, $id ) {
$structure = $this->get_wordpress_table_structure( $name );
$id_field = $structure['id_field'];
switch ( $name ) {
- 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_wordpress_object_data
has a Cognitive Complexity of 9 (exceeds 5 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'];
- 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 object_update
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function object_update( $name, $id, $params, $mapping_object = array() ) {
$structure = $this->get_wordpress_table_structure( $name );
$id_field = $structure['id_field'];
- 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 object_create
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function object_create( $name, $params ) {
$structure = $this->get_wordpress_table_structure( $name );
$id_field = $structure['id_field'];
- 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 comment_upsert
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
private function comment_upsert( $key, $value, $methods, $params, $id_field = 'comment_ID', $pull_to_drafts = false, $check_only = false ) {
Method user_upsert
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
private function user_upsert( $key, $value, $methods, $params, $id_field = 'ID', $pull_to_drafts = false, $check_only = false ) {
Method object_upsert
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public function object_upsert( $name, $key, $value, $methods, $params, $pull_to_drafts = false, $check_only = false ) {
Method attachment_upsert
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private function attachment_upsert( $key, $value, $methods, $params, $id_field = 'ID', $check_only = false ) {
Function post_update
has a Cognitive Complexity of 8 (exceeds 5 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'] ) {
- 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_update
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function term_update( $term_id, $params, $taxonomy, $id_field = 'ID' ) {
if ( 'tag' === $taxonomy ) {
$taxonomy = 'post_tag';
}
$args = 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_update
has a Cognitive Complexity of 7 (exceeds 5 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'] ) {
- 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
Avoid too many return
statements within this method. Open
return $existing_id;
Avoid too many return
statements within this method. Open
return $result;
Avoid too many return
statements within this method. Open
return $result;
Avoid too many return
statements within this method. Open
return $result;
Avoid too many return
statements within this method. Open
return $result;
Avoid too many return
statements within this method. Open
return $existing_id;
Avoid too many return
statements within this method. Open
return $existing_id;
Avoid too many return
statements within this method. Open
return $existing_id;
Avoid too many return
statements within this method. Open
return $existing_id;
Avoid too many return
statements within this method. Open
return $result;
Avoid too many return
statements within this method. Open
return $result;
Avoid too many return
statements within this method. Open
return $result;
Function object_edit_link
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function object_edit_link( $object_type, $wordpress_id ) {
$edit_link = '';
if ( 'user' === $object_type ) {
$edit_link = get_edit_user_link( $wordpress_id );
} elseif ( 'post' === $object_type || 'page' === $object_type || 'attachment' === $object_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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ( is_wp_error( $post_id ) ) {
$success = false;
$errors = $post_id;
} else {
// If it's a custom record type, fix the methods.
- 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 143.
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 3 locations. Consider refactoring. Open
if ( 'attachment' === $object_type ) {
$object_table_structure = array(
'object_name' => 'post',
'content_methods' => array(
'create' => 'wp_insert_attachment',
- 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 143.
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 3 locations. Consider refactoring. Open
} else { // This is for custom post types.
$object_table_structure = array(
'object_name' => 'post',
'content_methods' => array(
'create' => 'wp_insert_post',
- 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 143.
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 ( is_wp_error( $post_id ) ) {
$success = false;
$errors = $post_id;
} else {
// If it's a custom record type, fix the methods.
- 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 143.
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 3 locations. Consider refactoring. Open
} elseif ( 'post' === $object_type ) {
$object_table_structure = array(
'object_name' => 'post',
'content_methods' => array(
'create' => 'wp_insert_post',
- 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 143.
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 ( is_wp_error( $term ) ) {
$success = false;
$errors = $term;
} else {
$term_id = $term[ "$id_field" ];
- 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 111.
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 ( is_wp_error( $term ) ) {
$success = false;
$errors = $term;
} else {
$term_id = $term[ "$id_field" ];
- 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 111.
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 ( isset( $posts ) && isset( $posts[0]->{$id_field} ) ) {
// Post does exist after checking the matching value. We want its id.
$post_id = $posts[0]->{$id_field};
if ( true === $check_only ) {
- 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 101.
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 ( isset( $term ) && isset( $term->{$id_field} ) ) {
// Term does exist after checking the matching value. we want its id.
$term_id = $term->{$id_field};
if ( true === $check_only ) {
- 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 101.
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 ( is_wp_error( $comment_id ) ) {
$success = false;
$errors = $comment_id;
} else {
$meta_result = $this->create_wp_meta( $params, $comment_id, 'comment' );
- 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 98.
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 ( is_wp_error( $user_id ) ) {
$success = false;
$errors = $user_id;
} else {
$meta_result = $this->update_wp_meta( $params, $user_id, 'user' );
- 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 98.
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 ( isset( $posts ) && isset( $posts[0]->{$id_field} ) ) {
// Attachment does exist after checking the matching value. we want its id.
$attachment_id = $posts[0]->{$id_field};
if ( true === $check_only ) {
- 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 98.
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 ( isset( $user ) && isset( $user->{$id_field} ) ) {
// User does exist after checking the matching value. we want its id.
$user_id = $user->{$id_field};
if ( true === $check_only ) {
- 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 95.
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
Use placeholders and $wpdb->prepare(); found interpolated variable $tax_table at "DESC {$tax_table}" Open
$taxonomy = $this->wpdb->get_col( "DESC {$tax_table}", 0 );
- Exclude checks
Use placeholders and $wpdb->prepare(); found interpolated variable $content_table at "DESC {$content_table}" Open
$data_fields = $this->wpdb->get_col( "DESC {$content_table}", 0 );
- Exclude checks
Use placeholders and $wpdb->prepare(); found interpolated variable $content_table at "DESC {$content_table}" Open
$data_field_types = $this->wpdb->get_col( "DESC {$content_table}", 1 ); // get the database field types.
- Exclude checks
Use placeholders and $wpdb->prepare(); found $select_meta Open
$meta_fields = $this->wpdb->get_results( $select_meta );
- Exclude checks