MinnPost/object-sync-for-salesforce

View on GitHub

Showing 364 of 364 total issues

Method create_wp_meta has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function create_wp_meta( $params, $parent_object_id, $parent_object_type ) {
        $success = true;
        $errors  = array();
        if ( ! is_wp_error( $parent_object_id ) && is_array( $params ) && ! empty( $params ) ) {
            foreach ( $params as $key => $value ) {
Severity: Minor
Found in classes/class-object-sync-sf-wordpress.php - About 1 hr to fix

    Method register_routes has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function register_routes() {
            $namespace   = $this->namespace;
            $method_list = WP_REST_Server::ALLMETHODS;
            register_rest_route(
                $namespace,
    Severity: Minor
    Found in classes/class-object-sync-sf-rest.php - About 1 hr to fix

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

          public function setup( $title_or_params, $message = '', $trigger = 0, $parent = 0, $status = '' ) {
      
              if ( is_array( $title_or_params ) ) {
                  $title   = $title_or_params['title'];
                  $message = $title_or_params['message'];
      Severity: Minor
      Found in classes/class-object-sync-sf-logging.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_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

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

          public function objects(
              $conditions = array(
                  'updateable'  => true,
                  'triggerable' => true,
              ),
      Severity: Minor
      Found in classes/class-object-sync-sf-salesforce.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 object_upsert has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          public function object_upsert( $name, $key, $value, $methods, $params, $pull_to_drafts = false, $check_only = false ) {
      
              $structure = $this->get_wordpress_table_structure( $name );
              $id_field  = $structure['id_field'];
      
      
      Severity: Minor
      Found in classes/class-object-sync-sf-wordpress.php - About 1 hr to fix

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

          public function get_wordpress_object_fields( $wordpress_object, $id_field = 'ID' ) {
      
              $object_table_structure = $this->get_wordpress_table_structure( $wordpress_object );
      
              $meta_table      = $object_table_structure['meta_table'];
      Severity: Minor
      Found in classes/class-object-sync-sf-wordpress.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

            public function process( WP_REST_Request $request ) {
                // see methods: https://developer.wordpress.org/reference/classes/wp_rest_request/
                // use error_log( 'request is ' . print_r( $request, true ) ); to log the request.
                $http_method = $request->get_method();
                $route       = $request->get_route();
        Severity: Minor
        Found in classes/class-object-sync-sf-rest.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

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

                        if ( isset( $posts ) && isset( $posts[0]->{$id_field} ) ) {
                            // Post does exist after checking the matching value. We want its id.
                            $post_id = $posts[0]->{$id_field};
            
                            if ( true === $check_only ) {
            Severity: Major
            Found in classes/class-object-sync-sf-wordpress.php and 1 other location - About 1 hr to fix
            classes/class-object-sync-sf-wordpress.php on lines 2025..2063

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

            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( $term ) && isset( $term->{$id_field} ) ) {
                            // Term does exist after checking the matching value. we want its id.
                            $term_id = $term->{$id_field};
            
                            if ( true === $check_only ) {
            Severity: Major
            Found in classes/class-object-sync-sf-wordpress.php and 1 other location - About 1 hr to fix
            classes/class-object-sync-sf-wordpress.php on lines 1391..1429

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 101.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Method run_analytics_report has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function run_analytics_report( $id, $async = true, $clear_cache = false, $params = array(), $method = 'GET', $report_cache_expiration = '', $cache_instance = true, $instance_cache_expiration = '' ) {
            Severity: Major
            Found in classes/class-object-sync-sf-salesforce.php - About 1 hr to fix

              Method object_fields has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  private function object_fields( $object_name, $id_field, $content_table, $content_methods, $meta_table, $meta_methods, $where, $ignore_keys = array() ) {
              Severity: Major
              Found in classes/class-object-sync-sf-wordpress.php - About 1 hr to fix

                Method post_upsert has 8 arguments (exceeds 4 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 ) {
                Severity: Major
                Found in classes/class-object-sync-sf-wordpress.php - About 1 hr to fix

                  Method term_upsert has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

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

                    Function wordpress_salesforce_tables has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function wordpress_salesforce_tables() {
                    
                            $charset_collate = $this->wpdb->get_charset_collate();
                    
                            $field_map_table = $this->wpdb->prefix . 'object_sync_sf_field_map';
                    Severity: Minor
                    Found in classes/class-object-sync-sf-activate.php - About 55 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Function delete_object_map has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function delete_object_map( $id = '' ) {
                            if ( is_string( $id ) || is_int( $id ) ) {
                                $data   = array(
                                    'id' => $id,
                                );
                    Severity: Minor
                    Found in classes/class-object-sync-sf-mapping.php - About 55 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Function get_wordpress_table_structure has a Cognitive Complexity of 9 (exceeds 5 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: Minor
                    Found in classes/class-object-sync-sf-wordpress.php - About 55 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Function object_delete has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function object_delete( $name, $id ) {
                            $structure = $this->get_wordpress_table_structure( $name );
                            $id_field  = $structure['id_field'];
                    
                            switch ( $name ) {
                    Severity: Minor
                    Found in classes/class-object-sync-sf-wordpress.php - About 55 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Severity
                    Category
                    Status
                    Source
                    Language