MinnPost/object-sync-for-salesforce

View on GitHub

Showing 241 of 364 total issues

Method show_admin_page has 195 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function show_admin_page() {
        $get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_SPECIAL_CHARS );
        echo '<div class="wrap">';
        echo '<h1>' . esc_html( get_admin_page_title() ) . '</h1>';
        $allowed = $this->check_wordpress_admin_permissions();
Severity: Major
Found in classes/class-object-sync-sf-admin.php - About 7 hrs to fix

    Function get_deleted_records has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
    Open

        private function get_deleted_records() {
    
            $sfapi = $this->salesforce['sfapi'];
    
            // Load all unique SF record types that we have mappings for. This results in a double loop.
    Severity: Minor
    Found in classes/class-object-sync-sf-salesforce-pull.php - About 7 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 salesforce_push_object_crud has 186 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function salesforce_push_object_crud( $object_type, $object, $sf_sync_trigger, $manual = false ) {
    
            $structure               = $this->wordpress->get_wordpress_table_structure( $object_type );
            $wordpress_id_field_name = $structure['id_field'];
    
    
    Severity: Major
    Found in classes/class-object-sync-sf-salesforce-push.php - About 7 hrs to fix

      Function setup_fieldmap_data has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
      Open

          private function setup_fieldmap_data( $posted = array(), $wordpress_fields = array(), $salesforce_fields = array() ) {
              $data = array(
                  'label'             => $posted['label'],
                  'name'              => sanitize_title( $posted['label'] ),
                  'salesforce_object' => $posted['salesforce_object'],
      Severity: Minor
      Found in classes/class-object-sync-sf-mapping.php - About 7 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 fields_log_settings has 181 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function fields_log_settings( $page, $section, $callbacks ) {
              add_settings_section( $page, ucwords( str_replace( '_', ' ', $page ) ), null, $page );
              $log_settings = array(
                  'enable_logging'        => array(
                      'title'    => __( 'Enable Logging?', 'object-sync-for-salesforce' ),
      Severity: Major
      Found in classes/class-object-sync-sf-admin.php - About 7 hrs to fix

        Function maybe_upgrade_sync_triggers has a Cognitive Complexity of 46 (exceeds 5 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 7 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

        Object_Sync_Sf_Admin has 49 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Object_Sync_Sf_Admin {
        
            /**
             * Current version of the plugin
             *
        Severity: Minor
        Found in classes/class-object-sync-sf-admin.php - About 6 hrs to fix

          Function comment_upsert has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
          Open

              private function comment_upsert( $key, $value, $methods, $params, $id_field = 'comment_ID', $pull_to_drafts = false, $check_only = false ) {
                  $method = isset( $methods['method_match'] ) ? $methods['method_match'] : '';
                  if ( 'get_comment' === $method ) {
                      $method = 'get_comments';
                  }
          Severity: Minor
          Found in classes/class-object-sync-sf-wordpress.php - About 6 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_upsert has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
          Open

              private function post_upsert( $key, $value, $methods, $params, $id_field = 'ID', $pull_to_drafts = false, $post_type = 'post', $check_only = false ) {
          
                  $method = isset( $methods['method_match'] ) ? $methods['method_match'] : '';
                  if ( '' !== $method ) {
                      // By default, posts use get_posts as the method. args can be like this.
          Severity: Minor
          Found in classes/class-object-sync-sf-wordpress.php - About 6 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 map_params has 154 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function map_params( $mapping, $object, $trigger, $use_soap = false, $is_new = true, $object_id_field = '' ) {
          
                  $params = array();
          
                  $has_missing_required_salesforce_field = false;
          Severity: Major
          Found in classes/class-object-sync-sf-mapping.php - About 6 hrs to fix

            Method get_wordpress_table_structure has 154 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function get_wordpress_table_structure( $object_type ) {
                    if ( 'attachment' === $object_type ) {
                        $object_table_structure = array(
                            'object_name'     => 'post',
                            'content_methods' => array(
            Severity: Major
            Found in classes/class-object-sync-sf-wordpress.php - About 6 hrs to fix

              Function term_upsert has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function term_upsert( $key, $value, $methods, $params, $taxonomy, $id_field = 'ID', $pull_to_drafts = false, $check_only = false ) {
                      if ( 'tag' === $taxonomy ) {
                          $taxonomy = 'post_tag';
                      }
                      $method = isset( $methods['method_match'] ) ? $methods['method_match'] : '';
              Severity: Minor
              Found in classes/class-object-sync-sf-wordpress.php - About 6 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_fieldmaps has a Cognitive Complexity of 39 (exceeds 5 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: Minor
              Found in classes/class-object-sync-sf-mapping.php - About 5 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 attachment_upsert has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function attachment_upsert( $key, $value, $methods, $params, $id_field = 'ID', $check_only = false ) {
              
                      $method = isset( $methods['method_match'] ) ? $methods['method_match'] : '';
                      if ( '' !== $method ) {
                          // Get_posts is more helpful here, so that is the method attachment uses for 'read'.
              Severity: Minor
              Found in classes/class-object-sync-sf-wordpress.php - About 5 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_merged_records has a Cognitive Complexity of 38 (exceeds 5 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: Minor
              Found in classes/class-object-sync-sf-salesforce-pull.php - About 5 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 log_trigger_settings has a Cognitive Complexity of 35 (exceeds 5 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 5 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 user_upsert has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function user_upsert( $key, $value, $methods, $params, $id_field = 'ID', $pull_to_drafts = false, $check_only = false ) {
              
                      // If the key is user_email, we need to make it just email because that is how the WordPress method reads it.
                      $method = isset( $methods['method_match'] ) ? $methods['method_match'] : '';
                      if ( '' !== $method ) {
              Severity: Minor
              Found in classes/class-object-sync-sf-wordpress.php - About 5 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 import_json_file has 131 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function import_json_file() {
              
                      if ( ! wp_verify_nonce( $_POST['object_sync_for_salesforce_nonce_import'], 'object_sync_for_salesforce_nonce_import' ) ) {
                          return;
                      }
              Severity: Major
              Found in classes/class-object-sync-sf-admin.php - About 5 hrs to fix

                Function api_http_request has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function api_http_request( $path, $params, $method, $options = array(), $type = 'rest' ) {
                        // this merge will override a value in $this->options with the one in $options parameter if there is a matching key.
                        $options = array_merge( $this->options, $options );
                        $url     = $this->get_api_endpoint( $type ) . $path;
                        if ( isset( $options['full_url'] ) && true === $options['full_url'] ) {
                Severity: Minor
                Found in classes/class-object-sync-sf-salesforce.php - About 5 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

                Object_Sync_Sf_WordPress has 38 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class Object_Sync_Sf_WordPress {
                
                    /**
                     * Current version of the plugin
                     *
                Severity: Minor
                Found in classes/class-object-sync-sf-wordpress.php - About 5 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language