woocommerce/woocommerce

View on GitHub
includes/admin/class-wc-admin-assets.php

Summary

Maintainability
F
3 days
Test Coverage

Method admin_scripts has 337 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function admin_scripts() {
            global $wp_query, $post;

            $screen       = get_current_screen();
            $screen_id    = $screen ? $screen->id : '';
Severity: Major
Found in includes/admin/class-wc-admin-assets.php - About 1 day to fix

    Function admin_scripts has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

            public function admin_scripts() {
                global $wp_query, $post;
    
                $screen       = get_current_screen();
                $screen_id    = $screen ? $screen->id : '';
    Severity: Minor
    Found in includes/admin/class-wc-admin-assets.php - About 6 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

    File class-wc-admin-assets.php has 394 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Load assets
     *
     * @package WooCommerce\Admin
    Severity: Minor
    Found in includes/admin/class-wc-admin-assets.php - About 5 hrs to fix

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

              public function admin_styles() {
                  global $wp_scripts;
      
                  $version   = Constants::get_constant( 'WC_VERSION' );
                  $screen    = get_current_screen();
      Severity: Minor
      Found in includes/admin/class-wc-admin-assets.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 admin_styles has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              public function admin_styles() {
                  global $wp_scripts;
      
                  $version   = Constants::get_constant( 'WC_VERSION' );
                  $screen    = get_current_screen();
      Severity: Minor
      Found in includes/admin/class-wc-admin-assets.php - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                                if ( ! $order->has_status( array( 'pending', 'failed', 'cancelled' ) ) ) {
                                    $remove_item_notice = $remove_item_notice . ' ' . __( "You may need to manually restore the item's stock.", 'woocommerce' );
                                }
        Severity: Major
        Found in includes/admin/class-wc-admin-assets.php - About 45 mins to fix

          There are no issues that match your filters.

          Category
          Status