gocodebox/lifterlms

View on GitHub

Showing 1,420 of 1,425 total issues

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

    it.each( testData )( '%s', ( name, slug, expected, isPublic ) => {
        mockedApiReturn = getMockApiReturn( isPublic );
        mockedSlug = slug;
        expect( isProjectPrivate() ).toBe( expected );
    } );
Severity: Major
Found in packages/dev/test/utils/get-project-privacy.test.js and 1 other location - About 1 hr to fix
packages/dev/test/utils/get-project-privacy.test.js on lines 38..42

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

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

    public function get_fields() {

        $post_type = get_post_type_object( $this->post->post_type );

        $restrictions = get_post_meta( $this->post->ID, $this->prefix . 'restricted_levels', true );
Severity: Minor
Found in includes/admin/post-types/meta-boxes/class.llms.meta.box.access.php - About 1 hr to fix

    Method __construct has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function __construct() {
    
            // Achievements.
            new LLMS_Meta_Box_Achievement();
            new LLMS_Meta_Box_Achievement_Sync();
    Severity: Minor
    Found in includes/admin/post-types/class.llms.meta.boxes.php - About 1 hr to fix

      Method student_information has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function student_information() {
      
              $post_type  = get_post_type( $this->post->ID );
              $student_id = $this->current_student_id();
              $student    = $student_id ? llms_get_student( $student_id ) : $student_id;

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

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

          Method llms_merge_code_button has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function llms_merge_code_button( $target = 'content', $echo = true, $codes = array() ) {
          
              $screen = get_current_screen();
          
              if ( ! $codes && $screen && isset( $screen->post_type ) ) {
          Severity: Minor
          Found in includes/admin/llms.functions.admin.php - About 1 hr to fix

            Method get_author_id has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function get_author_id( $raw ) {
            
                    $author_id = 0;
            
                    // If raw is missing an ID and Email, use current user id.
            Severity: Minor
            Found in includes/abstracts/llms-abstract-generator-posts.php - About 1 hr to fix

              Method record_transaction has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function record_transaction( $data = array() ) {
              
                      extract(
                          array_merge(
                              array(
              Severity: Minor
              Found in includes/models/model.llms.order.php - About 1 hr to fix

                Method get_description has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function get_description( $context = 'course' ) {
                
                        $key = $this->get( 'meta_key' );
                
                        $student = $this->get_student();
                Severity: Minor
                Found in includes/models/model.llms.user.postmeta.php - About 1 hr to fix

                  Method set has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function set( $key, $val ) {
                  
                          // Don't set the ID.
                          if ( 'id' === $key ) {
                              return $this;
                  Severity: Minor
                  Found in includes/models/model.llms.question.choice.php - About 1 hr to fix

                    Method add_profile_nav_items has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function add_profile_nav_items() {
                    
                            $profile_endpoints = $this->get_profile_endpoints();
                    
                            if ( empty( $profile_endpoints ) ) {
                    Severity: Minor
                    Found in includes/integrations/class.llms.integration.buddypress.php - About 1 hr to fix

                      Method create has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function create( $content ) {
                              global $wpdb;
                      
                              $new_user_achievement = apply_filters(
                                  'lifterlms_new_achievement',
                      Severity: Minor
                      Found in includes/class.llms.achievement.php - About 1 hr to fix

                        Method check_voucher_duplicate has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public static function check_voucher_duplicate() {
                        
                                $post_id = ! empty( $_REQUEST['postId'] ) ? absint( llms_filter_input( INPUT_POST, 'postId', FILTER_SANITIZE_NUMBER_INT ) ) : 0;
                                $codes   = ! empty( $_REQUEST['codes'] ) ? llms_filter_input_sanitize_string( INPUT_POST, 'codes', array( FILTER_REQUIRE_ARRAY ) ) : array();
                        
                        
                        Severity: Minor
                        Found in includes/class.llms.ajax.handler.php - About 1 hr to fix

                          Method create_pending_order has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function create_pending_order() {
                          
                                  $verify = $this->verify_request( '_llms_checkout_nonce', self::ACTION_CREATE_PENDING_ORDER );
                                  if ( ! $verify ) {
                                      return $verify;
                          Severity: Minor
                          Found in includes/controllers/class-llms-controller-checkout.php - About 1 hr to fix

                            Method register_meta has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function register_meta() {
                            
                                    $props = array(
                                        '_llms_form_location'                => array(
                                            'description' => __( 'Determines the front-end location where the form is displayed.', 'lifterlms' ),
                            Severity: Minor
                            Found in includes/forms/class-llms-form-post-type.php - About 1 hr to fix

                              Method get_date_range_by_filter has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public static function get_date_range_by_filter( $filter ) {
                              
                                      $today         = current_time( 'Y-m-d' );
                                      $current_month = date( 'm', strtotime( $today ) );
                                      $current_year  = date( 'Y', strtotime( $today ) );
                              Severity: Minor
                              Found in includes/class.llms.date.php - About 1 hr to fix

                                Method create_files has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public static function create_files() {
                                        $upload_dir = wp_upload_dir();
                                        $files      = array(
                                            array(
                                                'base'    => LLMS_LOG_DIR,
                                Severity: Minor
                                Found in includes/class.llms.install.php - About 1 hr to fix

                                  Method llms_current_user_can has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  function llms_current_user_can( $cap, $obj_id = null ) {
                                  
                                      $caps  = LLMS_Roles::get_all_core_caps();
                                      $grant = false;
                                  
                                  
                                  Severity: Minor
                                  Found in includes/functions/llms.functions.person.php - About 1 hr to fix

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

                                                case 'memberships_expired':
                                                    $status      = explode( '_', $key );
                                                    $status      = array_pop( $status );
                                                    $memberships = $student->get_memberships(
                                                        array(
                                    Severity: Major
                                    Found in includes/admin/reporting/tables/llms.table.students.php and 1 other location - About 1 hr to fix
                                    includes/admin/reporting/tables/llms.table.students.php on lines 269..283

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

                                    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

                                                case 'courses_expired':
                                                    $status  = explode( '_', $key );
                                                    $status  = array_pop( $status );
                                                    $courses = $student->get_courses(
                                                        array(
                                    Severity: Major
                                    Found in includes/admin/reporting/tables/llms.table.students.php and 1 other location - About 1 hr to fix
                                    includes/admin/reporting/tables/llms.table.students.php on lines 291..305

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

                                    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