gocodebox/lifterlms

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

Summary

Maintainability
F
4 days
Test Coverage
D
62%

Function llms_page_restricted has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

function llms_page_restricted( $post_id, $user_id = null ) {

    $results = array(
        'content_id'     => $post_id,
        'is_restricted'  => false,
Severity: Minor
Found in includes/functions/llms.functions.access.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

File llms.functions.access.php has 346 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Functions used for managing page / post access
 *
 * @package LifterLMS/Functions
Severity: Minor
Found in includes/functions/llms.functions.access.php - About 4 hrs to fix

    Method llms_page_restricted has 86 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function llms_page_restricted( $post_id, $user_id = null ) {
    
        $results = array(
            'content_id'     => $post_id,
            'is_restricted'  => false,
    Severity: Major
    Found in includes/functions/llms.functions.access.php - About 3 hrs to fix

      Method llms_get_restriction_message has 71 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function llms_get_restriction_message( $restriction ) {
      
          $msg = __( 'You do not have permission to access this content', 'lifterlms' );
      
          switch ( $restriction['reason'] ) {
      Severity: Major
      Found in includes/functions/llms.functions.access.php - About 2 hrs to fix

        Function llms_is_post_restricted_by_membership has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

        function llms_is_post_restricted_by_membership( $post_id, $user_id = null ) {
        
            // don't check these posts types.
            $skip = apply_filters(
                'llms_is_post_restricted_by_membership_skip_post_types',
        Severity: Minor
        Found in includes/functions/llms.functions.access.php - About 2 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

        Function llms_is_post_restricted_by_prerequisite has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        function llms_is_post_restricted_by_prerequisite( $post_id, $user_id = null ) {
        
            $post_type = get_post_type( $post_id );
        
            switch ( $post_type ) {
        Severity: Minor
        Found in includes/functions/llms.functions.access.php - About 2 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_is_post_restricted_by_prerequisite has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function llms_is_post_restricted_by_prerequisite( $post_id, $user_id = null ) {
        
            $post_type = get_post_type( $post_id );
        
            switch ( $post_type ) {
        Severity: Minor
        Found in includes/functions/llms.functions.access.php - About 2 hrs to fix

          Method llms_is_post_restricted_by_membership has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function llms_is_post_restricted_by_membership( $post_id, $user_id = null ) {
          
              // don't check these posts types.
              $skip = apply_filters(
                  'llms_is_post_restricted_by_membership_skip_post_types',
          Severity: Minor
          Found in includes/functions/llms.functions.access.php - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                if ( is_home() && $sitewide_membership_id ) {
                    $restriction_id = $sitewide_membership_id;
                    $reason         = 'sitewide_membership';
                    // if it's a search page and the site isn't restricted to a membership bypass restrictions.
                } elseif ( ( is_search() ) && ! get_option( 'lifterlms_membership_required', '' ) ) {
            Severity: Critical
            Found in includes/functions/llms.functions.access.php - About 1 hr to fix

              Method llms_is_post_restricted_by_sitewide_membership has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function llms_is_post_restricted_by_sitewide_membership( $post_id, $user_id = null ) {
              
                  $membership_id = absint( get_option( 'lifterlms_membership_required', '' ) );
              
                  // site is restricted to a membership.
              Severity: Minor
              Found in includes/functions/llms.functions.access.php - About 1 hr to fix

                Method llms_is_post_restricted_by_time_period has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function llms_is_post_restricted_by_time_period( $post_id, $user_id = null ) {
                
                    $post_type = get_post_type( $post_id );
                
                    switch ( $post_type ) {
                Severity: Minor
                Found in includes/functions/llms.functions.access.php - About 1 hr to fix

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

                  function llms_get_restriction_message( $restriction ) {
                  
                      $msg = __( 'You do not have permission to access this content', 'lifterlms' );
                  
                      switch ( $restriction['reason'] ) {
                  Severity: Minor
                  Found in includes/functions/llms.functions.access.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 llms_is_post_restricted_by_sitewide_membership has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function llms_is_post_restricted_by_sitewide_membership( $post_id, $user_id = null ) {
                  
                      $membership_id = absint( get_option( 'lifterlms_membership_required', '' ) );
                  
                      // site is restricted to a membership.
                  Severity: Minor
                  Found in includes/functions/llms.functions.access.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

                  Avoid too many return statements within this method.
                  Open

                                  return apply_filters( 'llms_page_restricted', $results, $post_id );
                  Severity: Major
                  Found in includes/functions/llms.functions.access.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return apply_filters( 'llms_page_restricted', $results, $post_id );
                    Severity: Major
                    Found in includes/functions/llms.functions.access.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return apply_filters( 'llms_page_restricted', $results, $post_id );
                      Severity: Major
                      Found in includes/functions/llms.functions.access.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

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

                          Avoid too many return statements within this method.
                          Open

                              return apply_filters( 'llms_page_restricted', $results, $post_id );
                          Severity: Major
                          Found in includes/functions/llms.functions.access.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

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

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

                              function llms_is_post_restricted_by_drip_settings( $post_id, $user_id = null ) {
                              
                                  $post_type = get_post_type( $post_id );
                              
                                  switch ( $post_type ) {
                              Severity: Minor
                              Found in includes/functions/llms.functions.access.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 llms_is_post_restricted_by_time_period has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                              function llms_is_post_restricted_by_time_period( $post_id, $user_id = null ) {
                              
                                  $post_type = get_post_type( $post_id );
                              
                                  switch ( $post_type ) {
                              Severity: Minor
                              Found in includes/functions/llms.functions.access.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