gocodebox/lifterlms

View on GitHub

Showing 1,389 of 1,394 total issues

Method get_export_data has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function get_export_data( $key, $student ) {

        switch ( $key ) {

            case 'id':
Severity: Major
Found in includes/admin/reporting/tables/llms.table.students.php - About 2 hrs to fix

    Method set_period has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function set_period( $period = 'today' ) {
    
            $now = current_time( 'timestamp' );
    
            switch ( $period ) {
    Severity: Major
    Found in includes/abstracts/llms.abstract.post.data.php - About 2 hrs to fix

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

              if ( $query->has_results() ) {
                  foreach ( $query->get_attempts() as $attempt ) {
                      $quiz    = llms_get_post( $attempt->get( 'quiz_id' ) );
                      $student = llms_get_student( $attempt->get( 'student_id' ) );
                      if ( $attempt && $student && $quiz ) {
      includes/notifications/controllers/class.llms.notification.controller.quiz.graded.php on lines 96..104

      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 135.

      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

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

              if ( $query->has_results() ) {
                  foreach ( $query->get_attempts() as $attempt ) {
                      $quiz    = llms_get_post( $attempt->get( 'quiz_id' ) );
                      $student = llms_get_student( $attempt->get( 'student_id' ) );
                      if ( $attempt && $student && $quiz ) {
      includes/notifications/controllers/class.llms.notification.controller.quiz.passed.php on lines 109..117

      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 135.

      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 init has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              this.init = function() {
      
                  var self = this;
      
                  $( '.llms-select2-post' ).each( function() {
      Severity: Major
      Found in assets/js/private/llms-metaboxes.js - About 2 hrs to fix

        Method get_field_html has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function get_field_html() {
        
                /**
                 * Allow 3rd parties to create custom field types or their own field HTML methods.
                 *
        Severity: Major
        Found in includes/forms/class-llms-form-field.php - About 2 hrs to fix

          File class-llms-order-generator.php has 276 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          /**
           * LLMS_Order_Generator class file.
           *
           * @package LifterLMS/Classes
          Severity: Minor
          Found in includes/class-llms-order-generator.php - About 2 hrs to fix

            Method recurring_charge has 65 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function recurring_charge( $order_id ) {
            
                    // Make sure the order still exists.
                    $order = llms_get_post( $order_id );
                    if ( ! $order || ! is_a( $order, 'LLMS_Order' ) ) {
            Severity: Major
            Found in includes/controllers/class.llms.controller.orders.php - About 2 hrs to fix

              Function action has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  action: ( { significance, type, comment, entry, interactive, links, attributions, dir, title, useEditor } ) => {
                      if ( ! entry && ! interactive ) {
                          logResult( 'A changelog entry is required.', 'error' );
                          process.exit( 1 );
                      }
              Severity: Minor
              Found in packages/dev/src/cmds/changelog/add.js - 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

              Function output has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function output() {
              
                      global $post;
              
                      parent::output();

              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_block_path has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function get_block_path( $block, $block_list, $iterations = 0 ) {
              
                      foreach ( $block_list as $_block ) {
              
                          // Found the block.
              Severity: Minor
              Found in includes/forms/class-llms-forms.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

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

                  public function __construct() {
              
                      $this->id    = 'integrations';
                      $this->label = __( 'Integrations', 'lifterlms' );
              
              
              Severity: Major
              Found in includes/admin/settings/class.llms.settings.integrations.php and 1 other location - About 2 hrs to fix
              includes/admin/settings/class.llms.settings.checkout.php on lines 38..48

              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 133.

              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

                          <?php if ( 'yes' === get_option( 'lifterlms_retake_lessons', 'no' ) || apply_filters( 'lifterlms_retake_lesson_' . $lesson->get( 'parent_course' ), false ) ) : ?>
              
                              <form action="" class="llms-incomplete-lesson-form" method="POST" name="mark_incomplete">
              
                                  <?php do_action( 'lifterlms_before_mark_incomplete_lesson' ); ?>
              Severity: Major
              Found in templates/course/complete-lesson-link.php and 1 other location - About 2 hrs to fix
              templates/course/complete-lesson-link.php on lines 75..104

              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 133.

              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

                  public function __construct() {
              
                      $this->id    = 'checkout';
                      $this->label = __( 'Checkout', 'lifterlms' );
              
              
              Severity: Major
              Found in includes/admin/settings/class.llms.settings.checkout.php and 1 other location - About 2 hrs to fix
              includes/admin/settings/class.llms.settings.integrations.php on lines 30..40

              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 133.

              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

                      <?php if ( llms_show_mark_complete_button( $lesson ) ) : ?>
              
                          <form action="" class="llms-complete-lesson-form" method="POST" name="mark_complete">
              
                              <?php do_action( 'lifterlms_before_mark_complete_lesson' ); ?>
              Severity: Major
              Found in templates/course/complete-lesson-link.php and 1 other location - About 2 hrs to fix
              templates/course/complete-lesson-link.php on lines 40..69

              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 133.

              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

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

                  public function save( $post_id ) {
              
                      if ( ! llms_verify_nonce( 'lifterlms_meta_nonce', 'lifterlms_save_data' ) ) {
                          return;
                      }

                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

                  Method export has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function export() {
                  
                          if ( empty( llms_filter_input( INPUT_POST, 'llms_generate_export' ) ) || ! llms_verify_nonce( 'lifterlms_export_nonce', 'lifterlms_csv_export_data' ) ) {
                              return false;
                          }

                    Method validate_coupon_code has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static function validate_coupon_code( $request ) {
                    
                            $error = new WP_Error();
                    
                            $request['code'] = ! empty( $request['code'] ) ? sanitize_text_field( $request['code'] ) : '';
                    Severity: Major
                    Found in includes/class.llms.ajax.handler.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
                        Severity
                        Category
                        Status
                        Source
                        Language