static/timetable/js/colorchange.js
File colorchange.js
has 444 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
timeTableStorage = [{
"id": 0,
"name": "Table Default",
"data": [],
}];
Function loadCourseData
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function loadCourseData() {
var isDataAvailable = true;
function createScript() {
var scriptTag = document.createElement("script");
Function checkSlotClash
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function checkSlotClash() {
// Remove danger class (shows clashing) form tr in course list table.
$('#courseListTable tbody tr').removeClass('danger');
$('#timetable tr .hidden').removeClass('hidden');
Function addColorChangeEvents
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
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")) {
Function insertCourseToCourseListTable
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function insertCourseToCourseListTable(courseId, courseCode, courseTile, faculty, slotArray, venue, credits, isProject) {
Function addCourseToTimetable
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function addCourseToTimetable(courseId, courseCode, venue, slotArray, isProject) {
Function renameTable
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
function renameTable(tableId, tableName) {
for (var i = 0; i < timeTableStorage.length; i++) {
if (timeTableStorage[i].id == tableId) {
timeTableStorage[i].name = tableName;
updateLocalForage();
- Read upRead up
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
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) {
- Read upRead up
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"