MinnPost/object-sync-for-salesforce

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

Summary

Maintainability
C
1 day
Test Coverage

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

<?php
/**
 * Log events based on plugin settings. Extend the WP_Logging class for the purposes of Object Sync for Salesforce.
 *
 * @class   Object_Sync_Sf_Logging
Severity: Minor
Found in classes/class-object-sync-sf-logging.php - About 4 hrs to fix

    Object_Sync_Sf_Logging has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Object_Sync_Sf_Logging extends WP_Logging {
    
        /**
         * Current version of the plugin
         *
    Severity: Minor
    Found in classes/class-object-sync-sf-logging.php - About 2 hrs to fix

      Method restrict_logs_by_type has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function restrict_logs_by_type( $post_type ) {
              $type     = 'wp_log';
              $taxonomy = 'wp_log_type';
              // only add filter to post type you want.
              if ( 'wp_log' === $post_type ) {
      Severity: Minor
      Found in classes/class-object-sync-sf-logging.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

        Method set_log_slug has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function set_log_slug( $override_slug, $slug, $post_ID, $post_status, $post_type ) {
        Severity: Minor
        Found in classes/class-object-sync-sf-logging.php - About 35 mins to fix

          Method setup has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function setup( $title_or_params, $message = '', $trigger = 0, $parent = 0, $status = '' ) {
          Severity: Minor
          Found in classes/class-object-sync-sf-logging.php - About 35 mins to fix

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

                public function posts_filter( $query ) {
                    global $pagenow;
                    $type     = 'wp_log';
                    $taxonomy = 'wp_log_type';
                    if ( is_admin() && 'edit.php' === $pagenow ) {
            Severity: Minor
            Found in classes/class-object-sync-sf-logging.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 check_log_schedule has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function check_log_schedule( $old_value, $new_value, $option ) {
                    $clear_schedule  = false;
                    $schedule_unit   = get_option( $this->option_prefix . 'logs_how_often_unit', '' );
                    $schedule_number = filter_var( get_option( $this->option_prefix . 'logs_how_often_number', '' ), FILTER_VALIDATE_INT );
                    if ( $this->option_prefix . 'logs_how_often_unit' === $option ) {
            Severity: Minor
            Found in classes/class-object-sync-sf-logging.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 restrict_logs_by_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function restrict_logs_by_type( $post_type ) {
                    $type     = 'wp_log';
                    $taxonomy = 'wp_log_type';
                    // only add filter to post type you want.
                    if ( 'wp_log' === $post_type ) {
            Severity: Minor
            Found in classes/class-object-sync-sf-logging.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

            There are no issues that match your filters.

            Category
            Status