MinnPost/object-sync-for-salesforce

View on GitHub
classes/class-object-sync-sf-admin.php

Summary

Maintainability
F
3 wks
Test Coverage

File class-object-sync-sf-admin.php has 2018 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Create default WordPress admin functionality to configure the plugin.
 *
 * @class   Object_Sync_Sf_Admin
Severity: Major
Found in classes/class-object-sync-sf-admin.php - About 5 days to fix

    Function show_admin_page has a Cognitive Complexity of 65 (exceeds 5 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: Minor
    Found in classes/class-object-sync-sf-admin.php - About 1 day 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_settings has 246 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function fields_settings( $page, $section, $callbacks ) {
            add_settings_section( $page, ucwords( $page ), null, $page );
            $salesforce_settings = array(
                'consumer_key'                   => array(
                    'title'    => __( 'Consumer Key', 'object-sync-for-salesforce' ),
    Severity: Major
    Found in classes/class-object-sync-sf-admin.php - About 1 day to fix

      Function import_json_file has a Cognitive Complexity of 62 (exceeds 5 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: Minor
      Found in classes/class-object-sync-sf-admin.php - About 1 day 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 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

        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

          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

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

                  public function get_salesforce_object_description( $data = array() ) {
                      $ajax = false;
                      if ( empty( $data ) ) {
                          $data = filter_input_array( INPUT_POST, FILTER_SANITIZE_SPECIAL_CHARS );
                          $ajax = true;
              Severity: Minor
              Found in classes/class-object-sync-sf-admin.php - About 4 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 delete_object_map has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function delete_object_map() {
                      $post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_SPECIAL_CHARS );
                      if ( isset( $post_data['id'] ) ) {
                          $result = $this->mappings->delete_object_map( $post_data['id'] );
                          if ( true === $result ) {
              Severity: Minor
              Found in classes/class-object-sync-sf-admin.php - About 4 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_scheduling has 103 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function fields_scheduling( $page, $section, $callbacks ) {
              
                      add_settings_section( 'batch', __( 'Batch Settings', 'object-sync-for-salesforce' ), null, $page );
                      $section           = 'batch';
                      $schedule_settings = array(
              Severity: Major
              Found in classes/class-object-sync-sf-admin.php - About 4 hrs to fix

                Function get_salesforce_object_fields has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function get_salesforce_object_fields( $data = array() ) {
                        $ajax      = false;
                        $post_data = filter_input_array( INPUT_POST, FILTER_UNSAFE_RAW );
                        if ( empty( $data ) ) {
                            $salesforce_object = isset( $post_data['salesforce_object'] ) ? sanitize_text_field( wp_unslash( $post_data['salesforce_object'] ) ) : '';
                Severity: Minor
                Found in classes/class-object-sync-sf-admin.php - About 4 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 notices_data has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function notices_data() {
                        $notices = array(
                            'permission'              => array(
                                'condition'   => ( false === $this->check_wordpress_admin_permissions() ),
                                'message'     => __( "Your account does not have permission to edit the Object Sync for Salesforce plugin's settings.", 'object-sync-for-salesforce' ),
                Severity: Major
                Found in classes/class-object-sync-sf-admin.php - About 3 hrs to fix

                  Function prepare_fieldmap_data has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function prepare_fieldmap_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 3 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 show_salesforce_user_fields has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function show_salesforce_user_fields( $user ) {
                          $get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_SPECIAL_CHARS );
                          if ( true === $this->check_wordpress_admin_permissions() ) {
                              $mappings = $this->mappings->load_all_by_wordpress( 'user', $user->ID );
                              $fieldmap = $this->mappings->get_fieldmaps(
                  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 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

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

                        public function display_input_field( $args ) {
                            $type    = $args['type'];
                            $id      = $args['label_for'];
                            $name    = $args['name'];
                            $desc    = $args['desc'];
                    Severity: Minor
                    Found in classes/class-object-sync-sf-admin.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 resave_action_schedules has a Cognitive Complexity of 15 (exceeds 5 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: Minor
                    Found in classes/class-object-sync-sf-admin.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 get_salesforce_object_fields has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function get_salesforce_object_fields( $data = array() ) {
                            $ajax      = false;
                            $post_data = filter_input_array( INPUT_POST, FILTER_UNSAFE_RAW );
                            if ( empty( $data ) ) {
                                $salesforce_object = isset( $post_data['salesforce_object'] ) ? sanitize_text_field( wp_unslash( $post_data['salesforce_object'] ) ) : '';
                    Severity: Minor
                    Found in classes/class-object-sync-sf-admin.php - About 1 hr to fix

                      Method display_input_field has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function display_input_field( $args ) {
                              $type    = $args['type'];
                              $id      = $args['label_for'];
                              $name    = $args['name'];
                              $desc    = $args['desc'];
                      Severity: Minor
                      Found in classes/class-object-sync-sf-admin.php - About 1 hr to fix

                        Method delete_object_map has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function delete_object_map() {
                                $post_data = filter_input_array( INPUT_POST, FILTER_SANITIZE_SPECIAL_CHARS );
                                if ( isset( $post_data['id'] ) ) {
                                    $result = $this->mappings->delete_object_map( $post_data['id'] );
                                    if ( true === $result ) {
                        Severity: Minor
                        Found in classes/class-object-sync-sf-admin.php - About 1 hr to fix

                          Method get_salesforce_object_description has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function get_salesforce_object_description( $data = array() ) {
                                  $ajax = false;
                                  if ( empty( $data ) ) {
                                      $data = filter_input_array( INPUT_POST, FILTER_SANITIZE_SPECIAL_CHARS );
                                      $ajax = true;
                          Severity: Minor
                          Found in classes/class-object-sync-sf-admin.php - About 1 hr to fix

                            Method prepare_fieldmap_data has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function prepare_fieldmap_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

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

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

                                  public function display_notices() {
                              
                                      // before a notice is displayed, we should make sure we are on a page related to this plugin.
                                      if ( ! isset( $_GET['page'] ) || $this->admin_settings_url_param !== $_GET['page'] ) {
                                          return;
                              Severity: Minor
                              Found in classes/class-object-sync-sf-admin.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 display_select has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function display_select( $args ) {
                                      $type = $args['type'];
                                      $id   = $args['label_for'];
                                      $name = $args['name'];
                                      $desc = $args['desc'];
                              Severity: Minor
                              Found in classes/class-object-sync-sf-admin.php - About 1 hr to fix

                                Method display_checkboxes has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function display_checkboxes( $args ) {
                                        $type       = 'checkbox';
                                        $name       = $args['name'];
                                        $options    = get_option( $name, array() );
                                        $group_desc = $args['desc'];
                                Severity: Minor
                                Found in classes/class-object-sync-sf-admin.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

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

                                        Function display_checkboxes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                            public function display_checkboxes( $args ) {
                                                $type       = 'checkbox';
                                                $name       = $args['name'];
                                                $options    = get_option( $name, array() );
                                                $group_desc = $args['desc'];
                                        Severity: Minor
                                        Found in classes/class-object-sync-sf-admin.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 save_salesforce_user_fields has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                            public function save_salesforce_user_fields( $user_id ) {
                                                $post_data = filter_input_array( INPUT_POST, FILTER_UNSAFE_RAW );
                                                if ( isset( $post_data['salesforce_update_mapped_user'] ) && true === filter_var( $post_data['salesforce_update_mapped_user'], FILTER_VALIDATE_BOOLEAN ) ) {
                                                    $mapping_objects = $this->mappings->get_all_object_maps(
                                                        array(
                                        Severity: Minor
                                        Found in classes/class-object-sync-sf-admin.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 tabs has 30 lines of code (exceeds 25 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 1 hr to fix

                                          Method add_actions has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                          Open

                                              public function add_actions() {
                                          
                                                  // settings link.
                                                  add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 5 );
                                          
                                          
                                          Severity: Minor
                                          Found in classes/class-object-sync-sf-admin.php - About 1 hr to fix

                                            Function display_select has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                                public function display_select( $args ) {
                                                    $type = $args['type'];
                                                    $id   = $args['label_for'];
                                                    $name = $args['name'];
                                                    $desc = $args['desc'];
                                            Severity: Minor
                                            Found in classes/class-object-sync-sf-admin.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 show_salesforce_user_fields has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                            Open

                                                public function show_salesforce_user_fields( $user ) {
                                                    $get_data = filter_input_array( INPUT_GET, FILTER_SANITIZE_SPECIAL_CHARS );
                                                    if ( true === $this->check_wordpress_admin_permissions() ) {
                                                        $mappings = $this->mappings->load_all_by_wordpress( 'user', $user->ID );
                                                        $fieldmap = $this->mappings->get_fieldmaps(
                                            Severity: Minor
                                            Found in classes/class-object-sync-sf-admin.php - About 1 hr to fix

                                              Method __construct has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                              Open

                                                  public function __construct() {
                                                      $this->version             = object_sync_for_salesforce()->version;
                                                      $this->file                = object_sync_for_salesforce()->file;
                                                      $this->wpdb                = object_sync_for_salesforce()->wpdb;
                                                      $this->slug                = object_sync_for_salesforce()->slug;
                                              Severity: Minor
                                              Found in classes/class-object-sync-sf-admin.php - About 1 hr to fix

                                                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

                                                Consider simplifying this complex logical expression.
                                                Open

                                                            if ( true === $this->salesforce['is_authorized'] ) {
                                                                echo sprintf(
                                                                    '<a class="nav-tab%1$s" href="%2$s">%3$s</a>',
                                                                    esc_attr( $active ),
                                                                    esc_url( '?page=' . $this->admin_settings_url_param . '&tab=' . $tab_key ),
                                                Severity: Major
                                                Found in classes/class-object-sync-sf-admin.php - About 40 mins to fix

                                                  Consider simplifying this complex logical expression.
                                                  Open

                                                          if ( empty( $error_fieldmaps ) && empty( $error_object_maps ) && ( ! empty( $successful_fieldmaps ) || ! empty( $successful_object_maps ) ) ) {
                                                              $this->clear_cache( false );
                                                              wp_safe_redirect( get_admin_url( null, 'options-general.php?page=' . $this->admin_settings_url_param . '&tab=import-export&data_saved=true' ) );
                                                              exit;
                                                          } elseif ( ! empty( $error_fieldmaps ) && ! empty( $successful_fieldmaps ) ) {
                                                  Severity: Major
                                                  Found in classes/class-object-sync-sf-admin.php - About 40 mins to fix

                                                    Function clear_cache has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        private function clear_cache( $ajax = false ) {
                                                            $result  = $this->wordpress->sfwp_transients->flush();
                                                            $success = $result['success'];
                                                            if ( 0 < $result['count'] ) {
                                                                if ( true === $success ) {
                                                    Severity: Minor
                                                    Found in classes/class-object-sync-sf-admin.php - About 35 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 push_to_salesforce has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        public function push_to_salesforce( $wordpress_object = '', $wordpress_id = '', $force_return = false ) {
                                                            $post_data = filter_input_array( INPUT_POST, FILTER_UNSAFE_RAW );
                                                            if ( empty( $wordpress_object ) && empty( $wordpress_id ) ) {
                                                                $wordpress_object = isset( $post_data['wordpress_object'] ) ? sanitize_text_field( wp_unslash( $post_data['wordpress_object'] ) ) : '';
                                                                $wordpress_id     = isset( $post_data['wordpress_id'] ) ? absint( $post_data['wordpress_id'] ) : '';
                                                    Severity: Minor
                                                    Found in classes/class-object-sync-sf-admin.php - About 25 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 3 locations. Consider refactoring.
                                                    Open

                                                            foreach ( $error_settings as $key => $attributes ) {
                                                                $id       = $this->option_prefix . $key;
                                                                $name     = $this->option_prefix . $key;
                                                                $title    = $attributes['title'];
                                                                $callback = $attributes['callback'];
                                                    Severity: Major
                                                    Found in classes/class-object-sync-sf-admin.php and 2 other locations - About 3 hrs to fix
                                                    classes/class-object-sync-sf-admin.php on lines 1164..1182
                                                    classes/class-object-sync-sf-admin.php on lines 1357..1375

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

                                                    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

                                                                foreach ( $schedule_settings as $key => $attributes ) {
                                                                    $id       = $this->option_prefix . $key;
                                                                    $name     = $this->option_prefix . $key;
                                                                    $title    = $attributes['title'];
                                                                    $callback = $attributes['callback'];
                                                    Severity: Major
                                                    Found in classes/class-object-sync-sf-admin.php and 2 other locations - About 3 hrs to fix
                                                    classes/class-object-sync-sf-admin.php on lines 1357..1375
                                                    classes/class-object-sync-sf-admin.php on lines 1405..1423

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

                                                    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

                                                            foreach ( $log_settings as $key => $attributes ) {
                                                                $id       = $this->option_prefix . $key;
                                                                $name     = $this->option_prefix . $key;
                                                                $title    = $attributes['title'];
                                                                $callback = $attributes['callback'];
                                                    Severity: Major
                                                    Found in classes/class-object-sync-sf-admin.php and 2 other locations - About 3 hrs to fix
                                                    classes/class-object-sync-sf-admin.php on lines 1164..1182
                                                    classes/class-object-sync-sf-admin.php on lines 1405..1423

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

                                                    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'] ) . '&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

                                                    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

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

                                                                foreach ( $error_object_maps as $mapping_object ) {
                                                                    $body .= sprintf(
                                                                        // translators: placeholders are: 1) the mapping object row ID, 2) the ID of the Salesforce object, 3) the WordPress object type.
                                                                        '<li>' . esc_html__( 'Mapping object id (if it exists): %1$s. Salesforce Id: %2$s. WordPress object type: %3$s', 'object-sync-for-salesforce' ) . '</li>',
                                                                        isset( $mapping_object['id'] ) ? absint( $mapping_object['id'] ) : '',
                                                    Severity: Minor
                                                    Found in classes/class-object-sync-sf-admin.php and 1 other location - About 35 mins to fix
                                                    classes/class-object-sync-sf-admin.php on lines 2087..2095

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

                                                    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 ( $error_fieldmaps as $fieldmap ) {
                                                                    $body .= sprintf(
                                                                        // translators: placeholders are: 1) the fieldmap row ID, 2) the Salesforce object type, 3) the WordPress object type.
                                                                        '<li>' . esc_html__( 'Fieldmap id (if it exists): %1$s. Salesforce object type: %2$s. WordPress object type: %3$s', 'object-sync-for-salesforce' ) . '</li>',
                                                                        isset( $fieldmap['id'] ) ? absint( $fieldmap['id'] ) : '',
                                                    Severity: Minor
                                                    Found in classes/class-object-sync-sf-admin.php and 1 other location - About 35 mins to fix
                                                    classes/class-object-sync-sf-admin.php on lines 2096..2104

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

                                                    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

                                                    There are no issues that match your filters.

                                                    Category
                                                    Status