gocodebox/lifterlms

View on GitHub
includes/class.llms.nav.menus.php

Summary

Maintainability
C
1 day
Test Coverage
F
1%

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

    public function menu_item_classes( $menu_items ) {

        if ( ! function_exists( 'is_lifterlms' ) || ! is_lifterlms() ) {
            return $menu_items;
        }
Severity: Minor
Found in includes/class.llms.nav.menus.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

Consider simplifying this complex logical expression.
Open

            if ( $blog_id === $object_id ) {

                $menu_items[ $key ]->current = false;
                foreach ( array( 'current_page_parent', 'current-menu-item' ) as $class ) {
                    if ( in_array( $class, $classes, true ) ) {
Severity: Critical
Found in includes/class.llms.nav.menus.php - About 2 hrs to fix

    Function get_nav_items has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        private function get_nav_items() {
    
            $items = array();
    
            foreach ( LLMS_Student_Dashboard::get_tabs() as $id => $data ) {
    Severity: Minor
    Found in includes/class.llms.nav.menus.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 output has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function output() {
    
            ?>
            <div id="posttype-llms-nav-items" class="posttypediv">
                <div id="tabs-panel-llms-nav-items" class="tabs-panel tabs-panel-active">
    Severity: Minor
    Found in includes/class.llms.nav.menus.php - About 1 hr to fix

      Method get_nav_items has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function get_nav_items() {
      
              $items = array();
      
              foreach ( LLMS_Student_Dashboard::get_tabs() as $id => $data ) {
      Severity: Minor
      Found in includes/class.llms.nav.menus.php - About 1 hr to fix

        Function filter_nav_items has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function filter_nav_items( $items ) {
        
                $urls = array(
                    '#llms-signout',
                    '#llms-signin',
        Severity: Minor
        Found in includes/class.llms.nav.menus.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 menu_item_classes has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function menu_item_classes( $menu_items ) {
        
                if ( ! function_exists( 'is_lifterlms' ) || ! is_lifterlms() ) {
                    return $menu_items;
                }
        Severity: Minor
        Found in includes/class.llms.nav.menus.php - About 1 hr to fix

          There are no issues that match your filters.

          Category
          Status