gocodebox/lifterlms

View on GitHub
includes/controllers/class-llms-controller-checkout.php

Summary

Maintainability
C
7 hrs
Test Coverage
A
97%

File class-llms-controller-checkout.php has 255 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * LLMS_Controller_Checkout
 *
 * @package LifterLMS/Controllers/Classes
Severity: Minor
Found in includes/controllers/class-llms-controller-checkout.php - About 2 hrs to fix

    Method switch_payment_source_setup has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function switch_payment_source_setup() {
    
            $order_id = llms_filter_input( INPUT_POST, 'order_id', FILTER_SANITIZE_NUMBER_INT );
            if ( ! $order_id ) {
                return new WP_Error( 'switch-source-order-missing', __( 'Missing order information.', 'lifterlms' ), 'error' );
    Severity: Minor
    Found in includes/controllers/class-llms-controller-checkout.php - About 1 hr to fix

      Method create_pending_order has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function create_pending_order() {
      
              $verify = $this->verify_request( '_llms_checkout_nonce', self::ACTION_CREATE_PENDING_ORDER );
              if ( ! $verify ) {
                  return $verify;
      Severity: Minor
      Found in includes/controllers/class-llms-controller-checkout.php - About 1 hr to fix

        Function create_pending_order has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function create_pending_order() {
        
                $verify = $this->verify_request( '_llms_checkout_nonce', self::ACTION_CREATE_PENDING_ORDER );
                if ( ! $verify ) {
                    return $verify;
        Severity: Minor
        Found in includes/controllers/class-llms-controller-checkout.php - About 45 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

        Avoid too many return statements within this method.
        Open

                    return llms_add_notice( __( 'There was an error creating your order, please try again.', 'lifterlms' ), 'error' );
        Severity: Major
        Found in includes/controllers/class-llms-controller-checkout.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return new WP_Error( 'switch-source-action-invalid', __( 'Invalid action.', 'lifterlms' ), 'error' );
          Severity: Major
          Found in includes/controllers/class-llms-controller-checkout.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return compact( 'old_gateway', 'new_gateway', 'order' );
            Severity: Major
            Found in includes/controllers/class-llms-controller-checkout.php - About 30 mins to fix

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

                  private function switch_payment_source_setup() {
              
                      $order_id = llms_filter_input( INPUT_POST, 'order_id', FILTER_SANITIZE_NUMBER_INT );
                      if ( ! $order_id ) {
                          return new WP_Error( 'switch-source-order-missing', __( 'Missing order information.', 'lifterlms' ), 'error' );
              Severity: Minor
              Found in includes/controllers/class-llms-controller-checkout.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