MinnPost/object-sync-for-salesforce

View on GitHub

Showing 364 of 364 total issues

Function get_wordpress_object_data has a Cognitive Complexity of 9 (exceeds 5 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 55 mins 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 object_update has a Cognitive Complexity of 9 (exceeds 5 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 55 mins 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 object_create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function object_create( $name, $params ) {

        $structure = $this->get_wordpress_table_structure( $name );
        $id_field  = $structure['id_field'];

Severity: Minor
Found in classes/class-object-sync-sf-wordpress.php - About 55 mins 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

        if ( is_wp_error( $comment_id ) ) {
            $success = false;
            $errors  = $comment_id;
        } else {
            $meta_result = $this->create_wp_meta( $params, $comment_id, 'comment' );
Severity: Minor
Found in classes/class-object-sync-sf-wordpress.php and 1 other location - About 55 mins to fix
classes/class-object-sync-sf-wordpress.php on lines 1206..1215

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

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 ( is_wp_error( $user_id ) ) {
            $success = false;
            $errors  = $user_id;
        } else {
            $meta_result = $this->update_wp_meta( $params, $user_id, 'user' );
Severity: Minor
Found in classes/class-object-sync-sf-wordpress.php and 1 other location - About 55 mins to fix
classes/class-object-sync-sf-wordpress.php on lines 2243..2252

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

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 ( isset( $posts ) && isset( $posts[0]->{$id_field} ) ) {
                // Attachment does exist after checking the matching value. we want its id.
                $attachment_id = $posts[0]->{$id_field};

                if ( true === $check_only ) {
Severity: Minor
Found in classes/class-object-sync-sf-wordpress.php and 1 other location - About 55 mins to fix
classes/class-object-sync-sf-wordpress.php on lines 1391..1429

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

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 get_next_record_batch has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    private function get_next_record_batch( $last_sync, $salesforce_mapping, $map_sync_triggers, $type, $version_path, $query_options, $response ) {
Severity: Major
Found in classes/class-object-sync-sf-salesforce-pull.php - About 50 mins to fix

    Method comment_upsert has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        private function comment_upsert( $key, $value, $methods, $params, $id_field = 'comment_ID', $pull_to_drafts = false, $check_only = false ) {
    Severity: Major
    Found in classes/class-object-sync-sf-wordpress.php - About 50 mins to fix

      Method user_upsert has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          private function user_upsert( $key, $value, $methods, $params, $id_field = 'ID', $pull_to_drafts = false, $check_only = false ) {
      Severity: Major
      Found in classes/class-object-sync-sf-wordpress.php - About 50 mins to fix

        Method object_upsert has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function object_upsert( $name, $key, $value, $methods, $params, $pull_to_drafts = false, $check_only = false ) {
        Severity: Major
        Found in classes/class-object-sync-sf-wordpress.php - About 50 mins to fix

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

                  if ( isset( $post_data['id'] ) ) {
                      $result = $this->mappings->delete_object_map( $post_data['id'] );
                      if ( true === $result ) {
                          $url = esc_url_raw( $post_data['redirect_url_success'] );
                      } else {
          Severity: Minor
          Found in classes/class-object-sync-sf-admin.php and 1 other location - About 45 mins to fix
          classes/class-object-sync-sf-admin.php on lines 1867..1876

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

          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 ( $post_data['id'] ) {
                      $result = $this->mappings->delete_fieldmap( $post_data['id'] );
                      if ( true === $result ) {
                          $url = esc_url_raw( $post_data['redirect_url_success'] );
                      } else {
          Severity: Minor
          Found in classes/class-object-sync-sf-admin.php and 1 other location - About 45 mins to fix
          classes/class-object-sync-sf-admin.php on lines 1934..1979

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

          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 tabs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              private function tabs( $tabs, $tab = '' ) {
          
                  $get_data        = filter_input_array( INPUT_GET, FILTER_SANITIZE_SPECIAL_CHARS );
                  $consumer_key    = $this->login_credentials['consumer_key'];
                  $consumer_secret = $this->login_credentials['consumer_secret'];
          Severity: Minor
          Found in classes/class-object-sync-sf-admin.php - About 45 mins 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_called_from_salesforce has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              private function create_called_from_salesforce( $sf_sync_trigger, $synced_object, $params, $prematch, $wordpress_id_field_name, $seconds ) {
          Severity: Minor
          Found in classes/class-object-sync-sf-salesforce-pull.php - About 45 mins to fix

            Method map_params has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function map_params( $mapping, $object, $trigger, $use_soap = false, $is_new = true, $object_id_field = '' ) {
            Severity: Minor
            Found in classes/class-object-sync-sf-mapping.php - About 45 mins to fix

              Function init has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function init() {
                      if ( false === $this->salesforce_get_api['soap_available'] ) {
                          return;
                      }
                      if ( ! class_exists( 'SforceBaseClient' ) && file_exists( plugin_dir_path( $this->file ) . 'vendor/autoload.php' ) ) {
              Severity: Minor
              Found in classes/class-object-sync-sf-salesforce-soap-partner.php - About 45 mins 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 attachment_upsert has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  private function attachment_upsert( $key, $value, $methods, $params, $id_field = 'ID', $check_only = false ) {
              Severity: Minor
              Found in classes/class-object-sync-sf-wordpress.php - About 45 mins to fix

                Function __toString has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function __toString() {
                
                        $query  = 'SELECT ';
                        $query .= implode( ', ', $this->fields );
                        $query .= ' FROM ' . $this->object_type;
                Severity: Minor
                Found in classes/class-object-sync-sf-salesforce-select-query.php - About 45 mins 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_update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function post_update( $post_id, $params, $id_field = 'ID', $post_type = '' ) {
                        $content              = array();
                        $content[ $id_field ] = $post_id;
                        foreach ( $params as $key => $value ) {
                            if ( 'wp_update_post' === $value['method_modify'] ) {
                Severity: Minor
                Found in classes/class-object-sync-sf-wordpress.php - About 45 mins 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

                $( document ).on( 'click', '.column-is_key input', function() {
                    $( '.column-is_key input' ).not( this ).prop( 'checked', false );
                } );
                Severity: Minor
                Found in assets/js/src/03-fieldmap-rows.js and 1 other location - About 45 mins to fix
                assets/js/src/03-fieldmap-rows.js on lines 99..101

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

                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

                Severity
                Category
                Status
                Source
                Language