woothemes/woocommerce

View on GitHub
includes/wc-term-functions.php

Summary

Maintainability
D
2 days
Test Coverage

File wc-term-functions.php has 350 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * WooCommerce Terms
 *
 * Functions for handling terms/term meta.
Severity: Minor
Found in includes/wc-term-functions.php - About 4 hrs to fix

    Function _wc_term_recount has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    function _wc_term_recount( $terms, $taxonomy, $callback = true, $terms_are_term_taxonomy_ids = true ) {
        global $wpdb;
    
        // Standard callback.
        if ( $callback ) {
    Severity: Minor
    Found in includes/wc-term-functions.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 _wc_term_recount has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function _wc_term_recount( $terms, $taxonomy, $callback = true, $terms_are_term_taxonomy_ids = true ) {
        global $wpdb;
    
        // Standard callback.
        if ( $callback ) {
    Severity: Major
    Found in includes/wc-term-functions.php - About 2 hrs to fix

      Function wc_reorder_terms has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      function wc_reorder_terms( $the_term, $next_id, $taxonomy, $index = 0, $terms = null ) {
          if ( ! $terms ) {
              $terms = get_terms( $taxonomy, 'hide_empty=0&parent=0&menu_order=ASC' );
          }
          if ( empty( $terms ) ) {
      Severity: Minor
      Found in includes/wc-term-functions.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 wc_get_product_visibility_term_ids has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function wc_get_product_visibility_term_ids() {
          if ( ! taxonomy_exists( 'product_visibility' ) ) {
              wc_doing_it_wrong( __FUNCTION__, 'wc_get_product_visibility_term_ids should not be called before taxonomies are registered (woocommerce_after_register_post_type action).', '3.1' );
              return array();
          }
      Severity: Minor
      Found in includes/wc-term-functions.php - About 1 hr to fix

        Method wc_reorder_terms has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function wc_reorder_terms( $the_term, $next_id, $taxonomy, $index = 0, $terms = null ) {
            if ( ! $terms ) {
                $terms = get_terms( $taxonomy, 'hide_empty=0&parent=0&menu_order=ASC' );
            }
            if ( empty( $terms ) ) {
        Severity: Minor
        Found in includes/wc-term-functions.php - About 1 hr to fix

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

          function wc_change_term_counts( $terms, $taxonomies ) {
              if ( is_admin() || is_ajax() ) {
                  return $terms;
              }
          
          
          Severity: Minor
          Found in includes/wc-term-functions.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 wc_clear_term_product_ids has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          function wc_clear_term_product_ids( $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ) {
          Severity: Minor
          Found in includes/wc-term-functions.php - About 45 mins to fix

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

            function wc_reorder_terms( $the_term, $next_id, $taxonomy, $index = 0, $terms = null ) {
            Severity: Minor
            Found in includes/wc-term-functions.php - About 35 mins to fix

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

              function wc_recount_after_stock_change( $product_id ) {
                  if ( 'yes' !== get_option( 'woocommerce_hide_out_of_stock_items' ) ) {
                      return;
                  }
              
              
              Severity: Minor
              Found in includes/wc-term-functions.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 wc_change_get_terms_defaults has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function wc_change_get_terms_defaults( $defaults, $taxonomies ) {
                  if ( is_array( $taxonomies ) && 1 < count( $taxonomies ) ) {
                      return $defaults;
                  }
                  $taxonomy = is_array( $taxonomies ) ? (string) current( $taxonomies ) : $taxonomies;
              Severity: Minor
              Found in includes/wc-term-functions.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