MinnPost/object-sync-for-salesforce

View on GitHub

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();
Severity: Minor
Found in classes/class-object-sync-sf-wordpress.php - About 45 mins to fix

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 );
} );
Severity: Minor
Found in assets/js/src/03-fieldmap-rows.js and 1 other location - About 45 mins to fix
assets/js/src/03-fieldmap-rows.js on lines 106..108

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

Further Reading

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 ) {
Severity: Minor
Found in classes/class-object-sync-sf-wordpress.php and 1 other location - About 45 mins to fix
classes/class-object-sync-sf-wordpress.php on lines 1698..1736

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

Further Reading

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 ),
Severity: Major
Found in classes/class-object-sync-sf-admin.php - About 40 mins to fix

    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 ) ) {
    Severity: Major
    Found in classes/class-object-sync-sf-admin.php - About 40 mins to fix

      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;
                  }
      Severity: Major
      Found in classes/class-object-sync-sf-salesforce-push.php - About 40 mins to fix

        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 ) {
        Severity: Minor
        Found in classes/class-object-sync-sf-logging.php - About 35 mins to fix

          Method http_request has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              protected function http_request( $url, $data, $headers = array(), $method = 'GET', $options = array() ) {
          Severity: Minor
          Found in classes/class-object-sync-sf-salesforce.php - About 35 mins to fix

            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 ) {
            Severity: Minor
            Found in classes/class-object-sync-sf-salesforce-pull.php - About 35 mins to fix

              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' ) {
              Severity: Minor
              Found in classes/class-object-sync-sf-salesforce.php - About 35 mins to fix

                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 ) {
                Severity: Minor
                Found in classes/class-object-sync-sf-pull-options.php - About 35 mins to fix

                  Method schedule_cron has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public function schedule_cron( $timestamp, $cron_schedule, $hook, $args = array(), $group = '' ) {
                  Severity: Minor
                  Found in classes/class-object-sync-sf-queue.php - About 35 mins to fix

                    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 ) {
                    Severity: Minor
                    Found in classes/class-object-sync-sf-salesforce-push.php - About 35 mins to fix

                      Method setup has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          public function setup( $title_or_params, $message = '', $trigger = 0, $parent = 0, $status = '' ) {
                      Severity: Minor
                      Found in classes/class-object-sync-sf-logging.php - About 35 mins to fix

                        Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            public function __construct( $condition, $message, $dismissible, $type, $template ) {
                        Severity: Minor
                        Found in classes/class-object-sync-sf-admin-notice.php - About 35 mins to fix

                          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 ) {
                          Severity: Minor
                          Found in classes/class-object-sync-sf-salesforce-pull.php - About 35 mins to fix

                            Method schedule_recurring has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                public function schedule_recurring( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '' ) {
                            Severity: Minor
                            Found in classes/class-object-sync-sf-queue.php - About 35 mins to fix

                              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' ) {
                              Severity: Minor
                              Found in classes/class-object-sync-sf-salesforce.php - About 35 mins to fix

                                Method analytics_api has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    public function analytics_api( $name, $id, $route = '', $params = array(), $method = 'GET' ) {
                                Severity: Minor
                                Found in classes/class-object-sync-sf-salesforce.php - About 35 mins to fix

                                  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 ) {
                                  Severity: Minor
                                  Found in classes/class-object-sync-sf-salesforce-pull.php - About 35 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language