VaTz88/FFCSonTheGo

View on GitHub
src/js/timetable.js

Summary

Maintainability
F
1 wk
Test Coverage

File timetable.js has 640 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 *  This file contains the events and functions applied to
 *  the timetable
 */

Severity: Major
Found in src/js/timetable.js - About 1 day to fix

    Function initializeTimetable has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

    window.initializeTimetable = () => {
        var timetable;
        $('#timetable tr').slice(2).hide();
        $('#timetable tr td:not(:first-child)').remove();
    
    
    Severity: Minor
    Found in src/js/timetable.js - About 5 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

    Function initializeTimetable has 100 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    window.initializeTimetable = () => {
        var timetable;
        $('#timetable tr').slice(2).hide();
        $('#timetable tr td:not(:first-child)').remove();
    
    
    Severity: Major
    Found in src/js/timetable.js - About 4 hrs to fix

      Function checkSlotClash has 87 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function checkSlotClash() {
          $('#timetable tr td').removeClass('clash');
          $('#course-list tr').removeClass('table-danger');
      
          const $theoryHours = $('#theory td:not(.lunch)');
      Severity: Major
      Found in src/js/timetable.js - About 3 hrs to fix

        Function initializeQuickVisualization has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function initializeQuickVisualization() {
            /*
                Click event for the quick visualization buttons
             */
            $('.quick-buttons *[class*="-tile"]').on('click', function () {
        Severity: Major
        Found in src/js/timetable.js - About 2 hrs to fix

          Function addTableToPicker has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function addTableToPicker(tableId, tableName) {
              $('#tt-picker-dropdown').append(
                  `<li>
                      <table class="dropdown-item">
                          <td class="tt-picker-label">
          Severity: Minor
          Found in src/js/timetable.js - About 1 hr to fix

            Function removeCourseFromTimetable has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            window.removeCourseFromTimetable = (course) => {
                $(`#timetable tr td div[data-course="${course}"]`)
                    .parent()
                    .each(function () {
                        if ($(this).children().length != 1) {
            Severity: Minor
            Found in src/js/timetable.js - About 1 hr 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

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

            function appendHeader($layout, width) {
                const $header = $('<div></div>')
                    .css({
                        width: width,
                        'margin-bottom': '1rem',
            Severity: Minor
            Found in src/js/timetable.js - About 1 hr to fix

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

              window.removeCourseFromTimetable = (course) => {
                  $(`#timetable tr td div[data-course="${course}"]`)
                      .parent()
                      .each(function () {
                          if ($(this).children().length != 1) {
              Severity: Minor
              Found in src/js/timetable.js - About 1 hr to fix

                Avoid deeply nested control flow statements.
                Open

                                    while (index >= $quickButtons.find('tr').length) {
                                        $quickButtons.find('table').append('<tr></tr>');
                                    }
                Severity: Major
                Found in src/js/timetable.js - About 45 mins to fix

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

                          html2canvas($layout[0], {
                              scrollX: -window.scrollX,
                              scrollY: -window.scrollY,
                          }).then((canvas) => {
                              $layout.remove();
                  Severity: Major
                  Found in src/js/timetable.js and 1 other location - About 7 hrs to fix
                  src/js/timetable.js on lines 218..238

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

                  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

                          html2canvas($layout[0], {
                              scrollX: -window.scrollX,
                              scrollY: -window.scrollY,
                          }).then((canvas) => {
                              $layout.remove();
                  Severity: Major
                  Found in src/js/timetable.js and 1 other location - About 7 hrs to fix
                  src/js/timetable.js on lines 146..166

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

                  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

                              } else if ($('div', this).data('is-theory')) {
                                  nextStart = parse(
                                      $theoryHours.eq(index + 1).data('start'),
                                      'h:mm aa',
                                      new Date(),
                  Severity: Major
                  Found in src/js/timetable.js and 1 other location - About 2 hrs to fix
                  src/js/timetable.js on lines 509..537

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

                  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 ($('div', $(this).next()).data('is-lab')) {
                                  nextStart = parse(
                                      $labHours.eq(index + 1).data('start'),
                                      'h:mm aa',
                                      new Date(),
                  Severity: Major
                  Found in src/js/timetable.js and 1 other location - About 2 hrs to fix
                  src/js/timetable.js on lines 523..537

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

                  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 (theorySlots && theorySlots.start && theorySlots.end) {
                              $theoryHour.html(
                                  `${theorySlots.start}<br />to<br />${theorySlots.end}`,
                              );
                              $theoryHour.data('start', theorySlots.start);
                  Severity: Major
                  Found in src/js/timetable.js and 1 other location - About 2 hrs to fix
                  src/js/timetable.js on lines 695..699

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

                  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 (labSlots && labSlots.start && labSlots.end) {
                              $labHour.html(`${labSlots.start}<br />to<br />${labSlots.end}`);
                              $labHour.data('start', labSlots.start);
                              $labHour.data('end', labSlots.end);
                          }
                  Severity: Major
                  Found in src/js/timetable.js and 1 other location - About 2 hrs to fix
                  src/js/timetable.js on lines 687..693

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

                  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

                              } else if ($('div', this).data('is-theory')) {
                                  currentEnd = parse(
                                      $theoryHours.eq(index).data('end'),
                                      'h:mm aa',
                                      new Date(),
                  Severity: Major
                  Found in src/js/timetable.js and 1 other location - About 2 hrs to fix
                  src/js/timetable.js on lines 479..507

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

                  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 ($('div', this).data('is-lab')) {
                                  currentEnd = parse(
                                      $labHours.eq(index).data('end'),
                                      'h:mm aa',
                                      new Date(),
                  Severity: Major
                  Found in src/js/timetable.js and 1 other location - About 2 hrs to fix
                  src/js/timetable.js on lines 493..507

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

                  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

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

                                  $('div', this).each(function () {
                                      const dataCourse = $(this).data('course');
                                      $(`#course-list tr[data-course=${dataCourse}]`).addClass(
                                          'table-danger',
                                      );
                  Severity: Minor
                  Found in src/js/timetable.js and 1 other location - About 45 mins to fix
                  src/js/timetable.js on lines 559..564

                  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

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

                                  $('div', $(this).next()).each(function () {
                                      const dataCourse = $(this).data('course');
                                      $(`#course-list tr[data-course=${dataCourse}]`).addClass(
                                          'table-danger',
                                      );
                  Severity: Minor
                  Found in src/js/timetable.js and 1 other location - About 45 mins to fix
                  src/js/timetable.js on lines 542..547

                  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

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

                          var $layout = $('<div></div>').css({
                              padding: '2rem',
                              position: 'absolute',
                              top: 0,
                              left: `calc(-${width}px - 4rem)`,
                  Severity: Minor
                  Found in src/js/timetable.js and 1 other location - About 40 mins to fix
                  src/js/timetable.js on lines 124..129

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

                  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

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

                          var $layout = $('<div></div>').css({
                              padding: '2rem',
                              position: 'absolute',
                              top: 0,
                              left: `calc(-${width}px - 4rem)`,
                  Severity: Minor
                  Found in src/js/timetable.js and 1 other location - About 40 mins to fix
                  src/js/timetable.js on lines 185..190

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

                  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

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

                                  $('#timetable')
                                      .find('tr')
                                      .eq(el[0])
                                      .find('td')
                                      .eq(el[1])
                  Severity: Minor
                  Found in src/js/timetable.js and 1 other location - About 30 mins to fix
                  src/js/timetable.js on lines 345..345

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

                  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

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

                          var $el = $('#timetable').find('tr').eq(el[0]).find('td').eq(el[1]);
                  Severity: Minor
                  Found in src/js/timetable.js and 1 other location - About 30 mins to fix
                  src/js/timetable.js on lines 257..261

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

                  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