skyverge/wc-plugin-framework

View on GitHub
woocommerce/utilities/class-sv-wp-background-job-handler.php

Summary

Maintainability
D
2 days
Test Coverage

File class-sv-wp-background-job-handler.php has 401 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * WooCommerce Plugin Framework
 *
 * This source file is subject to the GNU General Public License v3.0
Severity: Minor
Found in woocommerce/utilities/class-sv-wp-background-job-handler.php - About 5 hrs to fix

    SV_WP_Background_Job_Handler has 34 functions (exceeds 20 allowed). Consider refactoring.
    Open

    #[\AllowDynamicProperties]
    abstract class SV_WP_Background_Job_Handler extends SV_WP_Async_Request {
    
    
        /** @var string async request prefix */
    Severity: Minor
    Found in woocommerce/utilities/class-sv-wp-background-job-handler.php - About 4 hrs to fix

      Function process_job has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          public function process_job( $job, $items_per_batch = null ) {
      
              if ( ! $this->start_time ) {
                  $this->start_time = time();
              }
      Severity: Minor
      Found in woocommerce/utilities/class-sv-wp-background-job-handler.php - About 3 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 process_job has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function process_job( $job, $items_per_batch = null ) {
      
              if ( ! $this->start_time ) {
                  $this->start_time = time();
              }
      Severity: Minor
      Found in woocommerce/utilities/class-sv-wp-background-job-handler.php - About 1 hr to fix

        Method get_jobs has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function get_jobs( $args = array() ) {
                global $wpdb;
        
                $args = wp_parse_args( $args, array(
                    'order'   => 'DESC',
        Severity: Minor
        Found in woocommerce/utilities/class-sv-wp-background-job-handler.php - About 1 hr to fix

          Function get_jobs has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function get_jobs( $args = array() ) {
                  global $wpdb;
          
                  $args = wp_parse_args( $args, array(
                      'order'   => 'DESC',
          Severity: Minor
          Found in woocommerce/utilities/class-sv-wp-background-job-handler.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_job has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function get_job( $id = null ) {
                  global $wpdb;
          
                  if ( ! $id ) {
          
          
          Severity: Minor
          Found in woocommerce/utilities/class-sv-wp-background-job-handler.php - About 1 hr to fix

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

                public function get_job( $id = null ) {
                    global $wpdb;
            
                    if ( ! $id ) {
            
            
            Severity: Minor
            Found in woocommerce/utilities/class-sv-wp-background-job-handler.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 maybe_handle has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function maybe_handle() {
            
                    if ( $this->is_process_running() ) {
                        // background process already running
                        wp_die();
            Severity: Minor
            Found in woocommerce/utilities/class-sv-wp-background-job-handler.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

            Function fail_job has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function fail_job( $job, $reason = '' ) {
            
                    if ( is_string( $job ) ) {
                        $job = $this->get_job( $job );
                    }
            Severity: Minor
            Found in woocommerce/utilities/class-sv-wp-background-job-handler.php - About 25 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_memory_limit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function get_memory_limit() {
            
                    if ( function_exists( 'ini_get' ) ) {
                        $memory_limit = ini_get( 'memory_limit' );
                    } else {
            Severity: Minor
            Found in woocommerce/utilities/class-sv-wp-background-job-handler.php - About 25 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