MinnPost/object-sync-for-salesforce

View on GitHub

Showing 241 of 364 total issues

Method attachment_update has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function attachment_update( $attachment_id, $params, $id_field = 'ID' ) {
        $content              = array();
        $content[ $id_field ] = $attachment_id;
        foreach ( $params as $key => $value ) {
            if ( 'wp_insert_attachment' === $value['method_modify'] ) { // Should also be insert attachment maybe.
Severity: Major
Found in classes/class-object-sync-sf-wordpress.php - About 2 hrs to fix

    Method post_create has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function post_create( $params, $id_field = 'ID', $post_type = 'post' ) {
            // Load all params with a method_modify of the object structure's content_method into $content.
            $content   = array();
            $structure = $this->get_wordpress_table_structure( $post_type );
            foreach ( $params as $key => $value ) {
    Severity: Major
    Found in classes/class-object-sync-sf-wordpress.php - About 2 hrs to fix

      Function get_pull_query has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          private function get_pull_query( $type, $salesforce_mapping = array() ) {
              // 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: Minor
      Found in classes/class-object-sync-sf-salesforce-pull.php - About 2 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 post_actions has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public function post_actions( $post_id, $post ) {
      
              // if this runs on a non-object due to another operation, don't continue.
              if ( ! is_object( $post ) ) {
                  return;
      Severity: Minor
      Found in classes/class-object-sync-sf-salesforce-push.php - About 2 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 get_object_maps has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public function get_object_maps( $conditions = array(), $reset = false ) {
              $table = $this->object_map_table;
              $order = ' ORDER BY object_updated, created';
              if ( ! empty( $conditions ) ) { // get multiple but with a limitation.
                  $mappings = array();
      Severity: Minor
      Found in classes/class-object-sync-sf-mapping.php - About 2 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 user_create has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          private function user_create( $params, $id_field = 'ID' ) {
      
              // Allow username to be email address or username.
              // The username could be autogenerated before this point for the sake of URLs.
              $username      = $params['user_email']['value'];
      Severity: Minor
      Found in classes/class-object-sync-sf-wordpress.php - About 2 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 run_analytics_report has 56 lines of code (exceeds 25 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: Major
      Found in classes/class-object-sync-sf-salesforce.php - About 2 hrs to fix

        Method user_create has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function user_create( $params, $id_field = 'ID' ) {
        
                // Allow username to be email address or username.
                // The username could be autogenerated before this point for the sake of URLs.
                $username      = $params['user_email']['value'];
        Severity: Major
        Found in classes/class-object-sync-sf-wordpress.php - About 2 hrs to fix

          Method get_fieldmaps has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function get_fieldmaps( $id = null, $conditions = array(), $reset = false ) {
                  $table = $this->fieldmap_table;
                  if ( null !== $id ) { // get one fieldmap.
                      $map        = $this->wpdb->get_row( 'SELECT * FROM ' . $table . ' WHERE id = ' . $id, ARRAY_A );
                      $mappings   = array();
          Severity: Major
          Found in classes/class-object-sync-sf-mapping.php - About 2 hrs to fix

            Method resave_action_schedules has 54 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function resave_action_schedules() {
                    // for each schedulable action, go ahead and resave it.
                    $schedules_updated  = array();
                    $schedules_restored = array();
                    foreach ( $this->schedulable_classes as $key => $value ) {
            Severity: Major
            Found in classes/class-object-sync-sf-admin.php - About 2 hrs to fix

              Function get_next_record_batch has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function get_next_record_batch( $last_sync, $salesforce_mapping, $map_sync_triggers, $type, $version_path, $query_options, $response ) {
                      // Handle next batch of records if it exists.
                      $next_records_url = isset( $response['nextRecordsUrl'] ) ? str_replace( $version_path, '', $response['nextRecordsUrl'] ) : false;
                      while ( $next_records_url ) {
                          // shouldn't cache this either. it's going into the queue if it exists anyway.
              Severity: Minor
              Found in classes/class-object-sync-sf-salesforce-pull.php - About 2 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 maybe_upgrade_sync_triggers has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function maybe_upgrade_sync_triggers( $sync_triggers, $mapping_version, $mapping_id = '' ) {
                      // in v2 of this plugin, we replaced the bit flags with strings to make them more legible.
                      if ( version_compare( $mapping_version, '2.0.0', '<' ) ) {
                          // check if the triggers stored in the database are up to date. if not, update them.
                          $intersect = array_intersect( $sync_triggers, array_merge( $this->wordpress_events, $this->salesforce_events ) );
              Severity: Minor
              Found in classes/class-object-sync-sf-mapping.php - About 1 hr to fix

                Method __construct has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function __construct() {
                        $this->version       = object_sync_for_salesforce()->version;
                        $this->file          = object_sync_for_salesforce()->file;
                        $this->wpdb          = object_sync_for_salesforce()->wpdb;
                        $this->slug          = object_sync_for_salesforce()->slug;
                Severity: Minor
                Found in classes/class-object-sync-sf-mapping.php - About 1 hr to fix

                  Method comment_create has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function comment_create( $params, $id_field = 'comment_ID' ) {
                          // Load all params with a method_modify of the object structure's content_method into $content.
                          $content   = array();
                          $structure = $this->get_wordpress_table_structure( 'comment' );
                          foreach ( $params as $key => $value ) {
                  Severity: Minor
                  Found in classes/class-object-sync-sf-wordpress.php - About 1 hr to fix

                    Function resave_action_schedules has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function resave_action_schedules() {
                            // for each schedulable action, go ahead and resave it.
                            $schedules_updated  = array();
                            $schedules_restored = array();
                            foreach ( $this->schedulable_classes as $key => $value ) {
                    Severity: Minor
                    Found in classes/class-object-sync-sf-admin.php - About 1 hr 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 display_input_field has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function display_input_field( $args ) {
                            $type    = $args['type'];
                            $id      = $args['label_for'];
                            $name    = $args['name'];
                            $desc    = $args['desc'];
                    Severity: Minor
                    Found in classes/class-object-sync-sf-admin.php - About 1 hr 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_salesforce_object_fields has 46 lines of code (exceeds 25 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 1 hr to fix

                      Method object_upsert has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function object_upsert( $name, $key, $value, $methods, $params, $pull_to_drafts = false, $check_only = false ) {
                      
                              $structure = $this->get_wordpress_table_structure( $name );
                              $id_field  = $structure['id_field'];
                      
                      
                      Severity: Minor
                      Found in classes/class-object-sync-sf-wordpress.php - About 1 hr to fix

                        Method prepare_fieldmap_data has 45 lines of code (exceeds 25 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 1 hr to fix

                          Method get_salesforce_object_description has 45 lines of code (exceeds 25 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 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language