woothemes/woocommerce

View on GitHub
includes/class-wc-template-loader.php

Summary

Maintainability
D
1 day
Test Coverage

File class-wc-template-loader.php has 332 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Template Loader
 *
 * @package WooCommerce\Classes
Severity: Minor
Found in includes/class-wc-template-loader.php - About 4 hrs to fix

    Method unsupported_theme_tax_archive_init has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static function unsupported_theme_tax_archive_init() {
            global $wp_query, $post;
    
            $queried_object = get_queried_object();
            $args           = self::get_current_shop_view_args();
    Severity: Major
    Found in includes/class-wc-template-loader.php - About 2 hrs to fix

      Function get_template_loader_files has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function get_template_loader_files( $default_file ) {
              $templates   = apply_filters( 'woocommerce_template_loader_files', array(), $default_file );
              $templates[] = 'woocommerce.php';
      
              if ( is_page_template() ) {
      Severity: Minor
      Found in includes/class-wc-template-loader.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 get_template_loader_files has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static function get_template_loader_files( $default_file ) {
              $templates   = apply_filters( 'woocommerce_template_loader_files', array(), $default_file );
              $templates[] = 'woocommerce.php';
      
              if ( is_page_template() ) {
      Severity: Minor
      Found in includes/class-wc-template-loader.php - About 1 hr to fix

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

            public static function unsupported_theme_shop_content_filter( $content ) {
                global $wp_query;
        
                if ( self::$theme_support || ! is_main_query() || ! in_the_loop() ) {
                    return $content;
        Severity: Minor
        Found in includes/class-wc-template-loader.php - About 1 hr to fix

          Function template_loader has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function template_loader( $template ) {
                  if ( is_embed() ) {
                      return $template;
                  }
          
          
          Severity: Minor
          Found in includes/class-wc-template-loader.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

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

              private static function get_template_loader_default_file() {
                  if ( is_singular( 'product' ) ) {
                      $default_file = 'single-product.php';
                  } elseif ( is_product_taxonomy() ) {
                      $object = get_queried_object();
          Severity: Minor
          Found in includes/class-wc-template-loader.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

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

              private static function unsupported_theme_tax_archive_init() {
                  global $wp_query, $post;
          
                  $queried_object = get_queried_object();
                  $args           = self::get_current_shop_view_args();
          Severity: Minor
          Found in includes/class-wc-template-loader.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

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

              public static function unsupported_theme_title_filter( $title, $id ) {
                  if ( self::$theme_support || ! $id !== self::$shop_page_id ) {
                      return $title;
                  }
          
          
          Severity: Minor
          Found in includes/class-wc-template-loader.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

          There are no issues that match your filters.

          Category
          Status