gocodebox/lifterlms

View on GitHub

Showing 1,420 of 1,425 total issues

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

    public function get_data( $key, $student ) {

        switch ( $key ) {

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

    Method llms_insert_access_plan has 105 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function llms_insert_access_plan( $props = array() ) {
    
        $action = 'create';
    
        if ( ! empty( $props['id'] ) ) {
    Severity: Major
    Found in includes/functions/llms-functions-access-plans.php - About 4 hrs to fix

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

                  } elseif ( is_post_type_archive( 'llms_membership' ) || $query->get( 'page_id' ) == llms_get_page_id( 'memberships' ) || is_tax( array( 'membership_tag', 'membership_cat' ) ) ) {
      
                      $query->set( 'posts_per_page', get_option( 'lifterlms_memberships_per_page', 10 ) );
      
                      $sorting = explode( ',', get_option( 'lifterlms_memberships_ordering', 'menu_order,ASC' ) );
      Severity: Major
      Found in includes/class.llms.query.php and 1 other location - About 4 hrs to fix
      includes/class.llms.query.php on lines 213..247

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

      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

                  if ( is_post_type_archive( 'course' ) || $query->get( 'page_id' ) == llms_get_page_id( 'courses' ) || is_tax( array( 'course_cat', 'course_tag', 'course_difficulty', 'course_track' ) ) ) {
      
                      $query->set( 'posts_per_page', get_option( 'lifterlms_shop_courses_per_page', 10 ) );
      
                      $sorting = explode( ',', get_option( 'lifterlms_shop_ordering', 'menu_order,ASC' ) );
      Severity: Major
      Found in includes/class.llms.query.php and 1 other location - About 4 hrs to fix
      includes/class.llms.query.php on lines 230..247

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

      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

      LLMS_Lesson has 33 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class LLMS_Lesson extends LLMS_Post_Model {
      
          use LLMS_Trait_Audio_Video_Embed;
      
          protected $properties = array(
      Severity: Minor
      Found in includes/models/model.llms.lesson.php - About 4 hrs to fix

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

                        <PanelRow>
                            <SelectControl
                                label={ __( 'Order', 'lifterlms' ) }
                                value={ attributes.order }
                                options={ [
        Severity: Major
        Found in src/blocks/memberships/index.jsx and 1 other location - About 4 hrs to fix
        src/blocks/courses/index.jsx on lines 146..163

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

        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

                        <PanelRow>
                            <SelectControl
                                label={ __( 'Order', 'lifterlms' ) }
                                value={ attributes.order }
                                options={ [
        Severity: Major
        Found in src/blocks/courses/index.jsx and 1 other location - About 4 hrs to fix
        src/blocks/memberships/index.jsx on lines 91..102

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

        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

        File model.llms.question.php has 339 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         * LifterLMS Quiz Question Model
         *
         * @package LifterLMS/Models/Classes
        Severity: Minor
        Found in includes/models/model.llms.question.php - About 4 hrs to fix

          Function get_progress has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

              public function get_progress( $object_id, $type = 'course', $use_cache = true ) {
          
                  $ret       = 0;
                  $cache_key = sprintf( '%1$s_%2$d_progress', $type, $object_id );
                  $cached    = $use_cache ? $this->get( $cache_key ) : '';
          Severity: Minor
          Found in includes/models/model.llms.student.php - About 4 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

          File access-plan.php has 334 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          /**
           * Individual Access Plan as displayed within the "Product Options" metabox.
           *
           * @package LifterLMS/Admin/Views
          Severity: Minor
          Found in includes/admin/views/access-plans/access-plan.php - About 4 hrs to fix

            Method admin_scripts has 100 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function admin_scripts() {
            
                    global $post_type;
                    $screen = get_current_screen();
            
            
            Severity: Major
            Found in includes/admin/class.llms.admin.assets.php - About 4 hrs to fix

              Method generate_inline_styles has 100 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected static function generate_inline_styles( $context = null ) {
              
                      $selector_prefix = ( 'editor' === $context ) ? '.editor-styles-wrapper' : '';
              
                      $styles = array();
              Severity: Major
              Found in includes/theme-support/class-llms-twenty-twenty-one.php - About 4 hrs to fix

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

                <?php
                /**
                 * Notification View: Quiz Passed
                 *
                 * @package LifterLMS/Notifications/Views/Classes
                includes/notifications/views/class.llms.notification.view.quiz.failed.php on lines 1..77

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

                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
                /**
                 * Notification View: Quiz Failed
                 *
                 * @package LifterLMS/Notifications/Views/Classes
                includes/notifications/views/class.llms.notification.view.quiz.passed.php on lines 1..77

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

                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

                File model.llms.access.plan.php has 331 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                /**
                 * LifterLMS Access Plan Model
                 *
                 * @package LifterLMS/Models/Classes
                Severity: Minor
                Found in includes/models/model.llms.access.plan.php - About 3 hrs to fix

                  Method get_settings_group_certs has 98 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function get_settings_group_certs() {
                  
                          $certificate_sizes = llms_get_certificate_sizes();
                  
                          $settings = array(
                  Severity: Major
                  Found in includes/admin/settings/class.llms.settings.engagements.php - About 3 hrs to fix

                    Function llms_update_3160_ensure_no_lesson_dupe_rels has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function llms_update_3160_ensure_no_lesson_dupe_rels() {
                    
                        if ( 'complete' !== get_transient( 'llms_update_3160_ensure_no_dupe_question_rels_status' ) ) {
                            return true;
                        }
                    Severity: Minor
                    Found in includes/functions/updates/llms-functions-updates-3160.php - About 3 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

                                case 'name':
                                    $first = $student->get( 'first_name' );
                                    $last  = $student->get( 'last_name' );
                    
                                    if ( ! $first || ! $last ) {
                    includes/admin/reporting/tables/llms.table.membership.students.php on lines 141..163

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

                    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 'name':
                                    $first = $student->get( 'first_name' );
                                    $last  = $student->get( 'last_name' );
                    
                                    if ( ! $first || ! $last ) {
                    includes/admin/reporting/tables/llms.table.course.students.php on lines 145..167

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

                    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

                    describe( 'isAttributionValid', () => {
                        const testData = [
                            // Valid data.
                            [ 'Should accept a GitHub username', '@username', true ],
                            [ 'Should accept a markdown link', '[username](https://fake.tld)', true ],
                    Severity: Major
                    Found in packages/dev/test/utils/validate-changelog.test.js and 1 other location - About 3 hrs to fix
                    packages/dev/test/utils/validate-changelog.test.js on lines 71..88

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

                    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