MinnPost/object-sync-for-salesforce

View on GitHub

Showing 364 of 364 total issues

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

    public function set( $operation, $object_type = '', $fieldmap_id = '', $value = '', $autoload = false ) {
Severity: Minor
Found in classes/class-object-sync-sf-pull-options.php - About 35 mins to fix

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

        public function set( $operation, $object_type = '', $fieldmap_id = '', $value = '', $expiration = 0 ) {
    Severity: Minor
    Found in classes/class-object-sync-sf-sync-transients.php - About 35 mins to fix

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

          private function legacy_transient_upgrade( $operation, $object_type = '', $fieldmap_id = '', $value = '', $expiration = 0 ) {
      Severity: Minor
      Found in classes/class-object-sync-sf-sync-transients.php - About 35 mins to fix

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

            private function is_push_allowed( $object_type, $object, $sf_sync_trigger, $mapping, $map_sync_triggers ) {
        Severity: Minor
        Found in classes/class-object-sync-sf-salesforce-push.php - About 35 mins to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                      foreach ( $error_object_maps as $mapping_object ) {
                          $body .= sprintf(
                              // translators: placeholders are: 1) the mapping object row ID, 2) the ID of the Salesforce object, 3) the WordPress object type.
                              '<li>' . esc_html__( 'Mapping object id (if it exists): %1$s. Salesforce Id: %2$s. WordPress object type: %3$s', 'object-sync-for-salesforce' ) . '</li>',
                              isset( $mapping_object['id'] ) ? absint( $mapping_object['id'] ) : '',
          Severity: Minor
          Found in classes/class-object-sync-sf-admin.php and 1 other location - About 35 mins to fix
          classes/class-object-sync-sf-admin.php on lines 2087..2095

          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 92.

          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

                      foreach ( $error_fieldmaps as $fieldmap ) {
                          $body .= sprintf(
                              // translators: placeholders are: 1) the fieldmap row ID, 2) the Salesforce object type, 3) the WordPress object type.
                              '<li>' . esc_html__( 'Fieldmap id (if it exists): %1$s. Salesforce object type: %2$s. WordPress object type: %3$s', 'object-sync-for-salesforce' ) . '</li>',
                              isset( $fieldmap['id'] ) ? absint( $fieldmap['id'] ) : '',
          Severity: Minor
          Found in classes/class-object-sync-sf-admin.php and 1 other location - About 35 mins to fix
          classes/class-object-sync-sf-admin.php on lines 2096..2104

          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 92.

          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

          Function posts_filter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function posts_filter( $query ) {
                  global $pagenow;
                  $type     = 'wp_log';
                  $taxonomy = 'wp_log_type';
                  if ( is_admin() && 'edit.php' === $pagenow ) {
          Severity: Minor
          Found in classes/class-object-sync-sf-logging.php - About 35 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

          Function check_deprecated_salesforce_api_version has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              private function check_deprecated_salesforce_api_version( $sf_api_version ) {
                  $deprecated_api_version = defined( 'OBJECT_SYNC_SF_SALESFORCE_API_VERSION' ) ? OBJECT_SYNC_SF_SALESFORCE_API_VERSION : '';
                  // if the constant exists.
                  if ( '' === $deprecated_api_version ) {
                      $deprecated_option_key = $this->option_prefix . 'api_version';
          Severity: Minor
          Found in classes/class-object-sync-salesforce.php - About 35 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

          Function create_object_map has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function create_object_map( $posted = array() ) {
                  $data            = $this->setup_object_map_data( $posted );
                  $data['created'] = current_time( 'mysql' );
                  // Check to see if we don't know the salesforce id and it is not a temporary id, or if this is pending.
                  // If it is using a temporary id, the map will get updated after it finishes running; it won't call this method unless there's an error, which we should log.
          Severity: Minor
          Found in classes/class-object-sync-sf-mapping.php - About 35 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

          Function clear_cache has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              private function clear_cache( $ajax = false ) {
                  $result  = $this->wordpress->sfwp_transients->flush();
                  $success = $result['success'];
                  if ( 0 < $result['count'] ) {
                      if ( true === $success ) {
          Severity: Minor
          Found in classes/class-object-sync-sf-admin.php - About 35 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

          Function object_describe has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function object_describe( $name, $reset = false ) {
                  if ( empty( $name ) ) {
                      return array();
                  }
                  $options = array(
          Severity: Minor
          Found in classes/class-object-sync-sf-salesforce.php - About 35 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

          Function check_log_schedule has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function check_log_schedule( $old_value, $new_value, $option ) {
                  $clear_schedule  = false;
                  $schedule_unit   = get_option( $this->option_prefix . 'logs_how_often_unit', '' );
                  $schedule_number = filter_var( get_option( $this->option_prefix . 'logs_how_often_number', '' ), FILTER_VALIDATE_INT );
                  if ( $this->option_prefix . 'logs_how_often_unit' === $option ) {
          Severity: Minor
          Found in classes/class-object-sync-sf-logging.php - About 35 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

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

          Use placeholders and $wpdb->prepare(); found interpolated variable $table at "SELECT * FROM $table ORDER BY fieldmap_status"
          Open

                      $mappings = $this->wpdb->get_results( "SELECT * FROM $table ORDER BY `fieldmap_status`", ARRAY_A );

          Use placeholders and $wpdb->prepare(); found $table
          Open

                      $mappings = $this->wpdb->get_results( 'SELECT * FROM ' . $table . $order, ARRAY_A );

          Use placeholders and $wpdb->prepare(); found interpolated variable $offset at "SELECT * FROM {$table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0 LIMIT {$offset}, {$items_per_page}"
          Open

                  $all_errors            = $this->wpdb->get_results( "SELECT * FROM {$table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0 LIMIT {$offset}, {$items_per_page}", ARRAY_A );

          Use placeholders and $wpdb->prepare(); found $id
          Open

                  $error_row = $this->wpdb->get_row( 'SELECT * FROM ' . $table . ' WHERE id = "' . $id . '"', ARRAY_A );

          Use placeholders and $wpdb->prepare(); found interpolated variable $table at "SELECT id, label, wordpress_object, salesforce_object, salesforce_record_types_allowed, salesforce_record_type_default, fields, pull_trigger_field, sync_triggers, push_async, push_drafts, weight FROM $table"
          Open

                              $mappings = $this->wpdb->get_results( "SELECT `id`, `label`, `wordpress_object`, `salesforce_object`, `salesforce_record_types_allowed`, `salesforce_record_type_default`, `fields`, `pull_trigger_field`, `sync_triggers`, `push_async`, `push_drafts`, `weight` FROM $table", ARRAY_A );

          Use placeholders and $wpdb->prepare(); found $id
          Open

                      $map        = $this->wpdb->get_row( 'SELECT * FROM ' . $table . ' WHERE id = ' . $id, ARRAY_A );

          Use placeholders and $wpdb->prepare(); found interpolated variable $this at "DESC {$this->object_map_table}"
          Open

                  $allowed_fields   = $this->wpdb->get_col( "DESC {$this->object_map_table}", 0 );
          Severity
          Category
          Status
          Source
          Language