gocodebox/lifterlms

View on GitHub
includes/class.llms.user.permissions.php

Summary

Maintainability
C
1 day
Test Coverage
A
95%

Function handle_caps has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function handle_caps( $allcaps, $cap, $args ) {

        /**
         * Modify the list of post types that users may not own but can still edit based on instructor permissions on the course
         *
Severity: Minor
Found in includes/class.llms.user.permissions.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 editable_roles has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function editable_roles( $all_roles ) {

        /**
         * Prevent issues when other plugins call get_editable_roles() before `init`.
         *
Severity: Minor
Found in includes/class.llms.user.permissions.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

Function handle_cap_view_grades has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private function handle_cap_view_grades( $allcaps, $args ) {

        // Logged out user or missing required args.
        if ( empty( $args[1] ) || empty( $args[2] ) ) {
            return $allcaps;
Severity: Minor
Found in includes/class.llms.user.permissions.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

Function user_can_manage_user has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    protected function user_can_manage_user( $user_id, $edit_id ) {

        $user = get_user_by( 'id', $user_id );

        /**
Severity: Minor
Found in includes/class.llms.user.permissions.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 handle_caps has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function handle_caps( $allcaps, $cap, $args ) {

        /**
         * Modify the list of post types that users may not own but can still edit based on instructor permissions on the course
         *
Severity: Minor
Found in includes/class.llms.user.permissions.php - About 1 hr to fix

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

        public function editable_roles( $all_roles ) {
    
            /**
             * Prevent issues when other plugins call get_editable_roles() before `init`.
             *
    Severity: Minor
    Found in includes/class.llms.user.permissions.php - About 1 hr to fix

      Method user_can_manage_user has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function user_can_manage_user( $user_id, $edit_id ) {
      
              $user = get_user_by( 'id', $user_id );
      
              /**
      Severity: Minor
      Found in includes/class.llms.user.permissions.php - About 1 hr to fix

        Avoid too many return statements within this method.
        Open

                return false;
        Severity: Major
        Found in includes/class.llms.user.permissions.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return $all_roles;
          Severity: Major
          Found in includes/class.llms.user.permissions.php - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status