CaffGeek/MBACNationals

View on GitHub
Web.Admin/2014/wordpress/wp-includes/date.php

Summary

Maintainability
D
1 day
Test Coverage

Function get_sql_for_subquery has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    protected function get_sql_for_subquery( $query ) {
        global $wpdb;

        // The sub-parts of a $where part
        $where_parts = array();
Severity: Minor
Found in Web.Admin/2014/wordpress/wp-includes/date.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 build_time_query has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function build_time_query( $column, $compare, $hour = null, $minute = null, $second = null ) {
        global $wpdb;

        // Have to have at least one
        if ( ! isset( $hour ) && ! isset( $minute ) && ! isset( $second ) )
Severity: Minor
Found in Web.Admin/2014/wordpress/wp-includes/date.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

Consider simplifying this complex logical expression.
Open

        if ( isset( $hour ) && ! isset( $minute ) && ! isset( $second ) && false !== ( $value = $this->build_value( $compare, $hour ) ) ) {
            return "HOUR( $column ) $compare $value";
        } elseif ( ! isset( $hour ) && isset( $minute ) && ! isset( $second ) && false !== ( $value = $this->build_value( $compare, $minute ) ) ) {
            return "MINUTE( $column ) $compare $value";
        } elseif ( ! isset( $hour ) && ! isset( $minute ) && isset( $second ) && false !== ( $value = $this->build_value( $compare, $second ) ) ) {
Severity: Critical
Found in Web.Admin/2014/wordpress/wp-includes/date.php - About 2 hrs to fix

    Method get_sql_for_subquery has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function get_sql_for_subquery( $query ) {
            global $wpdb;
    
            // The sub-parts of a $where part
            $where_parts = array();
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/date.php - About 1 hr to fix

      Method build_time_query has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function build_time_query( $column, $compare, $hour = null, $minute = null, $second = null ) {
              global $wpdb;
      
              // Have to have at least one
              if ( ! isset( $hour ) && ! isset( $minute ) && ! isset( $second ) )
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/date.php - About 1 hr to fix

        Function __construct has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            function __construct( $date_query, $default_column = 'post_date' ) {
                if ( empty( $date_query ) || ! is_array( $date_query ) )
                    return;
        
                if ( isset( $date_query['relation'] ) && strtoupper( $date_query['relation'] ) == 'OR' )
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/date.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 build_time_query has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function build_time_query( $column, $compare, $hour = null, $minute = null, $second = null ) {
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/date.php - About 35 mins to fix

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

              public function build_mysql_datetime( $datetime, $default_to_max = false ) {
                  $now = current_time( 'timestamp' );
          
                  if ( ! is_array( $datetime ) ) {
                      // @todo Timezone issues here possibly
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/date.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

          Avoid too many return statements within this method.
          Open

                      return "SECOND( $column ) $compare $value";
          Severity: Major
          Found in Web.Admin/2014/wordpress/wp-includes/date.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return false;
            Severity: Major
            Found in Web.Admin/2014/wordpress/wp-includes/date.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return $wpdb->prepare( "DATE_FORMAT( $column, %s ) $compare %f", $format, $time );
              Severity: Major
              Found in Web.Admin/2014/wordpress/wp-includes/date.php - About 30 mins to fix

                There are no issues that match your filters.

                Category
                Status