MinnPost/object-sync-for-salesforce

View on GitHub

Showing 241 of 364 total issues

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

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

        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

        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

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

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

                      Method api_call has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function api_call( $path, $params = array(), $method = 'GET', $options = array(), $type = 'rest' ) {
                              if ( ! $this->get_access_token() ) {
                                  $this->refresh_token();
                              }
                              $this->response = $this->api_http_request( $path, $params, $method, $options, $type );
                      Severity: Minor
                      Found in classes/class-object-sync-sf-salesforce.php - About 1 hr to fix

                        Method comment_update has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function comment_update( $comment_id, $params, $id_field = 'comment_ID' ) {
                                $content              = array();
                                $content[ $id_field ] = $comment_id;
                                foreach ( $params as $key => $value ) {
                                    if ( 'wp_update_comment' === $value['method_modify'] ) {
                        Severity: Minor
                        Found in classes/class-object-sync-sf-wordpress.php - About 1 hr to fix

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

                            Method log_trigger_settings has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                private function log_trigger_settings() {
                                    $triggers_to_log = get_option( $this->option_prefix . 'triggers_to_log', array() );
                                    if ( ! empty( $triggers_to_log ) ) {
                                        // in version 2.0.0 of this plugin, we replaced the bit flags with strings to make them more legible.
                                        // when the database version changes to 2.0.0, we should update the option value to use the new strings.
                            Severity: Minor
                            Found in classes/class-object-sync-sf-activate.php - About 1 hr to fix

                              Method respond_to_salesforce_merge has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  private function respond_to_salesforce_merge( $object_type, $merged_record ) {
                                      $op = 'Merge';
                                      if ( isset( $merged_record['Id'] ) && true === filter_var( $merged_record['sf:IsDeleted'], FILTER_VALIDATE_BOOLEAN ) && '' !== $merged_record['sf:MasterRecordId'] ) {
                                          $previous_sf_id  = $merged_record['Id'];
                                          $new_sf_id       = $merged_record['sf:MasterRecordId'];
                              Severity: Minor
                              Found in classes/class-object-sync-sf-salesforce-pull.php - About 1 hr to fix

                                Method wp_readme_visibility has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                function wp_readme_visibility( $string ) {
                                    // Remove github comment.
                                    $string = preg_replace( '#<!-- only:github/ -->(.*?)<!-- /only:github -->#us', '', $string );
                                    // Display WordPress comment.
                                    $string = preg_replace_callback(
                                Severity: Minor
                                Found in bin/wp-readme.php - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language