gocodebox/lifterlms-rest

View on GitHub

Showing 156 of 191 total issues

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

    protected function get_filters_to_be_removed_for_response( $course ) {

        $filters = array();

        if ( llms_blocks_is_post_migrated( $course->get( 'id' ) ) ) {
Severity: Major
Found in includes/server/class-llms-rest-courses-controller.php - About 2 hrs to fix

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

        protected function prepare_object_for_response( $access_plan, $request ) {
    
            $data    = parent::prepare_object_for_response( $access_plan, $request );
            $context = $request->get_param( 'context' );
    
    
    Severity: Major
    Found in includes/server/class-llms-rest-access-plans-controller.php - About 2 hrs to fix

      Method create_item has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function create_item( $request ) {
      
              $schema = $this->get_item_schema();
      
              $prepared_item = $this->prepare_item_for_database( $request );
      Severity: Major
      Found in includes/abstracts/class-llms-rest-posts-controller.php - About 2 hrs to fix

        Method register_routes has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function register_routes() {
        
                register_rest_route(
                    $this->namespace,
                    '/' . $this->rest_base,
        Severity: Minor
        Found in includes/server/class-llms-rest-enrollments-controller.php - About 2 hrs to fix

          Method register_routes has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function register_routes() {
          
                  register_rest_route(
                      $this->namespace,
                      '/' . $this->rest_base,
          Severity: Minor
          Found in includes/abstracts/class-llms-rest-controller.php - About 2 hrs to fix

            Method get_item_schema_base has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function get_item_schema_base() {
            
                    $schema = array(
                        '$schema'    => 'http://json-schema.org/draft-04/schema#',
                        'title'      => 'students-enrollments',
            Severity: Minor
            Found in includes/server/class-llms-rest-enrollments-controller.php - About 2 hrs to fix

              Method get_item_schema_base has 49 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function get_item_schema_base() {
              
                      return array(
                          '$schema'    => 'http://json-schema.org/draft-04/schema#',
                          'title'      => 'students-progress',
              Severity: Minor
              Found in includes/server/class-llms-rest-students-progress-controller.php - About 1 hr to fix

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

                    public function create_item( $request ) {
                
                        $schema = $this->get_item_schema();
                
                        $prepared_item = $this->prepare_item_for_database( $request );
                Severity: Minor
                Found in includes/abstracts/class-llms-rest-posts-controller.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 get_collection_params has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function get_collection_params() {
                
                        $query_params = parent::get_collection_params();
                
                        $query_params['context']['default'] = 'view';
                Severity: Minor
                Found in includes/abstracts/class-llms-rest-controller.php - About 1 hr to fix

                  Method delivery_after has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function delivery_after( $delivery_id, $req_args, $res, $duration ) {
                  
                          // Parse response.
                          if ( is_wp_error( $res ) ) {
                              $res_code    = $res->get_error_code();
                  Severity: Minor
                  Found in includes/models/class-llms-rest-webhook.php - About 1 hr to fix

                    Method get_item_schema_base has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function get_item_schema_base() {
                    
                            return array(
                                '$schema'    => 'http://json-schema.org/draft-04/schema#',
                                'title'      => 'api_key',
                    Severity: Minor
                    Found in includes/server/class-llms-rest-api-keys-controller.php - About 1 hr to fix

                      Method prepare_links has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function prepare_links( $lesson, $request ) {
                      
                              $links = parent::prepare_links( $lesson, $request );
                      
                              unset( $links['content'] );
                      Severity: Minor
                      Found in includes/server/class-llms-rest-lessons-controller.php - About 1 hr to fix

                        Function update_item has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function update_item( $request ) {
                        
                                $student_id = (int) $request['id'];
                                $post_id    = (int) $request['post_id'];
                        
                        
                        Severity: Minor
                        Found in includes/server/class-llms-rest-enrollments-controller.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 get_fields has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public static function get_fields() {
                        
                                require_once 'tables/class-llms-rest-table-webhooks.php';
                        
                                $add_hook = '1' === llms_filter_input( INPUT_GET, 'add-webhook', FILTER_SANITIZE_NUMBER_INT );
                        Severity: Minor
                        Found in includes/admin/class-llms-rest-admin-settings-webhooks.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_item has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function update_item( $request ) {
                        
                                $object = $this->get_object( (int) $request['id'] );
                                if ( is_wp_error( $object ) ) {
                                    return $object;
                        Severity: Minor
                        Found in includes/abstracts/class-llms-rest-posts-controller.php - About 1 hr to fix

                          Method prepare_links has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function prepare_links( $course, $request ) {
                          
                                  $links     = parent::prepare_links( $course, $request );
                                  $course_id = $course->get( 'id' );
                          
                          
                          Severity: Minor
                          Found in includes/server/class-llms-rest-courses-controller.php - About 1 hr to fix

                            Method get_topics has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function get_topics() {
                            
                                    /**
                                     * Filter the available webhook topics.
                                     *
                            Severity: Minor
                            Found in includes/class-llms-rest-webhooks.php - About 1 hr to fix

                              Method delete_item has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function delete_item( $request ) {
                              
                                      $object   = $this->get_object( (int) $request['id'] );
                                      $response = new WP_REST_Response();
                                      $response->set_status( 204 );
                              Severity: Minor
                              Found in includes/abstracts/class-llms-rest-posts-controller.php - About 1 hr to fix

                                Method update_item has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function update_item( $request ) {
                                
                                        $student_id = (int) $request['id'];
                                        $post_id    = (int) $request['post_id'];
                                
                                
                                Severity: Minor
                                Found in includes/server/class-llms-rest-enrollments-controller.php - About 1 hr to fix

                                  Function prepare_item_for_database has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      protected function prepare_item_for_database( $request ) {
                                          $prepared_item = parent::prepare_item_for_database( $request );
                                          $schema        = $this->get_item_schema();
                                  
                                          // Restriction action.
                                  Severity: Minor
                                  Found in includes/server/class-llms-rest-memberships-controller.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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language