gocodebox/lifterlms

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

Summary

Maintainability
D
2 days
Test Coverage
F
47%

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

<?php
/**
 * Front end template functions
 *
 * @package LifterLMS/Functions/Templates
Severity: Major
Found in includes/llms.template.functions.php - About 1 day to fix

    Function lifterlms_course_continue_button has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        function lifterlms_course_continue_button( $post_id = null, $student = null, $progress = null ) {
    
            if ( ! $post_id ) {
                $post_id = get_the_ID();
                if ( ! $post_id ) {
    Severity: Minor
    Found in includes/llms.template.functions.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 lifterlms_course_continue_button has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function lifterlms_course_continue_button( $post_id = null, $student = null, $progress = null ) {
    
            if ( ! $post_id ) {
                $post_id = get_the_ID();
                if ( ! $post_id ) {
    Severity: Minor
    Found in includes/llms.template.functions.php - About 1 hr to fix

      Method llms_get_author has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function llms_get_author( $args = array() ) {
      
          $args = wp_parse_args(
              $args,
              array(
      Severity: Minor
      Found in includes/llms.template.functions.php - About 1 hr to fix

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

        function llms_setup_lesson_data( $post ) {
            if ( ! is_admin() ) {
        
                if ( 'lesson' == $post->post_type ) {
                    unset( $GLOBALS['lesson'] );
        Severity: Minor
        Found in includes/llms.template.functions.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 lifterlms_page_title has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            function lifterlms_page_title( $echo = true ) {
        
                $page_title = '';
        
                if ( is_search() ) {
        Severity: Minor
        Found in includes/llms.template.functions.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 llms_setup_course_data has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        function llms_setup_course_data( $post ) {
            if ( ! is_admin() ) {
        
                if ( $post && 'course' === $post->post_type ) {
        
        
        Severity: Minor
        Found in includes/llms.template.functions.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 llms_post_classes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        function llms_post_classes( $classes, $class = array(), $post_id = '' ) {
        
            if ( ! $post_id ) {
                return $classes;
            }
        Severity: Minor
        Found in includes/llms.template.functions.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

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

        function get_section_data( $sections ) {
            global $post;
            $html = '';
            $args = array(
                'post_type'   => 'section',
        Severity: Minor
        Found in includes/llms.template.functions.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 get_lesson_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function get_lesson_data( $lessons ) {
            global $post;
            $html = '';
            $args = array(
                'post_type'   => 'lesson',
        Severity: Minor
        Found in includes/llms.template.functions.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