woocommerce/woocommerce

View on GitHub
includes/class-wc-frontend-scripts.php

Summary

Maintainability
F
4 days
Test Coverage

File class-wc-frontend-scripts.php has 466 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Handle frontend scripts
 *
 * @package WooCommerce\Classes
Severity: Minor
Found in includes/class-wc-frontend-scripts.php - About 7 hrs to fix

    Method get_script_data has 138 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static function get_script_data( $handle ) {
            global $wp;
    
            switch ( $handle ) {
                case 'woocommerce':
    Severity: Major
    Found in includes/class-wc-frontend-scripts.php - About 5 hrs to fix

      Method register_scripts has 137 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static function register_scripts() {
              $suffix  = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
              $version = Constants::get_constant( 'WC_VERSION' );
      
              $register_scripts = array(
      Severity: Major
      Found in includes/class-wc-frontend-scripts.php - About 5 hrs to fix

        Function load_scripts has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function load_scripts() {
                global $post;
        
                if ( ! did_action( 'before_woocommerce_init' ) ) {
                    return;
        Severity: Minor
        Found in includes/class-wc-frontend-scripts.php - About 4 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 load_scripts has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function load_scripts() {
                global $post;
        
                if ( ! did_action( 'before_woocommerce_init' ) ) {
                    return;
        Severity: Major
        Found in includes/class-wc-frontend-scripts.php - About 2 hrs to fix

          Function get_script_data has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function get_script_data( $handle ) {
                  global $wp;
          
                  switch ( $handle ) {
                      case 'woocommerce':
          Severity: Minor
          Found in includes/class-wc-frontend-scripts.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 register_styles has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static function register_styles() {
                  $version = Constants::get_constant( 'WC_VERSION' );
          
                  $register_styles = array(
                      'photoswipe'                  => array(
          Severity: Minor
          Found in includes/class-wc-frontend-scripts.php - About 1 hr to fix

            Method get_styles has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function get_styles() {
                    $version = Constants::get_constant( 'WC_VERSION' );
            
                    return apply_filters(
                        'woocommerce_enqueue_styles',
            Severity: Minor
            Found in includes/class-wc-frontend-scripts.php - About 1 hr to fix

              Method enqueue_style has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  private static function enqueue_style( $handle, $path = '', $deps = array(), $version = WC_VERSION, $media = 'all', $has_rtl = false ) {
              Severity: Minor
              Found in includes/class-wc-frontend-scripts.php - About 45 mins to fix

                Method register_style has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    private static function register_style( $handle, $path, $deps = array(), $version = WC_VERSION, $media = 'all', $has_rtl = false ) {
                Severity: Minor
                Found in includes/class-wc-frontend-scripts.php - About 45 mins to fix

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

                      private static function register_script( $handle, $path, $deps = array( 'jquery' ), $version = WC_VERSION, $in_footer = true ) {
                  Severity: Minor
                  Found in includes/class-wc-frontend-scripts.php - About 35 mins to fix

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

                        private static function enqueue_script( $handle, $path = '', $deps = array( 'jquery' ), $version = WC_VERSION, $in_footer = true ) {
                    Severity: Minor
                    Found in includes/class-wc-frontend-scripts.php - About 35 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status