MinnPost/object-sync-for-salesforce

View on GitHub

Showing 241 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

                        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

                          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

                          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

                          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

                            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
                              Severity
                              Category
                              Status
                              Source
                              Language