includes/class-wc-frontend-scripts.php
File class-wc-frontend-scripts.php
has 466 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
/**
* Handle frontend scripts
*
* @package WooCommerce\Classes
Method get_script_data
has 138 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private static function get_script_data( $handle ) {
global $wp;
switch ( $handle ) {
case 'woocommerce':
Method register_scripts
has 137 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private static function register_scripts() {
$suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
$version = Constants::get_constant( 'WC_VERSION' );
$register_scripts = array(
Function load_scripts
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
Open
public static function load_scripts() {
global $post;
if ( ! did_action( 'before_woocommerce_init' ) ) {
return;
- Read upRead up
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
Open
public static function load_scripts() {
global $post;
if ( ! did_action( 'before_woocommerce_init' ) ) {
return;
Function get_script_data
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
private static function get_script_data( $handle ) {
global $wp;
switch ( $handle ) {
case 'woocommerce':
- Read upRead up
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
Open
private static function register_styles() {
$version = Constants::get_constant( 'WC_VERSION' );
$register_styles = array(
'photoswipe' => array(
Method get_styles
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function get_styles() {
$version = Constants::get_constant( 'WC_VERSION' );
return apply_filters(
'woocommerce_enqueue_styles',
Method enqueue_style
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
private static function enqueue_style( $handle, $path = '', $deps = array(), $version = WC_VERSION, $media = 'all', $has_rtl = false ) {
Method register_style
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
private static function register_style( $handle, $path, $deps = array(), $version = WC_VERSION, $media = 'all', $has_rtl = false ) {
Method register_script
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
private static function register_script( $handle, $path, $deps = array( 'jquery' ), $version = WC_VERSION, $in_footer = true ) {
Method enqueue_script
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
private static function enqueue_script( $handle, $path = '', $deps = array( 'jquery' ), $version = WC_VERSION, $in_footer = true ) {