gocodebox/lifterlms

View on GitHub
includes/admin/class.llms.admin.builder.php

Summary

Maintainability
F
1 wk
Test Coverage
F
51%

File class.llms.admin.builder.php has 673 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * LifterLMS Admin Course Builder
 *
 * @package LifterLMS/Admin/Classes
Severity: Major
Found in includes/admin/class.llms.admin.builder.php - About 1 day to fix

    Function update_lessons has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function update_lessons( $lessons, $section ) {
    
            $ret = array();
    
            foreach ( $lessons as $lesson_data ) {
    Severity: Minor
    Found in includes/admin/class.llms.admin.builder.php - About 6 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 update_custom_schemas has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function update_custom_schemas( $type, $post, $post_data ) {
    
            $schemas = self::get_custom_schemas();
            if ( empty( $schemas[ $type ] ) ) {
                return;
    Severity: Minor
    Found in includes/admin/class.llms.admin.builder.php - About 5 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 get_existing_posts has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function get_existing_posts( $post_type = '', $search_term = '', $page = 1 ) {
    
            $args = array(
                'order'          => 'ASC',
                'orderby'        => 'post_title',
    Severity: Minor
    Found in includes/admin/class.llms.admin.builder.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

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

        private static function update_questions( $questions, $parent ) {
    
            $res = array();
    
            foreach ( $questions as $q_data ) {
    Severity: Minor
    Found in includes/admin/class.llms.admin.builder.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 output has 88 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function output() {
    
            global $post;
    
            $course_id = isset( $_GET['course_id'] ) ? absint( $_GET['course_id'] ) : null;
    Severity: Major
    Found in includes/admin/class.llms.admin.builder.php - About 3 hrs to fix

      Method get_existing_posts has 71 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static function get_existing_posts( $post_type = '', $search_term = '', $page = 1 ) {
      
              $args = array(
                  'order'          => 'ASC',
                  'orderby'        => 'post_title',
      Severity: Major
      Found in includes/admin/class.llms.admin.builder.php - About 2 hrs to fix

        Method update_lessons has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static function update_lessons( $lessons, $section ) {
        
                $ret = array();
        
                foreach ( $lessons as $lesson_data ) {
        Severity: Major
        Found in includes/admin/class.llms.admin.builder.php - About 2 hrs to fix

          LLMS_Admin_Builder has 23 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class LLMS_Admin_Builder {
          
              /**
               * Search term string used by `get_existing_posts_where()` when querying for existing posts to clone/add to a course.
               *
          Severity: Minor
          Found in includes/admin/class.llms.admin.builder.php - About 2 hrs to fix

            Method update_questions has 52 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private static function update_questions( $questions, $parent ) {
            
                    $res = array();
            
                    foreach ( $questions as $q_data ) {
            Severity: Major
            Found in includes/admin/class.llms.admin.builder.php - About 2 hrs to fix

              Method handle_ajax has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function handle_ajax( $request ) {
              
                      if ( ! $request['course_id'] || ! current_user_can( 'edit_course', $request['course_id'] ) ) {
                          return array();
                      }
              Severity: Minor
              Found in includes/admin/class.llms.admin.builder.php - About 1 hr to fix

                Function update_quiz has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                    private static function update_quiz( $quiz_data, $lesson ) {
                
                        $res = array_merge(
                            $quiz_data,
                            array(
                Severity: Minor
                Found in includes/admin/class.llms.admin.builder.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 heartbeat_received has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function heartbeat_received( $res, $data ) {
                
                        // Exit if there's no builder data in the heartbeat data.
                        if ( empty( $data['llms_builder'] ) ) {
                            return $res;
                Severity: Minor
                Found in includes/admin/class.llms.admin.builder.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 process_detachments has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                    private static function process_detachments( $data ) {
                
                        $ret = array();
                
                        foreach ( $data['detach'] as $id ) {
                Severity: Minor
                Found in includes/admin/class.llms.admin.builder.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_ajax has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function handle_ajax( $request ) {
                
                        if ( ! $request['course_id'] || ! current_user_can( 'edit_course', $request['course_id'] ) ) {
                            return array();
                        }
                Severity: Minor
                Found in includes/admin/class.llms.admin.builder.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 update_section has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    private static function update_section( $section_data, $course_id ) {
                
                        $res = array_merge(
                            $section_data,
                            array(
                Severity: Minor
                Found in includes/admin/class.llms.admin.builder.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 update_quiz has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private static function update_quiz( $quiz_data, $lesson ) {
                
                        $res = array_merge(
                            $quiz_data,
                            array(
                Severity: Minor
                Found in includes/admin/class.llms.admin.builder.php - About 1 hr to fix

                  Method process_detachments has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private static function process_detachments( $data ) {
                  
                          $ret = array();
                  
                          foreach ( $data['detach'] as $id ) {
                  Severity: Minor
                  Found in includes/admin/class.llms.admin.builder.php - About 1 hr to fix

                    Method update_custom_schemas has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static function update_custom_schemas( $type, $post, $post_data ) {
                    
                            $schemas = self::get_custom_schemas();
                            if ( empty( $schemas[ $type ] ) ) {
                                return;
                    Severity: Minor
                    Found in includes/admin/class.llms.admin.builder.php - About 1 hr to fix

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

                          public static function heartbeat_received( $res, $data ) {
                      
                              // Exit if there's no builder data in the heartbeat data.
                              if ( empty( $data['llms_builder'] ) ) {
                                  return $res;
                      Severity: Minor
                      Found in includes/admin/class.llms.admin.builder.php - About 1 hr to fix

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

                            private static function get_custom_schemas() {
                        
                                $quiz_fields = array();
                        
                                /**
                        Severity: Minor
                        Found in includes/admin/class.llms.admin.builder.php - About 1 hr to fix

                          Method update_section has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private static function update_section( $section_data, $course_id ) {
                          
                                  $res = array_merge(
                                      $section_data,
                                      array(
                          Severity: Minor
                          Found in includes/admin/class.llms.admin.builder.php - About 1 hr to fix

                            Function process_updates has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private static function process_updates( $data ) {
                            
                                    $ret = array();
                            
                                    if ( ! empty( $data['updates']['sections'] ) && is_array( $data['updates']['sections'] ) ) {
                            Severity: Minor
                            Found in includes/admin/class.llms.admin.builder.php - About 45 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 output has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public static function output() {
                            
                                    global $post;
                            
                                    $course_id = isset( $_GET['course_id'] ) ? absint( $_GET['course_id'] ) : null;
                            Severity: Minor
                            Found in includes/admin/class.llms.admin.builder.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