gocodebox/lifterlms-rest

View on GitHub

Showing 191 of 191 total issues

File class-llms-rest-posts-controller.php has 936 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * REST LLMS Posts Controller Class
 *
 * @package LifterLMS_REST/Abstracts
Severity: Major
Found in includes/abstracts/class-llms-rest-posts-controller.php - About 2 days to fix

    File class-llms-rest-courses-controller.php has 801 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * REST Courses Controller
     *
     * @package LifterLMS_REST/Classes/Controllers
    Severity: Major
    Found in includes/server/class-llms-rest-courses-controller.php - About 1 day to fix

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

          protected function get_item_schema_base() {
      
              $schema = (array) parent::get_item_schema_base();
      
              $course_properties = array(
      Severity: Major
      Found in includes/server/class-llms-rest-courses-controller.php - About 1 day to fix

        File class-llms-rest-enrollments-controller.php has 624 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         * REST Enrollments Controller.
         *
         * @package LLMS_REST
        Severity: Major
        Found in includes/server/class-llms-rest-enrollments-controller.php - About 1 day to fix

          Function update_additional_object_fields has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function update_additional_object_fields( $course, $request, $schema, $prepared_item, $creating = true ) {
          
                  $error = new WP_Error();
          
                  // Course catalog visibility.
          Severity: Minor
          Found in includes/server/class-llms-rest-courses-controller.php - About 1 day 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_item_schema_base has 184 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'      => $this->post_type,
          Severity: Major
          Found in includes/abstracts/class-llms-rest-posts-controller.php - About 7 hrs to fix

            File class-llms-rest-controller.php has 456 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            /**
             * Base REST Controller
             *
             * @package LifterLMS_REST/Abstracts
            Severity: Minor
            Found in includes/abstracts/class-llms-rest-controller.php - About 6 hrs to fix

              Method get_item_schema_base has 163 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'      => $this->resource_name,
              Severity: Major
              Found in includes/abstracts/class-llms-rest-users-controller.php - About 6 hrs to fix

                LLMS_REST_Posts_Controller has 47 functions (exceeds 20 allowed). Consider refactoring.
                Open

                abstract class LLMS_REST_Posts_Controller extends LLMS_REST_Controller {
                
                    /**
                     * Post type.
                     *
                Severity: Minor
                Found in includes/abstracts/class-llms-rest-posts-controller.php - About 6 hrs to fix

                  Method get_fields has 156 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function get_fields() {
                  
                          require_once 'tables/class-llms-rest-table-api-keys.php';
                  
                          $add_key = '1' === llms_filter_input( INPUT_GET, 'add-key', FILTER_SANITIZE_NUMBER_INT );
                  Severity: Major
                  Found in includes/admin/class-llms-rest-admin-settings-api-keys.php - About 6 hrs to fix

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

                        protected function get_item_schema_base() {
                    
                            $schema = (array) parent::get_item_schema_base();
                    
                            $schema['properties']['auto_enroll'] = array(
                    Severity: Major
                    Found in includes/server/class-llms-rest-memberships-controller.php - About 6 hrs to fix

                      File class-llms-rest-lessons-controller.php has 420 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      <?php
                      /**
                       * REST Lessons Controller
                       *
                       * @package LifterLMS_REST/Classes/Controllers
                      Severity: Minor
                      Found in includes/server/class-llms-rest-lessons-controller.php - About 6 hrs to fix

                        File class-llms-rest-users-controller.php has 417 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        <?php
                        /**
                         * Base users controller class
                         *
                         * @package  LifterLMS_REST/Abstracts
                        Severity: Minor
                        Found in includes/abstracts/class-llms-rest-users-controller.php - About 6 hrs to fix

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

                              protected function get_item_schema_base() {
                          
                                  $schema = (array) parent::get_item_schema_base();
                          
                                  $lesson_properties = array(
                          Severity: Major
                          Found in includes/server/class-llms-rest-lessons-controller.php - About 5 hrs to fix

                            File class-llms-rest-memberships-controller.php has 402 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            <?php
                            /**
                             * REST Memberships Controller
                             *
                             * @package LifterLMS_REST/Classes/Controllers
                            Severity: Minor
                            Found in includes/server/class-llms-rest-memberships-controller.php - About 5 hrs to fix

                              Similar blocks of code found in 2 locations. Consider refactoring.
                              Open

                                  protected function prepare_collection_query_args( $request ) {
                              
                                      $query_args = parent::prepare_collection_query_args( $request );
                                      if ( is_wp_error( $query_args ) ) {
                                          return $query_args;
                              Severity: Major
                              Found in includes/server/class-llms-rest-lessons-controller.php and 1 other location - About 5 hrs to fix
                              includes/server/class-llms-rest-sections-controller.php on lines 368..409

                              Duplicated Code

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Tuning

                              This issue has a mass of 196.

                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                              Refactorings

                              Further Reading

                              Similar blocks of code found in 2 locations. Consider refactoring.
                              Open

                                  protected function prepare_collection_query_args( $request ) {
                              
                                      $query_args = parent::prepare_collection_query_args( $request );
                                      if ( is_wp_error( $query_args ) ) {
                                          return $query_args;
                              Severity: Major
                              Found in includes/server/class-llms-rest-sections-controller.php and 1 other location - About 5 hrs to fix
                              includes/server/class-llms-rest-lessons-controller.php on lines 607..648

                              Duplicated Code

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Tuning

                              This issue has a mass of 196.

                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                              Refactorings

                              Further Reading

                              Function update_additional_object_fields has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  protected function update_additional_object_fields( $membership, $request, $schema, $prepared_item, $creating = true ) {
                                      $error = new WP_Error();
                              
                                      // Auto enroll.
                                      if ( ! empty( $schema['properties']['auto_enroll'] ) && isset( $request['auto_enroll'] ) ) {
                              Severity: Minor
                              Found in includes/server/class-llms-rest-memberships-controller.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

                              Similar blocks of code found in 2 locations. Consider refactoring.
                              Open

                                  protected function get_name_cell( $webhook ) {
                              
                                      $html      = esc_html( $webhook->get( 'name' ) );
                                      $edit_link = esc_url( $webhook->get_edit_link() );
                                      $html      = '<a href="' . $edit_link . '">' . $html . '</a>';
                              Severity: Major
                              Found in includes/admin/tables/class-llms-rest-table-webhooks.php and 1 other location - About 4 hrs to fix
                              includes/admin/tables/class-llms-rest-table-api-keys.php on lines 42..55

                              Duplicated Code

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Tuning

                              This issue has a mass of 182.

                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                              Refactorings

                              Further Reading

                              Similar blocks of code found in 2 locations. Consider refactoring.
                              Open

                                  protected function get_description_cell( $api_key ) {
                              
                                      $html      = esc_html( $api_key->get( 'description' ) );
                                      $edit_link = esc_url( $api_key->get_edit_link() );
                                      $html      = '<a href="' . $edit_link . '">' . $html . '</a>';
                              Severity: Major
                              Found in includes/admin/tables/class-llms-rest-table-api-keys.php and 1 other location - About 4 hrs to fix
                              includes/admin/tables/class-llms-rest-table-webhooks.php on lines 43..56

                              Duplicated Code

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Tuning

                              This issue has a mass of 182.

                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                              Refactorings

                              Further Reading

                              Severity
                              Category
                              Status
                              Source
                              Language