inderpartap/Bunk-O-Meter

View on GitHub
static/timetable/js/colorchange.js

Summary

Maintainability
D
1 day
Test Coverage

File colorchange.js has 444 lines of code (exceeds 250 allowed). Consider refactoring.
Open

timeTableStorage = [{
    "id": 0,
    "name": "Table Default",
    "data": [],
}];
Severity: Minor
Found in static/timetable/js/colorchange.js - About 6 hrs to fix

    Function loadCourseData has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function loadCourseData() {
        var isDataAvailable = true;
    
        function createScript() {
            var scriptTag = document.createElement("script");
    Severity: Minor
    Found in static/timetable/js/colorchange.js - About 2 hrs to fix

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

      function checkSlotClash() {
          // Remove danger class (shows clashing) form tr in course list table.
          $('#courseListTable tbody tr').removeClass('danger');
          $('#timetable tr .hidden').removeClass('hidden');
      
      Severity: Minor
      Found in static/timetable/js/colorchange.js - About 1 hr to fix

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

        function addColorChangeEvents() {
            $("#timetable .TimetableContent:not([disabled])").click(function () {
                if ((!$(this).hasClass("clash")) && $(this).children("div").length === 0) {
                    $(this).toggleClass("highlight");
                    if (!$(this).hasClass("highlight")) {
        Severity: Minor
        Found in static/timetable/js/colorchange.js - About 1 hr to fix

          Function insertCourseToCourseListTable has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          function insertCourseToCourseListTable(courseId, courseCode, courseTile, faculty, slotArray, venue, credits, isProject) {
          Severity: Major
          Found in static/timetable/js/colorchange.js - About 1 hr to fix

            Function addCourseToTimetable has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function addCourseToTimetable(courseId, courseCode, venue, slotArray, isProject) {
            Severity: Minor
            Found in static/timetable/js/colorchange.js - About 35 mins to fix

              Function renameTable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function renameTable(tableId, tableName) {
                  for (var i = 0; i < timeTableStorage.length; i++) {
                      if (timeTableStorage[i].id == tableId) {
                          timeTableStorage[i].name = tableName;
                          updateLocalForage();
              Severity: Minor
              Found in static/timetable/js/colorchange.js - About 25 mins 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 removeTable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function removeTable(tableId) {
                  for (var i = 0; i < timeTableStorage.length; ++i) {
                      if (timeTableStorage[i].id == tableId) {
                          // If it is the active table, change activeTable.
                          if (activeTable.id == tableId) {
              Severity: Minor
              Found in static/timetable/js/colorchange.js - About 25 mins 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

              There are no issues that match your filters.

              Category
              Status