gocodebox/lifterlms

View on GitHub
includes/functions/llms-functions-access-plans.php

Summary

Maintainability
C
1 day
Test Coverage
A
96%

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

function llms_insert_access_plan( $props = array() ) {

    $action = 'create';

    if ( ! empty( $props['id'] ) ) {
Severity: Minor
Found in includes/functions/llms-functions-access-plans.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 llms_insert_access_plan has 105 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function llms_insert_access_plan( $props = array() ) {

    $action = 'create';

    if ( ! empty( $props['id'] ) ) {
Severity: Major
Found in includes/functions/llms-functions-access-plans.php - About 4 hrs to fix

    Avoid too many return statements within this method.
    Open

                return new WP_Error( 'plan-creation', __( 'An error was encountered while creating the access plan', 'lifterlms' ) );
    Severity: Major
    Found in includes/functions/llms-functions-access-plans.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return new WP_Error( 'invalid-checkout-redirect-url', sprintf( __( 'Invalid checkout redirect URL: "%s"', 'lifterlms' ), $props['checkout_redirect_url'] ) );
      Severity: Major
      Found in includes/functions/llms-functions-access-plans.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

            return $plan;
        Severity: Major
        Found in includes/functions/llms-functions-access-plans.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return new WP_Error( 'invalid-checkout-redirect-type', sprintf( __( 'Invalid checkout redirect type: "%s"', 'lifterlms' ), $checkout_redirect_type ) );
          Severity: Major
          Found in includes/functions/llms-functions-access-plans.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return new WP_Error( 'invalid-checkout-redirect-page', sprintf( __( 'Invalid checkout redirect page ID: "%d"', 'lifterlms' ), $props['checkout_redirect_page'] ) );
            Severity: Major
            Found in includes/functions/llms-functions-access-plans.php - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status