Showing 364 of 364 total issues
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
$( document ).on( 'click', '.column-is_prematch input', function() {
$( '.column-is_prematch input' ).not( this ).prop( 'checked', false );
} );
- 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 50.
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
Consider simplifying this complex logical expression. Open
if ( true === $this->salesforce['is_authorized'] ) {
echo sprintf(
'<a class="nav-tab%1$s" href="%2$s">%3$s</a>',
esc_attr( $active ),
esc_url( '?page=' . $this->admin_settings_url_param . '&tab=' . $tab_key ),
Consider simplifying this complex logical expression. Open
if ( empty( $error_fieldmaps ) && empty( $error_object_maps ) && ( ! empty( $successful_fieldmaps ) || ! empty( $successful_object_maps ) ) ) {
$this->clear_cache( false );
wp_safe_redirect( get_admin_url( null, 'options-general.php?page=' . $this->admin_settings_url_param . '&tab=import-export&data_saved=true' ) );
exit;
} elseif ( ! empty( $error_fieldmaps ) && ! empty( $successful_fieldmaps ) ) {
Consider simplifying this complex logical expression. Open
if ( ( ! isset( $mapping['push_drafts'] ) || '1' !== $mapping['push_drafts'] ) && isset( $object['post_status'] ) && ( 'draft' === $object['post_status'] || ( 'inherit' === $object['post_status'] && 'attachment' !== $object['post_type'] ) ) ) {
// skip this object if it is a draft and the fieldmap settings told us to ignore it.
continue;
}
Method set_log_slug
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function set_log_slug( $override_slug, $slug, $post_ID, $post_status, $post_type ) {
Method http_request
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function http_request( $url, $data, $headers = array(), $method = 'GET', $options = array() ) {
Method delete_called_from_salesforce
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private function delete_called_from_salesforce( $sf_sync_trigger, $synced_object, $wordpress_id_field_name, $seconds, $mapping_objects ) {
Method api_http_request
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function api_http_request( $path, $params, $method, $options = array(), $type = 'rest' ) {
Method legacy_option_upgrade
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private function legacy_option_upgrade( $operation, $object_type = '', $fieldmap_id = '', $value = '', $autoload = true ) {
Method schedule_cron
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function schedule_cron( $timestamp, $cron_schedule, $hook, $args = array(), $group = '' ) {
Method create_object_map
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private function create_object_map( $wordpress_object, $id_field_name, $salesforce_id, $field_mapping, $pending = false ) {
Method setup
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function setup( $title_or_params, $message = '', $trigger = 0, $parent = 0, $status = '' ) {
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct( $condition, $message, $dismissible, $type, $template ) {
Method is_pull_allowed
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private function is_pull_allowed( $object_type, $object, $sf_sync_trigger, $salesforce_mapping, $map_sync_triggers ) {
Method schedule_recurring
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function schedule_recurring( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '' ) {
Method api_call
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function api_call( $path, $params = array(), $method = 'GET', $options = array(), $type = 'rest' ) {
Method analytics_api
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function analytics_api( $name, $id, $route = '', $params = array(), $method = 'GET' ) {
Method update_called_from_salesforce
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private function update_called_from_salesforce( $sf_sync_trigger, $synced_object, $params, $wordpress_id_field_name, $seconds ) {