@mistyk786 We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, so that you can avoid similar problems in your tP code (which will be graded more strictly for code quality).
IMPORTANT: Note that the script looked for just a few easy-to-detect problems only, and at-most three example are given i.e., there can be other areas/places to improve.
Aspect: Tab Usage
No easy-to-detect issues 👍
Aspect: Naming boolean variables/methods
Example from src/main/java/commands/ReminderCommand.java lines 18-18:
Example from src/main/java/commands/FindCommand.java lines 15-15:
Suggestion: Follow the given naming convention for boolean variables/methods (e.g., use a boolean-sounding prefix).You may ignore the above if you think the name already follows the convention (the script can report false positives in some cases)
Aspect: Brace Style
Example from src/main/java/tasks/Task.java lines 46-47:
Suggestion: As specified by the coding standard, use egyptian style braces.
Aspect: Package Name Style
No easy-to-detect issues 👍
Aspect: Class Name Style
No easy-to-detect issues 👍
Aspect: Dead Code
No easy-to-detect issues 👍
Aspect: Method Length
Example from src/main/java/io/EventParser.java lines 85-155:
public static Task parseTaskFromFile(String line) throws CortanaException {
String[] parts = line.split(" \\| ");
if (parts.length < 3) {
throw new CortanaException("Invalid task format: Missing essential fields. \n");
}
String taskType = parts[0];
String isDoneStr = parts[1];
String description = parts[2];
if (!isDoneStr.equals(" ") && !isDoneStr.equals("X")) {
throw new CortanaException("Invalid task format: Unrecognized essential field: " + isDoneStr + "\n");
}
boolean isDone = isDoneStr.equals("X");
try {
switch (taskType) {
case "T":
ToDo todo = new ToDo(description);
if (isDone) {
todo.markAsDone();
}
return todo;
case "D":
if (parts.length < 4) {
throw new CortanaException("Invalid Deadline format: Missing date/time.");
}
String[] deadlineParts = parts[3].split(" ", 2);
if (deadlineParts.length < 2) {
throw new CortanaDateTimeException();
}
LocalDate date = parseDate(deadlineParts[0]);
LocalTime time = parseTime(deadlineParts[1]);
Deadline deadline = new Deadline(description, date, time);
if (isDone) {
deadline.markAsDone();
}
return deadline;
case "E":
if (parts.length < 5) {
throw new CortanaException("Invalid event format: Missing start or end date/time.");
}
String[] eventStartParts = parts[3].split(" ", 2);
String[] eventEndParts = parts[4].split(" ", 2);
if (eventStartParts.length < 2 || eventEndParts.length < 2) {
throw new CortanaDateTimeException();
}
LocalDate eventDateStart = parseDate(eventStartParts[0]);
LocalTime eventTimeStart = parseTime(eventStartParts[1]);
LocalDate eventDateEnd = parseDate(eventEndParts[0]);
LocalTime eventTimeEnd = parseTime(eventEndParts[1]);
Event event = new Event(description, eventDateStart, eventDateEnd, eventTimeStart, eventTimeEnd);
if (isDone) {
event.markAsDone();
}
return event;
default:
throw new CortanaException("Unknown task type: " + taskType);
}
} catch (DateTimeParseException e) {
throw new CortanaException(e.getMessage());
}
}
Example from src/main/java/io/EventParser.java lines 165-236:
public static String parseTask(String line, String taskType, Tasklist tasks) throws CortanaException {
String output = "";
try {
switch (taskType) {
case "todo":
ToDo todo = new ToDo(line);
tasks.addTask(todo);
output = Ui.print("Task added:\n" + todo.toString());
break;
case "deadline":
String[] parts = line.split(" /by ", 2);
if (parts.length != 2) {
throw new CortanaDateTimeException();
}
String deadlineDescription = parts[0].trim();
String deadlineString = parts[1].trim();
String[] dateTimeParts = deadlineString.split(" ", 2);
if (dateTimeParts.length < 2) {
throw new CortanaDateTimeException();
}
try {
LocalDate date = parseDate(dateTimeParts[0]);
LocalTime time = parseTime(dateTimeParts[1]);
Deadline deadline = new Deadline(deadlineDescription, date, time);
tasks.addTask(deadline);
output = Ui.print("Task added:\n" + deadline.toString());
} catch (DateTimeParseException e) {
throw new CortanaDateTimeException();
}
break;
case "event":
String[] parts2 = line.split(" /from | /to ");
if (parts2.length != 3) {
throw new CortanaDateTimeException();
}
String eventDescription = parts2[0].trim();
String eventStartString = parts2[1].trim();
String eventEndString = parts2[2].trim();
String[] startParts = eventStartString.split(" ", 2);
String[] endParts = eventEndString.split(" ", 2);
if (startParts.length < 2 || endParts.length < 2) {
throw new CortanaDateTimeException();
}
try {
LocalDate startDate = parseDate(startParts[0]);
LocalTime startTime = parseTime(startParts[1]);
LocalDate endDate = parseDate(endParts[0]);
LocalTime endTime = parseTime(endParts[1]);
Event event = new Event(eventDescription, startDate, endDate, startTime, endTime);
tasks.addTask(event);
output = Ui.print("Task added:\n" + event.toString());
} catch (DateTimeParseException e) {
throw new CortanaDateTimeException();
}
break;
default:
throw new CortanaException("Unknown task type: " + taskType);
}
} catch (DateTimeParseException e) {
throw new CortanaDateTimeException();
}
return output;
}
Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods e.g., extract some code blocks into separate methods. You may ignore this suggestion if you think a longer method is justified in a particular case.
Aspect: Class size
No easy-to-detect issues 👍
Aspect: Header Comments
No easy-to-detect issues 👍
Aspect: Recent Git Commit Messages
No easy-to-detect issues 👍
Aspect: Binary files in repo
No easy-to-detect issues 👍
❗ You are not required to (but you are welcome to) fix the above problems in your iP, unless you have been separately asked to resubmit the iP due to code quality issues.
ℹ️ The bot account used to post this issue is un-manned. Do not reply to this post (as those replies will not be read). Instead, contact [email protected] if you want to follow up on this post.
@mistyk786 We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, so that you can avoid similar problems in your tP code (which will be graded more strictly for code quality).
IMPORTANT: Note that the script looked for just a few easy-to-detect problems only, and at-most three example are given i.e., there can be other areas/places to improve.
Aspect: Tab Usage
No easy-to-detect issues 👍
Aspect: Naming boolean variables/methods
Example from
src/main/java/commands/ReminderCommand.javalines18-18:Example from
src/main/java/commands/FindCommand.javalines15-15:Suggestion: Follow the given naming convention for boolean variables/methods (e.g., use a boolean-sounding prefix).You may ignore the above if you think the name already follows the convention (the script can report false positives in some cases)
Aspect: Brace Style
Example from
src/main/java/tasks/Task.javalines46-47:} else {Suggestion: As specified by the coding standard, use egyptian style braces.
Aspect: Package Name Style
No easy-to-detect issues 👍
Aspect: Class Name Style
No easy-to-detect issues 👍
Aspect: Dead Code
No easy-to-detect issues 👍
Aspect: Method Length
Example from
src/main/java/io/EventParser.javalines85-155:Example from
src/main/java/io/EventParser.javalines165-236:Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods e.g., extract some code blocks into separate methods. You may ignore this suggestion if you think a longer method is justified in a particular case.
Aspect: Class size
No easy-to-detect issues 👍
Aspect: Header Comments
No easy-to-detect issues 👍
Aspect: Recent Git Commit Messages
No easy-to-detect issues 👍
Aspect: Binary files in repo
No easy-to-detect issues 👍
❗ You are not required to (but you are welcome to) fix the above problems in your iP, unless you have been separately asked to resubmit the iP due to code quality issues.
ℹ️ The bot account used to post this issue is un-manned. Do not reply to this post (as those replies will not be read). Instead, contact
[email protected]if you want to follow up on this post.