gocodebox/lifterlms

View on GitHub

Showing 1,420 of 1,425 total issues

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

                        <?php $i = 1; while ( $i <= 24 ) : ?>
                            <option value="<?php echo esc_attr( $i ); ?>"<?php selected( $i, ( $plan && 'month' === $period ) ? $plan->get( 'length' ) : '' ); ?>><?php printf( esc_html( _n( 'for %s month', 'for %s months', $i, 'lifterlms' ) ), esc_html( $i ) ); ?></option>
                            <?php
                            ++$i;
endwhile;
Severity: Major
Found in includes/admin/views/access-plans/access-plan.php and 3 other locations - About 1 hr to fix
includes/admin/views/access-plans/access-plan.php on lines 176..180
includes/admin/views/access-plans/access-plan.php on lines 196..200
includes/admin/views/access-plans/access-plan.php on lines 206..210

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

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

        this.bind_controllers = function( $controllers ) {

            $controllers = $controllers || $( '[data-is-controller]' );

            $controllers.each( function() {
Severity: Minor
Found in assets/js/private/llms-metaboxes.js - About 1 hr to fix

    Function writeChangelog has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function writeChangelog( log ) {
        const { dir } = log;
        let { title } = log;
        delete log.dir;
        delete log.title;
    Severity: Minor
    Found in packages/dev/src/cmds/changelog/add.js - About 1 hr to fix

      Function render_editor has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              render_editor: function( field ) {
      
                  var self     = this,
                      wpEditor = _.getEditor();
      
      
      Severity: Minor
      Found in assets/js/builder/Views/SettingsFields.js - About 1 hr to fix

        Method gateways has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function gateways() {
                $id = 'no-gateways';
        
                if ( ! apply_filters( 'llms_admin_notice_no_payment_gateways', llms()->payment_gateways()->has_gateways( true ) ) ) {
                    $html  = __( 'No LifterLMS Payment Gateways are currently enabled. Students will only be able to enroll in courses or memberships with free access plans.', 'lifterlms' ) . '<br><br>';
        Severity: Minor
        Found in includes/admin/class.llms.admin.notices.core.php - About 1 hr to fix

          Method admin_print_scripts has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function admin_print_scripts() {
          
                  $screen = get_current_screen();
          
                  global $post;
          Severity: Minor
          Found in includes/admin/class.llms.admin.assets.php - About 1 hr to fix

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

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

              Method register_meta_boxes has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function register_meta_boxes() {
              
                      add_meta_box(
                          'llms_dashboard_welcome_video',
                          __( 'Welcome to LifterLMS', 'lifterlms' ),
              Severity: Minor
              Found in includes/admin/class.llms.admin.resources.php - About 1 hr to fix

                Method generate_csv has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function generate_csv() {
                
                        $csv = array();
                
                        $orders = new WP_Query(

                  Method add_elements has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function add_elements( $elements ) {
                  
                          // Accent Background.
                          $elements['content']['accent']['background-color'] = array_merge(
                              $elements['content']['accent']['background-color'],
                  Severity: Minor
                  Found in includes/theme-support/class-llms-twenty-twenty.php - About 1 hr to fix

                    Method get_enrollment_status has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function get_enrollment_status( $product_id, $use_cache = true ) {
                    
                            $status       = false;
                            $product_type = get_post_type( $product_id );
                    
                    
                    Severity: Minor
                    Found in includes/models/model.llms.student.php - About 1 hr to fix

                      Method unenroll has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function unenroll( $product_id, $trigger = 'any', $new_status = 'expired' ) {
                      
                              // Can only unenroll those that are a currently enrolled.
                              if ( ! $this->is_enrolled( $product_id, 'all', false ) ) {
                                  return false;
                      Severity: Minor
                      Found in includes/models/model.llms.student.php - About 1 hr to fix

                        Method llms_update_access_plans has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public static function llms_update_access_plans( $request ) {
                        
                                if ( empty( $request['plans'] ) || ! is_array( $request['plans'] ) || empty( $request['post_id'] ) ) {
                                    return new WP_Error( 'error', __( 'Missing Required Parameters.', 'lifterlms' ) );
                                }
                        Severity: Minor
                        Found in includes/class.llms.ajax.handler.php - About 1 hr to fix

                          Method get_core_forms has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function get_core_forms( $return = 'posts', $use_cache = true ) {
                          
                                  global $wpdb;
                          
                                  $forms_cache_key = 'posts' === $return ? 'llms_core_forms' : 'llms_core_form_ids';
                          Severity: Minor
                          Found in includes/forms/class-llms-forms.php - About 1 hr to fix

                            Method get_password_reset_fields has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public static function get_password_reset_fields( $key = '', $login = '' ) {
                            
                                    $fields = array();
                                    foreach ( array( 'checkout', 'registration' ) as $location ) {
                                        $fields = self::find_password_fields( $location );
                            Severity: Minor
                            Found in includes/class.llms.person.handler.php - About 1 hr to fix

                              Method enqueue_scripts has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public static function enqueue_scripts() {
                              
                                      // I don't think we need these next 3 scripts.
                                      wp_enqueue_script( 'jquery-ui-tooltip' );
                                      wp_enqueue_script( 'jquery-ui-datepicker' );
                              Severity: Minor
                              Found in includes/class.llms.frontend.assets.php - About 1 hr to fix

                                Method prepare has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    protected function prepare() {
                                
                                        if ( empty( $this->settings['id'] ) ) {
                                            $this->settings['id'] = uniqid( 'llms-field-' );
                                        }
                                Severity: Minor
                                Found in includes/forms/class-llms-form-field.php - About 1 hr to fix

                                  Method explode_options_to_fields has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function explode_options_to_fields( $is_hidden = false ) {
                                  
                                          $fields = array();
                                          $value  = ! empty( $this->settings['value'] ) || is_array( $this->settings['value'] )
                                              ? $this->settings['value']
                                  Severity: Minor
                                  Found in includes/forms/class-llms-form-field.php - About 1 hr to fix

                                    Method validate_matching_fields has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        public function validate_matching_fields( $posted_data, $fields ) {
                                    
                                            $err      = new WP_Error();
                                            $err_data = array();
                                    
                                    
                                    Severity: Minor
                                    Found in includes/forms/class-llms-form-validator.php - About 1 hr to fix

                                      Method get_core_caps has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          private static function get_core_caps( $role ) {
                                      
                                              $all_caps = array_fill_keys( array_values( self::get_all_core_caps() ), true );
                                      
                                              switch ( $role ) {
                                      Severity: Minor
                                      Found in includes/class.llms.roles.php - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language