MinnPost/object-sync-for-salesforce

View on GitHub

Showing 364 of 364 total issues

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

        if ( is_wp_error( $term ) ) {
            $success = false;
            $errors  = $term;
        } else {
            $term_id     = $term[ "$id_field" ];
Severity: Major
Found in classes/class-object-sync-sf-wordpress.php and 1 other location - About 1 hr to fix
classes/class-object-sync-sf-wordpress.php on lines 1951..1961

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

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( $term ) ) {
            $success = false;
            $errors  = $term;
        } else {
            $term_id     = $term[ "$id_field" ];
Severity: Major
Found in classes/class-object-sync-sf-wordpress.php and 1 other location - About 1 hr to fix
classes/class-object-sync-sf-wordpress.php on lines 2153..2163

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

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_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 object_create has 36 lines of code (exceeds 25 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 1 hr to fix

      Method term_update has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function term_update( $term_id, $params, $taxonomy, $id_field = 'ID' ) {
              if ( 'tag' === $taxonomy ) {
                  $taxonomy = 'post_tag';
              }
              $args = array();
      Severity: Minor
      Found in classes/class-object-sync-sf-wordpress.php - About 1 hr to fix

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

          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

            Function get_all_object_maps has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

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

                private function comment_create( $params, $id_field = 'comment_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( 'comment' );
                    foreach ( $params as $key => $value ) {
            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 user_update has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                private function user_update( $user_id, $params, $id_field = 'ID' ) {
                    $content              = array();
                    $content[ $id_field ] = $user_id;
                    foreach ( $params as $key => $value ) {
            
            
            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 term_create has a Cognitive Complexity of 12 (exceeds 5 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

            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 refresh_token has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function refresh_token() {
                    $refresh_token = $this->get_refresh_token();
                    if ( empty( $refresh_token ) ) {
                        throw new Object_Sync_Sf_Exception( esc_html__( 'There is no refresh token.', 'object-sync-for-salesforce' ) );
                    }
            Severity: Minor
            Found in classes/class-object-sync-sf-salesforce.php - About 1 hr to fix

              Method fields_errors has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function fields_errors( $page, $section, $callbacks ) {
              
                      add_settings_section( $section, __( 'Mapping Error Settings', 'object-sync-for-salesforce' ), null, $page );
                      $error_settings = array(
                          'errors_per_page' => array(
              Severity: Minor
              Found in classes/class-object-sync-sf-admin.php - About 1 hr to fix

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

                                        <?php if ( '' !== esc_url( $this->wordpress->object_edit_link( $mapping_error['wordpress_object'], $mapping_error['wordpress_id'] ) ) ) : ?>
                                            <span class="edit">
                                            <a href="<?php echo esc_url( $this->wordpress->object_edit_link( $mapping_error['wordpress_object'], $mapping_error['wordpress_id'] ) ); ?>">
                                                <?php
                                                echo sprintf(
                Severity: Major
                Found in templates/admin/mapping-errors.php and 2 other locations - About 1 hr to fix
                templates/admin/mapping-errors-edit.php on lines 141..154
                templates/admin/mapping-errors.php on lines 144..156

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

                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 3 locations. Consider refactoring.
                Open

                                        <?php if ( '' !== esc_url( $this->wordpress->object_delete_link( $mapping_error['wordpress_object'], $mapping_error['wordpress_id'] ) ) ) : ?>
                                            <span class="delete">
                                            <a href="<?php echo esc_url( $this->wordpress->object_delete_link( $mapping_error['wordpress_object'], $mapping_error['wordpress_id'] ) ); ?>">
                                                <?php
                                                echo sprintf(
                Severity: Major
                Found in templates/admin/mapping-errors.php and 2 other locations - About 1 hr to fix
                templates/admin/mapping-errors-edit.php on lines 141..154
                templates/admin/mapping-errors.php on lines 127..139

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

                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 3 locations. Consider refactoring.
                Open

                    <?php if ( '' !== esc_url( $this->wordpress->object_edit_link( $map_row['wordpress_object'], $map_row['wordpress_id'] ) ) ) : ?>
                        <li>
                            <span class="dashicons dashicons-edit-large"></span>
                            <a href="<?php echo esc_url( $this->wordpress->object_edit_link( $map_row['wordpress_object'], $map_row['wordpress_id'] ) ); ?>">
                                <?php
                Severity: Major
                Found in templates/admin/mapping-errors-edit.php and 2 other locations - About 1 hr to fix
                templates/admin/mapping-errors.php on lines 127..139
                templates/admin/mapping-errors.php on lines 144..156

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

                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 prepare_object_map_data has 34 lines of code (exceeds 25 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 1 hr to fix

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

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

                      Method user_update has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function user_update( $user_id, $params, $id_field = 'ID' ) {
                              $content              = array();
                              $content[ $id_field ] = $user_id;
                              foreach ( $params as $key => $value ) {
                      
                      
                      Severity: Minor
                      Found in classes/class-object-sync-sf-wordpress.php - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language