Showing 364 of 364 total issues
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
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 can_process
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function can_process( WP_REST_Request $request ) {
// unless we specify it here, the method will not be allowed unless the user has configure_salesforce capability.
$http_method = $request->get_method();
$class = $request->get_url_params()['class'];
switch ( $class ) {
Method get_wordpress_object_data
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_wordpress_object_data( $object_type, $object_id, $is_deleted = false ) {
$wordpress_object = array();
$object_table_structure = $this->get_wordpress_table_structure( $object_type );
$meta_table = $object_table_structure['meta_table'];
Function get_all_object_maps
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function get_all_object_maps( $conditions = array(), $reset = false ) {
$table = $this->object_map_table;
$order = ' ORDER BY object_updated, created';
if ( ! empty( $conditions ) ) { // get multiple but with a limitation.
$mappings = array();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function comment_create
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function comment_create( $params, $id_field = 'comment_ID' ) {
// Load all params with a method_modify of the object structure's content_method into $content.
$content = array();
$structure = $this->get_wordpress_table_structure( 'comment' );
foreach ( $params as $key => $value ) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function user_update
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function user_update( $user_id, $params, $id_field = 'ID' ) {
$content = array();
$content[ $id_field ] = $user_id;
foreach ( $params as $key => $value ) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function term_create
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function term_create( $params, $taxonomy, $id_field = 'ID' ) {
if ( 'tag' === $taxonomy ) {
$taxonomy = 'post_tag';
}
// Load all params with a method_modify of the object structure's content_method into $content.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method refresh_token
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function refresh_token() {
$refresh_token = $this->get_refresh_token();
if ( empty( $refresh_token ) ) {
throw new Object_Sync_Sf_Exception( esc_html__( 'There is no refresh token.', 'object-sync-for-salesforce' ) );
}
Method fields_errors
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function fields_errors( $page, $section, $callbacks ) {
add_settings_section( $section, __( 'Mapping Error Settings', 'object-sync-for-salesforce' ), null, $page );
$error_settings = array(
'errors_per_page' => array(
Similar blocks of code found in 3 locations. Consider refactoring. Open
<?php if ( '' !== esc_url( $this->wordpress->object_edit_link( $mapping_error['wordpress_object'], $mapping_error['wordpress_id'] ) ) ) : ?>
<span class="edit">
<a href="<?php echo esc_url( $this->wordpress->object_edit_link( $mapping_error['wordpress_object'], $mapping_error['wordpress_id'] ) ); ?>">
<?php
echo sprintf(
- 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 108.
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
<?php if ( '' !== esc_url( $this->wordpress->object_delete_link( $mapping_error['wordpress_object'], $mapping_error['wordpress_id'] ) ) ) : ?>
<span class="delete">
<a href="<?php echo esc_url( $this->wordpress->object_delete_link( $mapping_error['wordpress_object'], $mapping_error['wordpress_id'] ) ); ?>">
<?php
echo sprintf(
- 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 108.
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
<?php if ( '' !== esc_url( $this->wordpress->object_edit_link( $map_row['wordpress_object'], $map_row['wordpress_id'] ) ) ) : ?>
<li>
<span class="dashicons dashicons-edit-large"></span>
<a href="<?php echo esc_url( $this->wordpress->object_edit_link( $map_row['wordpress_object'], $map_row['wordpress_id'] ) ); ?>">
<?php
- 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 108.
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 prepare_object_map_data
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function prepare_object_map_data() {
$error = false;
$post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_SPECIAL_CHARS );
$cachekey = wp_json_encode( $post_data );
if ( false !== $cachekey ) {
Method manual_push
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function manual_push( $object_type, $wordpress_id, $http_method ) {
$object = $this->wordpress->get_wordpress_object_data( $object_type, $wordpress_id );
// run the WordPress trigger that corresponds to the HTTP method.
switch ( $http_method ) {
case 'POST':
Method __toString
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __toString() {
$query = 'SELECT ';
$query .= implode( ', ', $this->fields );
$query .= ' FROM ' . $this->object_type;
Method user_update
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function user_update( $user_id, $params, $id_field = 'ID' ) {
$content = array();
$content[ $id_field ] = $user_id;
foreach ( $params as $key => $value ) {