MinnPost/object-sync-for-salesforce

View on GitHub

Showing 364 of 364 total issues

Method comment_upsert has 123 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function comment_upsert( $key, $value, $methods, $params, $id_field = 'comment_ID', $pull_to_drafts = false, $check_only = false ) {
        $method = isset( $methods['method_match'] ) ? $methods['method_match'] : '';
        if ( 'get_comment' === $method ) {
            $method = 'get_comments';
        }
Severity: Major
Found in classes/class-object-sync-sf-wordpress.php - About 4 hrs to fix

    Function get_salesforce_object_description has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

        public function get_salesforce_object_description( $data = array() ) {
            $ajax = false;
            if ( empty( $data ) ) {
                $data = filter_input_array( INPUT_POST, FILTER_SANITIZE_SPECIAL_CHARS );
                $ajax = true;
    Severity: Minor
    Found in classes/class-object-sync-sf-admin.php - About 4 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 http_request has 120 lines of code (exceeds 25 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: Major
    Found in classes/class-object-sync-sf-salesforce.php - About 4 hrs to fix

      Object_Sync_Sf_Salesforce has 36 functions (exceeds 20 allowed). Consider refactoring.
      Open

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

        Method post_upsert has 112 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function post_upsert( $key, $value, $methods, $params, $id_field = 'ID', $pull_to_drafts = false, $post_type = 'post', $check_only = false ) {
        
                $method = isset( $methods['method_match'] ) ? $methods['method_match'] : '';
                if ( '' !== $method ) {
                    // By default, posts use get_posts as the method. args can be like this.
        Severity: Major
        Found in classes/class-object-sync-sf-wordpress.php - About 4 hrs to fix

          Function delete_object_map has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
          Open

              public function delete_object_map() {
                  $post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_SPECIAL_CHARS );
                  if ( isset( $post_data['id'] ) ) {
                      $result = $this->mappings->delete_object_map( $post_data['id'] );
                      if ( true === $result ) {
          Severity: Minor
          Found in classes/class-object-sync-sf-admin.php - About 4 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

          File class-object-sync-sf-logging.php has 347 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          /**
           * Log events based on plugin settings. Extend the WP_Logging class for the purposes of Object Sync for Salesforce.
           *
           * @class   Object_Sync_Sf_Logging
          Severity: Minor
          Found in classes/class-object-sync-sf-logging.php - About 4 hrs to fix

            Method attachment_upsert has 107 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function attachment_upsert( $key, $value, $methods, $params, $id_field = 'ID', $check_only = false ) {
            
                    $method = isset( $methods['method_match'] ) ? $methods['method_match'] : '';
                    if ( '' !== $method ) {
                        // Get_posts is more helpful here, so that is the method attachment uses for 'read'.
            Severity: Major
            Found in classes/class-object-sync-sf-wordpress.php - About 4 hrs to fix

              Method fields_scheduling has 103 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function fields_scheduling( $page, $section, $callbacks ) {
              
                      add_settings_section( 'batch', __( 'Batch Settings', 'object-sync-for-salesforce' ), null, $page );
                      $section           = 'batch';
                      $schedule_settings = array(
              Severity: Major
              Found in classes/class-object-sync-sf-admin.php - About 4 hrs to fix

                Method api_http_request has 103 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function api_http_request( $path, $params, $method, $options = array(), $type = 'rest' ) {
                        // this merge will override a value in $this->options with the one in $options parameter if there is a matching key.
                        $options = array_merge( $this->options, $options );
                        $url     = $this->get_api_endpoint( $type ) . $path;
                        if ( isset( $options['full_url'] ) && true === $options['full_url'] ) {
                Severity: Major
                Found in classes/class-object-sync-sf-salesforce.php - About 4 hrs to fix

                  Function get_salesforce_object_fields has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function get_salesforce_object_fields( $data = array() ) {
                          $ajax      = false;
                          $post_data = filter_input_array( INPUT_POST, FILTER_UNSAFE_RAW );
                          if ( empty( $data ) ) {
                              $salesforce_object = isset( $post_data['salesforce_object'] ) ? sanitize_text_field( wp_unslash( $post_data['salesforce_object'] ) ) : '';
                  Severity: Minor
                  Found in classes/class-object-sync-sf-admin.php - About 4 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 setup_fieldmap_data has 99 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function setup_fieldmap_data( $posted = array(), $wordpress_fields = array(), $salesforce_fields = array() ) {
                          $data = array(
                              'label'             => $posted['label'],
                              'name'              => sanitize_title( $posted['label'] ),
                              'salesforce_object' => $posted['salesforce_object'],
                  Severity: Major
                  Found in classes/class-object-sync-sf-mapping.php - About 3 hrs to fix

                    Method term_upsert has 97 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function term_upsert( $key, $value, $methods, $params, $taxonomy, $id_field = 'ID', $pull_to_drafts = false, $check_only = false ) {
                            if ( 'tag' === $taxonomy ) {
                                $taxonomy = 'post_tag';
                            }
                            $method = isset( $methods['method_match'] ) ? $methods['method_match'] : '';
                    Severity: Major
                    Found in classes/class-object-sync-sf-wordpress.php - About 3 hrs to fix

                      Method delete_called_from_salesforce has 95 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function delete_called_from_salesforce( $sf_sync_trigger, $synced_object, $wordpress_id_field_name, $seconds, $mapping_objects ) {
                      
                              $salesforce_mapping = $synced_object['mapping'];
                              $mapping_object     = $synced_object['mapping_object'];
                      
                      
                      Severity: Major
                      Found in classes/class-object-sync-sf-salesforce-pull.php - About 3 hrs to fix

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

                                foreach ( $log_settings as $key => $attributes ) {
                                    $id       = $this->option_prefix . $key;
                                    $name     = $this->option_prefix . $key;
                                    $title    = $attributes['title'];
                                    $callback = $attributes['callback'];
                        Severity: Major
                        Found in classes/class-object-sync-sf-admin.php and 2 other locations - About 3 hrs to fix
                        classes/class-object-sync-sf-admin.php on lines 1164..1182
                        classes/class-object-sync-sf-admin.php on lines 1405..1423

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

                        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

                                    foreach ( $schedule_settings as $key => $attributes ) {
                                        $id       = $this->option_prefix . $key;
                                        $name     = $this->option_prefix . $key;
                                        $title    = $attributes['title'];
                                        $callback = $attributes['callback'];
                        Severity: Major
                        Found in classes/class-object-sync-sf-admin.php and 2 other locations - About 3 hrs to fix
                        classes/class-object-sync-sf-admin.php on lines 1357..1375
                        classes/class-object-sync-sf-admin.php on lines 1405..1423

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

                        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

                                foreach ( $error_settings as $key => $attributes ) {
                                    $id       = $this->option_prefix . $key;
                                    $name     = $this->option_prefix . $key;
                                    $title    = $attributes['title'];
                                    $callback = $attributes['callback'];
                        Severity: Major
                        Found in classes/class-object-sync-sf-admin.php and 2 other locations - About 3 hrs to fix
                        classes/class-object-sync-sf-admin.php on lines 1164..1182
                        classes/class-object-sync-sf-admin.php on lines 1357..1375

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

                        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 user_upsert has 92 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function user_upsert( $key, $value, $methods, $params, $id_field = 'ID', $pull_to_drafts = false, $check_only = false ) {
                        
                                // If the key is user_email, we need to make it just email because that is how the WordPress method reads it.
                                $method = isset( $methods['method_match'] ) ? $methods['method_match'] : '';
                                if ( '' !== $method ) {
                        Severity: Major
                        Found in classes/class-object-sync-sf-wordpress.php - About 3 hrs to fix

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

                                  $.post( ajaxurl, data, function( response ) {
                                      if ( true === response.success ) {
                                          updateSalesforceUserSummary();
                                          $( '.salesforce_user_ajax_message' ).width( $( '.mapped-salesforce-user' ).width() - 27 );
                                          $( '.salesforce_user_ajax_message' ).html( '<p>This object has been pulled from Salesforce.</p>' ).fadeIn().delay( 4000 ).fadeOut();
                          Severity: Major
                          Found in assets/js/src/04-interface-ajax-events.js and 1 other location - About 3 hrs to fix
                          assets/js/src/04-interface-ajax-events.js on lines 17..23

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

                          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

                                      $.post( ajaxurl, data, function( response ) {
                                          if ( true === response.success ) {
                                              updateSalesforceUserSummary();
                                              $( '.salesforce_user_ajax_message' ).width( $( '.mapped-salesforce-user' ).width() - 27 );
                                              $( '.salesforce_user_ajax_message' ).html( '<p>This object has been pushed to Salesforce.</p>' ).fadeIn().delay( 4000 ).fadeOut();
                          Severity: Major
                          Found in assets/js/src/04-interface-ajax-events.js and 1 other location - About 3 hrs to fix
                          assets/js/src/04-interface-ajax-events.js on lines 42..48

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

                          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