classes/class-log.php

Summary

Maintainability
C
1 day
Test Coverage
F
59%

Method log has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function log( $connector, $message, $args, $object_id, $context, $action, $user_id = null ) {
        global $wp_roles;

        if ( is_null( $user_id ) ) {
            $user_id = get_current_user_id();
Severity: Major
Found in classes/class-log.php - About 2 hrs to fix

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

        public function debug_backtrace( $recordarr ) {
            if ( version_compare( PHP_VERSION, '5.3.6', '<' ) ) {
                return __( 'Debug backtrace requires at least PHP 5.3.6', 'wp_stream' );
            }
    
    
    Severity: Minor
    Found in classes/class-log.php - About 1 hr to fix

      Method is_record_excluded has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function is_record_excluded( $connector, $context, $action, $user = null, $ip = null ) {
              $exclude_record = false;
      
              if ( is_null( $user ) ) {
                  $user = wp_get_current_user();
      Severity: Minor
      Found in classes/class-log.php - About 1 hr to fix

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

            public function record_matches_rules( $record, $exclude_rules ) {
                $matches_needed = count( $exclude_rules );
                $matches_found  = 0;
                foreach ( $exclude_rules as $exclude_key => $exclude_value ) {
                    if ( ! isset( $record[ $exclude_key ] ) || is_null( $exclude_value ) ) {
        Severity: Minor
        Found in classes/class-log.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 log has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public function log( $connector, $message, $args, $object_id, $context, $action, $user_id = null ) {
                global $wp_roles;
        
                if ( is_null( $user_id ) ) {
                    $user_id = get_current_user_id();
        Severity: Minor
        Found in classes/class-log.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 is_record_excluded has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            public function is_record_excluded( $connector, $context, $action, $user = null, $ip = null ) {
                $exclude_record = false;
        
                if ( is_null( $user ) ) {
                    $user = wp_get_current_user();
        Severity: Minor
        Found in classes/class-log.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

        Method log has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function log( $connector, $message, $args, $object_id, $context, $action, $user_id = null ) {
        Severity: Major
        Found in classes/class-log.php - About 50 mins to fix

          Function exclude_rules_by_rows has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function exclude_rules_by_rows( $rules ) {
                  $excludes = array();
          
                  // TODO: Move these to where the settings are generated to ensure they're in sync.
                  $rule_keys = array(
          Severity: Minor
          Found in classes/class-log.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

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

              public function is_record_excluded( $connector, $context, $action, $user = null, $ip = null ) {
          Severity: Minor
          Found in classes/class-log.php - About 35 mins to fix

            There are no issues that match your filters.

            Category
            Status