MinnPost/object-sync-for-salesforce

View on GitHub

Showing 241 of 364 total issues

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

      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

          Function delete_called_from_salesforce has a Cognitive Complexity of 21 (exceeds 5 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: 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 show_salesforce_user_fields has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              public function show_salesforce_user_fields( $user ) {
                  $get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_SPECIAL_CHARS );
                  if ( true === $this->check_wordpress_admin_permissions() ) {
                      $mappings = $this->mappings->load_all_by_wordpress( 'user', $user->ID );
                      $fieldmap = $this->mappings->get_fieldmaps(
          Severity: Minor
          Found in classes/class-object-sync-sf-admin.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 attachment_update has a Cognitive Complexity of 20 (exceeds 5 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: 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 update_called_from_salesforce has 68 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

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

            Method object_fields has 67 lines of code (exceeds 25 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: Major
            Found in classes/class-object-sync-sf-wordpress.php - About 2 hrs to fix

              Method wordpress_salesforce_tables has 65 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function wordpress_salesforce_tables() {
              
                      $charset_collate = $this->wpdb->get_charset_collate();
              
                      $field_map_table = $this->wpdb->prefix . 'object_sync_sf_field_map';
              Severity: Major
              Found in classes/class-object-sync-sf-activate.php - About 2 hrs to fix

                Function manual_push has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function manual_push( $object_type, $wordpress_id, $http_method ) {
                        $object = $this->wordpress->get_wordpress_object_data( $object_type, $wordpress_id );
                        // run the WordPress trigger that corresponds to the HTTP method.
                        switch ( $http_method ) {
                            case 'POST':
                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 post_create has a Cognitive Complexity of 19 (exceeds 5 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: 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

                Object_Sync_Sf_Logging has 23 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class Object_Sync_Sf_Logging extends WP_Logging {
                
                    /**
                     * Current version of the plugin
                     *
                Severity: Minor
                Found in classes/class-object-sync-sf-logging.php - About 2 hrs to fix

                  Object_Sync_Sf_Mapping has 23 functions (exceeds 20 allowed). Consider refactoring.
                  Open

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

                    Function get_pull_query has a Cognitive Complexity of 18 (exceeds 5 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: 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 prepare_object_map_data has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function prepare_object_map_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 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_mapped_fields has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function get_mapped_fields( $mapping, $directions = array() ) {
                            $mapped_fields = array();
                            foreach ( $mapping['fields'] as $fields ) {
                                if ( empty( $directions ) || in_array( $fields['direction'], $directions, true ) ) {
                    
                    
                    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

                    Severity
                    Category
                    Status
                    Source
                    Language