gocodebox/lifterlms

View on GitHub

Showing 1,420 of 1,425 total issues

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

            if ( 'clone' === event.action ) {
                question = _.prepareQuestionObjectForCloning( question );
            } else {
                // Use author id instead of the question author object.
                question = _.prepareExistingPostObjectDataForAddingOrCloning( question );
Severity: Major
Found in assets/js/builder/Views/QuestionType.js and 2 other locations - About 1 hr to fix
assets/js/builder/Views/Assignment.js on lines 204..214
assets/js/builder/Views/Quiz.js on lines 285..295

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

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

Consider simplifying this complex logical expression.
Open

    if ( is_home() && $sitewide_membership_id ) {
        $restriction_id = $sitewide_membership_id;
        $reason         = 'sitewide_membership';
        // if it's a search page and the site isn't restricted to a membership bypass restrictions.
    } elseif ( ( is_search() ) && ! get_option( 'lifterlms_membership_required', '' ) ) {
Severity: Critical
Found in includes/functions/llms.functions.access.php - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

    if ( ! function_exists( 'is_lifterlms' ) ) {
    
        /**
         * Determine if a LifterLMS post type or post type archive is being displayed.
         *
    Severity: Critical
    Found in includes/functions/llms-functions-conditional-tags.php - About 1 hr to fix

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

          public function __construct() {
      
              $this->id    = 'courses';
              $this->label = __( 'Courses', 'lifterlms' );
      
      
      Severity: Major
      Found in includes/admin/settings/class.llms.settings.courses.php and 2 other locations - About 1 hr to fix
      includes/admin/settings/class.llms.settings.general.php on lines 30..39
      includes/admin/settings/class.llms.settings.memberships.php on lines 29..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 107.

      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

          public function __construct() {
      
              $this->id    = 'general';
              $this->label = __( 'General', 'lifterlms' );
      
      
      Severity: Major
      Found in includes/admin/settings/class.llms.settings.general.php and 2 other locations - About 1 hr to fix
      includes/admin/settings/class.llms.settings.courses.php on lines 29..38
      includes/admin/settings/class.llms.settings.memberships.php on lines 29..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 107.

      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

          public function __construct() {
      
              $this->id    = 'memberships';
              $this->label = __( 'Memberships', 'lifterlms' );
      
      
      includes/admin/settings/class.llms.settings.courses.php on lines 29..38
      includes/admin/settings/class.llms.settings.general.php on lines 30..39

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

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

          function Donut(options) {
      
              this.settings = $.extend( {
                  element: options.element,
                  percent: 100
      Severity: Minor
      Found in assets/js/app/llms-donut.js - About 1 hr to fix

        Function init_formatting_els has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                init_formatting_els: function() {
        
                    var self = this;
        
                    this.$el.find( '.llms-input-formatting[data-formatting]' ).each( function() {
        Severity: Minor
        Found in assets/js/builder/Views/_Editable.js - About 1 hr to fix

          Function addEvent has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              this.addEvent = function( event, args ) {
          
                  args  = args || {};
                  if ( 'string' === typeof event ) {
                      args.event = event;
          Severity: Minor
          Found in assets/js/app/llms-tracking.js - About 1 hr to fix

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

                public function output() {
            
                    ?>
                    <div id="posttype-llms-nav-items" class="posttypediv">
                        <div id="tabs-panel-llms-nav-items" class="tabs-panel tabs-panel-active">
            Severity: Minor
            Found in includes/class.llms.nav.menus.php - About 1 hr to fix

              Method get_dashboard_widget_data has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function get_dashboard_widget_data() {
                      return apply_filters(
                          /**
                           * Filters the dashboard widget data.
                           *
              Severity: Minor
              Found in includes/admin/class.llms.admin.dashboard-widget.php - About 1 hr to fix

                Method parse_engagement has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function parse_engagement( $engagement, $trigger_data ) {
                
                        $parsed = array(
                            'handler_action' => null,
                            'handler_args'   => null,
                Severity: Minor
                Found in includes/class.llms.engagements.php - About 1 hr to fix

                  Method maybe_schedule_retry has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function maybe_schedule_retry() {
                  
                          if ( ! $this->can_be_retried() ) {
                              return null;
                          }
                  Severity: Minor
                  Found in includes/models/model.llms.order.php - About 1 hr to fix

                    Method get_link has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

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

                      Method get_posts has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function get_posts( $args = array(), $return = 'llms_posts' ) {
                      
                              $serialized_id = serialize( // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
                                  array(
                                      'id' => $this->get_id(),
                      Severity: Minor
                      Found in includes/models/model.llms.instructor.php - About 1 hr to fix

                        Method checkout has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private static function checkout( $atts ) {
                        
                                // if there are membership restrictions, check the user is in at least one membership.
                                // this is to combat CHEATERS.
                                if ( $atts['plan']->has_availability_restrictions() ) {
                        Severity: Minor
                        Found in includes/shortcodes/class.llms.shortcode.checkout.php - About 1 hr to fix

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

                              protected function set_merge_data( $code ) {
                          
                                  $order = $this->post;
                          
                                  switch ( $code ) {

                            Method llms_update_500_add_admin_notice has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function llms_update_500_add_admin_notice() {
                            
                                require_once LLMS_PLUGIN_DIR . 'includes/admin/class.llms.admin.notices.php';
                            
                                $notice_id        = 'v500-welcome-msg';
                            Severity: Minor
                            Found in includes/functions/updates/llms-functions-updates-500.php - About 1 hr to fix

                              Method llms_sd_my_grades_table_content has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function llms_sd_my_grades_table_content( $id, $lesson, $student, $restrictions ) {
                              
                                  ob_start();
                              
                                  /**
                              Severity: Minor
                              Found in includes/functions/llms.functions.templates.dashboard.php - About 1 hr to fix

                                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( getProjectPrivacy() ).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 64..68

                                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

                                Severity
                                Category
                                Status
                                Source
                                Language