MinnPost/object-sync-for-salesforce

View on GitHub

Showing 364 of 364 total issues

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

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

    private function get_merged_records() {

        $use_soap = $this->salesforce['soap_loaded'];
        if ( true === $use_soap ) {
            $soap = new Object_Sync_Sf_Salesforce_Soap_Partner();
Severity: Major
Found in classes/class-object-sync-sf-salesforce-pull.php - About 2 hrs to fix

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

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

                        } else if ( 'salesforce' === system ) {
                            var fieldLabel = '';
                            if ( 'undefined' !== typeof value.label ) {
                                fieldLabel = value.label;
                            } else {
        Severity: Major
        Found in assets/js/src/02-load-field-options.js and 1 other location - About 2 hrs to fix
        assets/js/src/01-salesforce-object.js on lines 57..65

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

        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

        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

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

                            $.each( response.data.fields, function( index, value ) {
                                var fieldLabel = '';
                                if ( 'undefined' !== typeof value.label ) {
                                    fieldLabel = value.label;
                                } else {
        Severity: Major
        Found in assets/js/src/01-salesforce-object.js and 1 other location - About 2 hrs to fix
        assets/js/src/02-load-field-options.js on lines 36..44

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

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

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

                          if ( false === $result ) { // if the database didn't save, it's still an error.
                              $this->sfwp_transients->set( $cachekey, $post_data, $this->wordpress->options['cache_expiration'] );
                              if ( '' !== $cachekey ) {
                                  $url = esc_url_raw( $post_data['redirect_url_error'] ) . '&mapping_error_transient=' . $cachekey;
                              }
          Severity: Major
          Found in classes/class-object-sync-sf-admin.php and 1 other location - About 2 hrs to fix
          classes/class-object-sync-sf-admin.php on lines 1909..1920

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

          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 ( false === $result ) { // if the database didn't save, it's still an error.
                          $this->sfwp_transients->set( $cachekey, $post_data, $this->wordpress->options['cache_expiration'] );
                          if ( '' !== $cachekey ) {
                              $url = esc_url_raw( $post_data['redirect_url_error'] ) . '&map_transient=' . $cachekey;
                          }
          Severity: Major
          Found in classes/class-object-sync-sf-admin.php and 1 other location - About 2 hrs to fix
          classes/class-object-sync-sf-admin.php on lines 1964..1975

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

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

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

                        foreach ( $transients_to_delete as $key => $value ) {
                            $fieldmap_id = $value['fieldmap']['id'];
                            $transients  = (array) $value['transients'];
                            foreach ( $transients as $transient_end ) {
                                $this->sync_transients->delete( 'salesforce_pulling_' . $transient_end, '', $fieldmap_id );
                Severity: Major
                Found in classes/class-object-sync-sf-salesforce-push.php and 1 other location - About 2 hrs to fix
                classes/class-object-sync-sf-salesforce-pull.php on lines 1535..1545

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

                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

                        foreach ( $transients_to_delete as $key => $value ) {
                            $fieldmap_id = $value['fieldmap']['id'];
                            $transients  = (array) $value['transients'];
                            foreach ( $transients as $transient_end ) {
                                $this->sync_transients->delete( 'salesforce_pushing_' . $transient_end, '', $fieldmap_id );
                Severity: Major
                Found in classes/class-object-sync-sf-salesforce-pull.php and 1 other location - About 2 hrs to fix
                classes/class-object-sync-sf-salesforce-push.php on lines 747..757

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

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