MinnPost/object-sync-for-salesforce

View on GitHub

Showing 241 of 364 total issues

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

    Method display_input_field has 45 lines of code (exceeds 25 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

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

        Function loadFieldOptions has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function loadFieldOptions( system, objectName ) {
            var data = {
                'action': 'get_' + system + '_object_fields'
            };
            var selectField = '.column-' + system + '_field select';
        Severity: Minor
        Found in assets/js/src/02-load-field-options.js - About 1 hr to fix

          Method attachment_create has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function attachment_create( $params, $id_field = '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( 'attachment' );
                  // WP requires post_title, post_content (can be empty), post_status, and post_mime_type to create an attachment.
          Severity: Minor
          Found in classes/class-object-sync-sf-wordpress.php - About 1 hr to fix

            Method term_create has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function term_create( $params, $taxonomy, $id_field = 'ID' ) {
                    if ( 'tag' === $taxonomy ) {
                        $taxonomy = 'post_tag';
                    }
                    // Load all params with a method_modify of the object structure's content_method into $content.
            Severity: Minor
            Found in classes/class-object-sync-sf-wordpress.php - About 1 hr to fix

              Function status has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function status( $sfapi ) {
              
                      $contacts = $sfapi->query( 'SELECT Name, Id from Contact LIMIT 100' );
              
                      if ( 200 !== $contacts['code'] ) {
              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 create_object_map has 43 lines of code (exceeds 25 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 1 hr to fix

                Method object_delete has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function object_delete( $name, $id ) {
                        $structure = $this->get_wordpress_table_structure( $name );
                        $id_field  = $structure['id_field'];
                
                        switch ( $name ) {
                Severity: Minor
                Found in classes/class-object-sync-sf-wordpress.php - About 1 hr to fix

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

                    Function display_notices has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function display_notices() {
                    
                            // before a notice is displayed, we should make sure we are on a page related to this plugin.
                            if ( ! isset( $_GET['page'] ) || $this->admin_settings_url_param !== $_GET['page'] ) {
                                return;
                    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 loadFieldOptions has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function loadFieldOptions( system, objectName ) {
                        var data = {
                            'action': 'get_' + system + '_object_fields'
                        };
                        var selectField = '.column-' + system + '_field select';
                    Severity: Minor
                    Found in assets/js/src/02-load-field-options.js - 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 attachment_create has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function attachment_create( $params, $id_field = '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( 'attachment' );
                            // WP requires post_title, post_content (can be empty), post_status, and post_mime_type to create an attachment.
                    Severity: Minor
                    Found in classes/class-object-sync-sf-wordpress.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 can_process has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function can_process( WP_REST_Request $request ) {
                            // unless we specify it here, the method will not be allowed unless the user has configure_salesforce capability.
                            $http_method = $request->get_method();
                            $class       = $request->get_url_params()['class'];
                            switch ( $class ) {
                    Severity: Minor
                    Found in classes/class-object-sync-sf-rest.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 display_select has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function display_select( $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

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

                        Method display_checkboxes has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function display_checkboxes( $args ) {
                                $type       = 'checkbox';
                                $name       = $args['name'];
                                $options    = get_option( $name, array() );
                                $group_desc = $args['desc'];
                        Severity: Minor
                        Found in classes/class-object-sync-sf-admin.php - About 1 hr to fix

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

                            Method object_update has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function object_update( $name, $id, $params, $mapping_object = array() ) {
                            
                                    $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 get_wordpress_object_data has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function get_wordpress_object_data( $object_type, $object_id, $is_deleted = false ) {
                                      $wordpress_object       = array();
                                      $object_table_structure = $this->get_wordpress_table_structure( $object_type );
                              
                                      $meta_table      = $object_table_structure['meta_table'];
                              Severity: Minor
                              Found in classes/class-object-sync-sf-wordpress.php - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language