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,
- Read upRead up
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
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,
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'] ) {
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',
- Read upRead up
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 ) {
- Read upRead up
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 ) {
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',
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', '' ) ) {
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.
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 ) {
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'] ) {
- Read upRead up
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.
- Read upRead up
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 );
Avoid too many return
statements within this method. Open
return apply_filters( 'llms_page_restricted', $results, $post_id );
Avoid too many return
statements within this method. Open
return apply_filters( 'llms_page_restricted', $results, $post_id );
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return apply_filters( 'llms_page_restricted', $results, $post_id );
Avoid too many return
statements within this method. Open
return $prereq;
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 ) {
- Read upRead up
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 ) {
- Read upRead up
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"