woocommerce/woocommerce

View on GitHub
includes/customizer/class-wc-shop-customizer.php

Summary

Maintainability
F
6 days
Test Coverage

File class-wc-shop-customizer.php has 720 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Adds options to the customizer for WooCommerce.
 *
 * @version 3.3.0
Severity: Major
Found in includes/customizer/class-wc-shop-customizer.php - About 1 day to fix

    Method add_checkout_section has 164 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function add_checkout_section( $wp_customize ) {
            $wp_customize->add_section(
                'woocommerce_checkout',
                array(
                    'title'       => __( 'Checkout', 'woocommerce' ),
    Severity: Major
    Found in includes/customizer/class-wc-shop-customizer.php - About 6 hrs to fix

      Method add_product_catalog_section has 141 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function add_product_catalog_section( $wp_customize ) {
              $wp_customize->add_section(
                  'woocommerce_product_catalog',
                  array(
                      'title'    => __( 'Product Catalog', 'woocommerce' ),
      Severity: Major
      Found in includes/customizer/class-wc-shop-customizer.php - About 5 hrs to fix

        Method add_scripts has 135 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function add_scripts() {
                $min_rows    = wc_get_theme_support( 'product_grid::min_rows', 1 );
                $max_rows    = wc_get_theme_support( 'product_grid::max_rows', '' );
                $min_columns = wc_get_theme_support( 'product_grid::min_columns', 1 );
                $max_columns = wc_get_theme_support( 'product_grid::max_columns', '' );
        Severity: Major
        Found in includes/customizer/class-wc-shop-customizer.php - About 5 hrs to fix

          Method add_product_images_section has 129 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function add_product_images_section( $wp_customize ) {
                  if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) {
                      $regen_description = ''; // Nothing to report; Jetpack will handle magically.
                  } elseif ( apply_filters( 'woocommerce_background_image_regeneration', true ) && ! is_multisite() ) {
                      $regen_description = __( 'After publishing your changes, new image sizes will be generated automatically.', 'woocommerce' );
          Severity: Major
          Found in includes/customizer/class-wc-shop-customizer.php - About 5 hrs to fix

            Method add_store_notice_section has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function add_store_notice_section( $wp_customize ) {
                    $wp_customize->add_section(
                        'woocommerce_store_notice',
                        array(
                            'title'    => __( 'Store Notice', 'woocommerce' ),
            Severity: Major
            Found in includes/customizer/class-wc-shop-customizer.php - About 2 hrs to fix

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

                  private function add_product_images_section( $wp_customize ) {
                      if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) {
                          $regen_description = ''; // Nothing to report; Jetpack will handle magically.
                      } elseif ( apply_filters( 'woocommerce_background_image_regeneration', true ) && ! is_multisite() ) {
                          $regen_description = __( 'After publishing your changes, new image sizes will be generated automatically.', 'woocommerce' );
              Severity: Minor
              Found in includes/customizer/class-wc-shop-customizer.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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                      if ( ! wc_get_theme_support( 'single_image_width' ) ) {
                          $wp_customize->add_setting(
                              'woocommerce_single_image_width',
                              array(
                                  'default'              => 600,
              Severity: Major
              Found in includes/customizer/class-wc-shop-customizer.php and 1 other location - About 2 hrs to fix
              includes/customizer/class-wc-shop-customizer.php on lines 576..602

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 126.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                      if ( ! wc_get_theme_support( 'thumbnail_image_width' ) ) {
                          $wp_customize->add_setting(
                              'woocommerce_thumbnail_image_width',
                              array(
                                  'default'              => 300,
              Severity: Major
              Found in includes/customizer/class-wc-shop-customizer.php and 1 other location - About 2 hrs to fix
              includes/customizer/class-wc-shop-customizer.php on lines 548..574

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 126.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                      $wp_customize->add_control(
                          'woocommerce_shop_page_display',
                          array(
                              'label'       => __( 'Shop page display', 'woocommerce' ),
                              'description' => __( 'Choose what to display on the main shop page.', 'woocommerce' ),
              Severity: Major
              Found in includes/customizer/class-wc-shop-customizer.php and 1 other location - About 1 hr to fix
              includes/customizer/class-wc-shop-customizer.php on lines 409..423

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 109.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                      $wp_customize->add_control(
                          'woocommerce_category_archive_display',
                          array(
                              'label'       => __( 'Category display', 'woocommerce' ),
                              'description' => __( 'Choose what to display on product category pages.', 'woocommerce' ),
              Severity: Major
              Found in includes/customizer/class-wc-shop-customizer.php and 1 other location - About 1 hr to fix
              includes/customizer/class-wc-shop-customizer.php on lines 383..397

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 109.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                      $options = apply_filters(
                          'woocommerce_default_catalog_orderby_options',
                          array(
                              'menu_order' => __( 'Default sorting (custom ordering + name)', 'woocommerce' ),
                              'popularity' => __( 'Popularity (sales)', 'woocommerce' ),
              Severity: Major
              Found in includes/customizer/class-wc-shop-customizer.php and 2 other locations - About 1 hr to fix
              includes/wc-core-functions.php on lines 1514..1524
              includes/wc-template-functions.php on lines 1402..1412

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 108.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                      $wp_customize->add_control(
                          'woocommerce_catalog_rows',
                          array(
                              'label'       => __( 'Rows per page', 'woocommerce' ),
                              'description' => __( 'How many rows of products should be shown per page?', 'woocommerce' ),
              Severity: Minor
              Found in includes/customizer/class-wc-shop-customizer.php and 1 other location - About 55 mins to fix
              includes/customizer/class-wc-shop-customizer.php on lines 473..487

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 99.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                      $wp_customize->add_control(
                          'woocommerce_catalog_columns',
                          array(
                              'label'       => __( 'Products per row', 'woocommerce' ),
                              'description' => __( 'How many products should be shown per row?', 'woocommerce' ),
              Severity: Minor
              Found in includes/customizer/class-wc-shop-customizer.php and 1 other location - About 55 mins to fix
              includes/customizer/class-wc-shop-customizer.php on lines 503..517

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 99.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              There are no issues that match your filters.

              Category
              Status