gocodebox/lifterlms

View on GitHub

Showing 1,420 of 1,425 total issues

File llms.table.course.students.php has 251 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Display students enrolled in a given course on the course students subtab
 *
 * @package LifterLMS/Admin/Reporting/Tables/Classes
Severity: Minor
Found in includes/admin/reporting/tables/llms.table.course.students.php - About 2 hrs to fix

    Function submit has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            this.submit = function( e ) {
    
                var self       = e.data,
                    num        = before_submit.length,
                    checks     = 0,
    Severity: Minor
    Found in assets/js/llms-form-checkout.js - About 2 hrs to fix

      Consider simplifying this complex logical expression.
      Open

                  if ( $blog_id === $object_id ) {
      
                      $menu_items[ $key ]->current = false;
                      foreach ( array( 'current_page_parent', 'current-menu-item' ) as $class ) {
                          if ( in_array( $class, $classes, true ) ) {
      Severity: Critical
      Found in includes/class.llms.nav.menus.php - About 2 hrs to fix

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

            public function output() {
                ?>
                <div class="llms-dashboard-widget-wrap">
                    <h3><?php esc_html_e( 'Activity this week:', 'lifterlms' ); ?></h3>
                    <a class="llms-button-primary" href="<?php echo esc_url( admin_url( 'post-new.php?post_type=course' ) ); ?>">
        Severity: Minor
        Found in includes/admin/class.llms.admin.dashboard-widget.php - About 2 hrs to fix

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

              public function includes() {
          
                  // Instantiate LLMS_Shortcodes before LLMS_Controller_Orders.
                  require_once LLMS_PLUGIN_DIR . 'includes/shortcodes/class.llms.shortcodes.php';
                  require_once LLMS_PLUGIN_DIR . 'includes/shortcodes/class.llms.shortcodes.blocks.php';
          Severity: Minor
          Found in includes/class-llms-loader.php - About 2 hrs to fix

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

            function migrate_spanish_users() {
            
                $per_page = \llms_update_util_get_items_per_page();
            
                $states_migration_map = array(
            Severity: Minor
            Found in includes/functions/updates/llms-functions-updates-6100.php - About 2 hrs to fix

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

              function llms_update_300_migrate_account_field_options() {
              
                  $email_confirm = get_option( 'lifterlms_registration_confirm_email' );
                  if ( 'yes' === $email_confirm ) {
                      $email_confirm = 'yes';
              Severity: Minor
              Found in includes/functions/updates/llms-functions-updates-300.php - About 2 hrs to fix

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

                function llms_is_post_restricted_by_prerequisite( $post_id, $user_id = null ) {
                
                    $post_type = get_post_type( $post_id );
                
                    switch ( $post_type ) {
                Severity: Minor
                Found in includes/functions/llms.functions.access.php - About 2 hrs to fix

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

                      public function send_test( $type, $data = array() ) {
                          if ( empty( $data['attempt_id'] ) ) {
                              return;
                          }
                          $attempt       = new LLMS_Quiz_Attempt( $data['attempt_id'] );
                  includes/notifications/controllers/class.llms.notification.controller.quiz.passed.php on lines 192..205

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

                  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

                      public function send_test( $type, $data = array() ) {
                  
                          if ( empty( $data['attempt_id'] ) ) {
                              return;
                          }
                  includes/notifications/controllers/class.llms.notification.controller.quiz.failed.php on lines 191..201

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

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

                      public function manage_columns( $column, $post_id ) {
                  
                          $lesson = llms_get_post( $post_id );
                          if ( ! $lesson ) {
                              return;

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

                        public function get_data( $key, $achievement ) {
                    
                            // Handle old object being passed in.
                            if ( ! is_a( $achievement, 'LLMS_User_Achievement' ) && property_exists( $achievement, 'achievement_id' ) ) {
                                $achievement = new LLMS_User_Achievement( $achievement->certificate_id );
                    Severity: Minor
                    Found in includes/admin/reporting/tables/llms.table.achievements.php - About 1 hr to fix

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

                          public function get_admin_settings_fields() {
                      
                              $fields = array();
                      
                              $fields[] = array(
                      Severity: Minor
                      Found in includes/abstracts/abstract.llms.payment.gateway.php - About 1 hr to fix

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

                            protected function set_merge_data( $code ) {
                        
                                $quiz_id = $this->notification->get( 'post_id' );
                                $attempt = $this->user->quizzes()->get_last_completed_attempt( $quiz_id );
                                if ( ! $attempt ) {

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

                              describe( 'trailingSlashIt', () => {
                                  const testData = [
                                      [
                                          'Should leave a string with a trailing slash unchanged',
                                          'string/',
                          Severity: Major
                          Found in packages/utils/src/formatting/test/index.js and 2 other locations - About 1 hr to fix
                          packages/dev/test/utils/repo-links.test.js on lines 27..35
                          packages/utils/src/formatting/test/index.js on lines 22..38

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

                          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 3 locations. Consider refactoring.
                          Open

                              describe( 'untrailingSlashIt', () => {
                                  const testData = [
                                      [
                                          'Should leave a string without a trailing slash unchanged',
                                          'string',
                          Severity: Major
                          Found in packages/utils/src/formatting/test/index.js and 2 other locations - About 1 hr to fix
                          packages/dev/test/utils/repo-links.test.js on lines 27..35
                          packages/utils/src/formatting/test/index.js on lines 4..20

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

                          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 3 locations. Consider refactoring.
                          Open

                              describe( 'getIssueLink', () => {
                                  const testData = [
                                      [ 'Should accept issue references to the current project', 'https://github.com/gocodebox/lifterlms/issues/123', '#123' ],
                                      [ 'Should accept issue references to the another project', 'https://github.com/org/repo/issues/456', 'org/repo#456' ],
                                  ];
                          Severity: Major
                          Found in packages/dev/test/utils/repo-links.test.js and 2 other locations - About 1 hr to fix
                          packages/utils/src/formatting/test/index.js on lines 4..20
                          packages/utils/src/formatting/test/index.js on lines 22..38

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

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

                                  answer_question: function( $btn ) {
                          
                                      var self      = this,
                                          $question = this.$container.find( '.llms-question-wrapper' ),
                                          type      = $question.attr( 'data-type' ),
                          Severity: Minor
                          Found in assets/js/llms-quiz.js - About 1 hr to fix

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

                                private function get_table_html() {
                            
                                    $integrations = llms()->integrations()->get_integrations();
                                    ob_start();
                                    ?>
                            Severity: Minor
                            Found in includes/admin/settings/class.llms.settings.integrations.php - About 1 hr to fix

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

                                  public function get_data( $key, $course_id ) {
                              
                                      $course = new LLMS_Course( $course_id );
                              
                                      switch ( $key ) {
                              Severity: Minor
                              Found in includes/admin/reporting/tables/llms.table.student.courses.php - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language