gocodebox/lifterlms

View on GitHub
includes/class.llms.roles.php

Summary

Maintainability
C
1 day
Test Coverage
A
99%

Function get_post_type_caps has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    private static function get_post_type_caps( $role ) {

        $caps = array();

        // Students get nothing.
Severity: Minor
Found in includes/class.llms.roles.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 get_wp_caps has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private static function get_wp_caps( $role ) {

        $caps = array(
            'read' => true,
        );
Severity: Major
Found in includes/class.llms.roles.php - About 2 hrs to fix

    Method get_post_type_caps has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static function get_post_type_caps( $role ) {
    
            $caps = array();
    
            // Students get nothing.
    Severity: Major
    Found in includes/class.llms.roles.php - About 2 hrs to fix

      File class.llms.roles.php has 252 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * LLMS_Roles class.
       *
       * @package LifterLMS/Classes
      Severity: Minor
      Found in includes/class.llms.roles.php - About 2 hrs to fix

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

            private static function get_core_caps( $role ) {
        
                $all_caps = array_fill_keys( array_values( self::get_all_core_caps() ), true );
        
                switch ( $role ) {
        Severity: Minor
        Found in includes/class.llms.roles.php - About 1 hr to fix

          Function update_caps has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function update_caps( $role, $type = 'add', $exclude_groups = array() ) {
          
                  $role_caps = self::get_all_caps( $role->name );
                  $role_caps = empty( $exclude_groups ) ? $role_caps : array_diff_key( $role_caps, array_flip( $exclude_groups ) );
          
          
          Severity: Minor
          Found in includes/class.llms.roles.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

          There are no issues that match your filters.

          Category
          Status