MinnPost/object-sync-for-salesforce

View on GitHub

Showing 364 of 364 total issues

Function add_actions has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    public function add_actions() {
        $db_version = get_option( $this->option_prefix . 'db_version', false );
        if ( $db_version === $this->version ) {
            foreach ( $this->mappings->get_fieldmaps( null, $this->mappings->active_fieldmap_conditions ) as $mapping ) {
                $object_type = $mapping['wordpress_object'];
Severity: Minor
Found in classes/class-object-sync-sf-salesforce-push.php - About 3 hrs 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 run_analytics_report has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    public function run_analytics_report( $id, $async = true, $clear_cache = false, $params = array(), $method = 'GET', $report_cache_expiration = '', $cache_instance = true, $instance_cache_expiration = '' ) {

        $id         = $this->convert_id( $id );
        $report_url = 'analytics/reports/' . $id . '/instances';

Severity: Minor
Found in classes/class-object-sync-sf-salesforce.php - About 3 hrs 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

Object_Sync_Sf_Salesforce_Pull has 29 functions (exceeds 20 allowed). Consider refactoring.
Open

class Object_Sync_Sf_Salesforce_Pull {

    /**
     * Current version of the plugin
     *
Severity: Minor
Found in classes/class-object-sync-sf-salesforce-pull.php - About 3 hrs to fix

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

    $( document ).on( 'change', 'select#salesforce_object', function() {
        var timeout;
        loadFieldOptions( 'salesforce', $( this ).val() );
        clearTimeout( timeout );
        timeout = setTimeout( function() {
    Severity: Major
    Found in assets/js/src/02-load-field-options.js and 1 other location - About 3 hrs to fix
    assets/js/src/02-load-field-options.js on lines 55..63

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

    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

    $( document ).on( 'change', 'select#wordpress_object', function() {
        var timeout;
        loadFieldOptions( 'wordpress', $( this ).val() );
        clearTimeout( timeout );
        timeout = setTimeout( function() {
    Severity: Major
    Found in assets/js/src/02-load-field-options.js and 1 other location - About 3 hrs to fix
    assets/js/src/02-load-field-options.js on lines 66..74

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

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

    Method get_deleted_records has 83 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function get_deleted_records() {
    
            $sfapi = $this->salesforce['sfapi'];
    
            // Load all unique SF record types that we have mappings for. This results in a double loop.
    Severity: Major
    Found in classes/class-object-sync-sf-salesforce-pull.php - About 3 hrs to fix

      Function salesforceObjectFields has 82 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function salesforceObjectFields() {
      
          var delay = ( function() {
              var timer = 0;
              return function( callback, ms ) {
      Severity: Major
      Found in assets/js/src/01-salesforce-object.js - About 3 hrs to fix

        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.
        Severity: Minor
        Found in classes/class-object-sync-sf-wordpress.php - About 3 hrs 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

        Method notices_data has 81 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function notices_data() {
                $notices = array(
                    'permission'              => array(
                        'condition'   => ( false === $this->check_wordpress_admin_permissions() ),
                        'message'     => __( "Your account does not have permission to edit the Object Sync for Salesforce plugin's settings.", 'object-sync-for-salesforce' ),
        Severity: Major
        Found in classes/class-object-sync-sf-admin.php - About 3 hrs to fix

          Function prepare_fieldmap_data has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

              public function prepare_fieldmap_data() {
                  $error     = false;
                  $post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_SPECIAL_CHARS );
                  $cachekey  = wp_json_encode( $post_data );
                  if ( false !== $cachekey ) {
          Severity: Minor
          Found in classes/class-object-sync-sf-admin.php - About 3 hrs 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 http_request has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function http_request( $url, $data, $headers = array(), $method = 'GET', $options = array() ) {
                  // Build the request, including path and headers. Internal use.
          
                  /**
                   * Short-circuits the return value of an HTTP API call.
          Severity: Minor
          Found in classes/class-object-sync-sf-salesforce.php - About 3 hrs 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

                  if ( is_wp_error( $post_id ) ) {
                      $success = false;
                      $errors  = $post_id;
                  } else {
                      // If it's a custom record type, fix the methods.
          Severity: Major
          Found in classes/class-object-sync-sf-wordpress.php and 1 other location - About 3 hrs to fix
          classes/class-object-sync-sf-wordpress.php on lines 1529..1543

          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

          Further Reading

          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',
          Severity: Major
          Found in classes/class-object-sync-sf-wordpress.php and 2 other locations - About 3 hrs to fix
          classes/class-object-sync-sf-wordpress.php on lines 234..258
          classes/class-object-sync-sf-wordpress.php on lines 307..331

          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

          Further Reading

          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',
          Severity: Major
          Found in classes/class-object-sync-sf-wordpress.php and 2 other locations - About 3 hrs to fix
          classes/class-object-sync-sf-wordpress.php on lines 174..331
          classes/class-object-sync-sf-wordpress.php on lines 234..258

          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

          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.
          Severity: Major
          Found in classes/class-object-sync-sf-wordpress.php and 1 other location - About 3 hrs to fix
          classes/class-object-sync-sf-wordpress.php on lines 1296..1310

          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

          Further Reading

          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',
          Severity: Major
          Found in classes/class-object-sync-sf-wordpress.php and 2 other locations - About 3 hrs to fix
          classes/class-object-sync-sf-wordpress.php on lines 174..331
          classes/class-object-sync-sf-wordpress.php on lines 307..331

          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

          Further Reading

          Method get_pull_query has 76 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function get_pull_query( $type, $salesforce_mapping = array(), $force_current_offset = false ) {
                  // we need to determine what to do with saved queries. this is what we currently do but it doesn't work.
                  // check if we have a stored next query to run for this type. if so, unserialize it so we have an object.
                  $pull_query_running = $this->pull_options->get( 'current_query', $type, $salesforce_mapping['id'], '' );
                  if ( '' !== $pull_query_running ) {
          Severity: Major
          Found in classes/class-object-sync-sf-salesforce-pull.php - About 3 hrs to fix

            Object_Sync_Sf_Salesforce_Push has 26 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Object_Sync_Sf_Salesforce_Push {
            
                /**
                 * Current version of the plugin
                 *
            Severity: Minor
            Found in classes/class-object-sync-sf-salesforce-push.php - About 3 hrs to fix

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

                  public function set( $operation, $object_type = '', $fieldmap_id = '', $value = '', $autoload = false ) {
                      // generate the option key parameters.
                      $params = array(
                          'operation'   => $operation,
                          'object_type' => $object_type,
              Severity: Major
              Found in classes/class-object-sync-sf-pull-options.php and 1 other location - About 2 hrs to fix
              classes/class-object-sync-sf-sync-transients.php on lines 89..117

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

              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

              Severity
              Category
              Status
              Source
              Language