MinnPost/object-sync-for-salesforce

View on GitHub

Showing 364 of 364 total issues

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

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

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

                                                    if ( true === $disable_mapped_fields ) {
                                                        $key    = null;
                                                        $needle = $salesforce_field['name']; // the current Salesforce field.
                                                        // check the already mapped fields for the current field.
                                                        array_walk(
                Severity: Major
                Found in templates/admin/fieldmaps-add-edit-clone.php and 1 other location - About 1 hr to fix
                templates/admin/fieldmaps-add-edit-clone.php on lines 395..411

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

                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

                                                    if ( true === $disable_mapped_fields ) {
                                                        $key    = null;
                                                        $needle = $wordpress_field['key']; // the current WP field.
                                                        // check the already mapped fields for the current field.
                                                        array_walk(
                Severity: Major
                Found in templates/admin/fieldmaps-add-edit-clone.php and 1 other location - About 1 hr to fix
                templates/admin/fieldmaps-add-edit-clone.php on lines 447..463

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

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

                    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

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