woocommerce/woocommerce

View on GitHub
includes/data-stores/class-wc-data-store-wp.php

Summary

Maintainability
D
2 days
Test Coverage

Function parse_date_for_wp_query has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

    public function parse_date_for_wp_query( $query_var, $key, $wp_query_args = array() ) {
        $query_parse_regex = '/([^.<>]*)(>=|<=|>|<|\.\.\.)([^.<>]+)/';
        $valid_operators   = array( '>', '>=', '=', '<=', '<', '...' );

        // YYYY-MM-DD queries have 'day' precision. Timestamp/WC_DateTime queries have 'second' precision.
Severity: Minor
Found in includes/data-stores/class-wc-data-store-wp.php - About 6 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 parse_date_for_wp_query has 122 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function parse_date_for_wp_query( $query_var, $key, $wp_query_args = array() ) {
        $query_parse_regex = '/([^.<>]*)(>=|<=|>|<|\.\.\.)([^.<>]+)/';
        $valid_operators   = array( '>', '>=', '=', '<=', '<', '...' );

        // YYYY-MM-DD queries have 'day' precision. Timestamp/WC_DateTime queries have 'second' precision.
Severity: Major
Found in includes/data-stores/class-wc-data-store-wp.php - About 4 hrs to fix

    File class-wc-data-store-wp.php has 347 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Shared logic for WP based data.
     * Contains functions like meta handling for all default data stores.
     * Your own data store doesn't need to use WC_Data_Store_WP -- you can write
    Severity: Minor
    Found in includes/data-stores/class-wc-data-store-wp.php - About 4 hrs to fix

      WC_Data_Store_WP has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class WC_Data_Store_WP {
      
          /**
           * Meta type. This should match up with
           * the types available at https://developer.wordpress.org/reference/functions/add_metadata/.
      Severity: Minor
      Found in includes/data-stores/class-wc-data-store-wp.php - About 2 hrs to fix

        Function get_wp_query_args has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function get_wp_query_args( $query_vars ) {
        
                $skipped_values = array( '', array(), null );
                $wp_query_args  = array(
                    'errors'     => array(),
        Severity: Minor
        Found in includes/data-stores/class-wc-data-store-wp.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 get_wp_query_args has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function get_wp_query_args( $query_vars ) {
        
                $skipped_values = array( '', array(), null );
                $wp_query_args  = array(
                    'errors'     => array(),
        Severity: Minor
        Found in includes/data-stores/class-wc-data-store-wp.php - About 1 hr to fix

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

              protected function get_valid_search_terms( $terms ) {
                  $valid_terms = array();
                  $stopwords   = $this->get_search_stopwords();
          
                  foreach ( $terms as $term ) {
          Severity: Minor
          Found in includes/data-stores/class-wc-data-store-wp.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

          There are no issues that match your filters.

          Category
          Status