gocodebox/lifterlms

View on GitHub
assets/js/builder/Models/Lesson.js

Summary

Maintainability
B
6 hrs
Test Coverage

Function get_sibling has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        get_sibling: function( direction, status ) {

            direction = 'next' === direction ? direction : 'prev';

            // Functions and vars to use when direction is 'prev' (default).
Severity: Minor
Found in assets/js/builder/Models/Lesson.js - About 1 hr to fix

    Function get_available_prereq_options has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            get_available_prereq_options: function() {
    
                var parent_section_index    = this.get_parent().collection.indexOf( this.get_parent() ),
                    lesson_index_in_section = this.collection.indexOf( this ),
                    options                 = [];
    Severity: Minor
    Found in assets/js/builder/Models/Lesson.js - About 1 hr to fix

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

                      quiz: {
                          class: 'Quiz',
                          conditional: function( model ) {
                              // if quiz is enabled OR not enabled but we have some quiz data as an obj
                              return ( 'yes' === model.get( 'quiz_enabled' ) || ! _.isEmpty( model.get( 'quiz' ) ) );
      Severity: Major
      Found in assets/js/builder/Models/Lesson.js and 1 other location - About 1 hr to fix
      assets/js/builder/Models/Lesson.js on lines 430..438

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

      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

                  this.relationships.children.assignment = {
                      class: 'Assignment',
                      conditional: function( model ) {
                          // If assignment is enabled OR not enabled but we have some assignment data as an obj.
                          return ( 'yes' === model.get( 'assignment_enabled' ) || ! _.isEmpty( model.get( 'assignment' ) ) );
      Severity: Major
      Found in assets/js/builder/Models/Lesson.js and 1 other location - About 1 hr to fix
      assets/js/builder/Models/Lesson.js on lines 22..30

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

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

              get_l10n_type: function( plural ) {
      
                  if ( plural ) {
                      return LLMS.l10n.translate( 'lessons' );
                  }
      Severity: Major
      Found in assets/js/builder/Models/Lesson.js and 3 other locations - About 45 mins to fix
      assets/js/builder/Models/Question.js on lines 218..225
      assets/js/builder/Models/Quiz.js on lines 145..152
      assets/js/builder/Models/Section.js on lines 98..105

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

      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

      There are no issues that match your filters.

      Category
      Status