You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@johnnythesnake12 We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, to help you improve the iP code further.
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.
publicvoidrun() {
ui.showWelcomeMessage();
while (true) {
StringuserInput = ui.getUserInput();
Commandcommand = Parser.parseCommand(userInput);
Stringdescription = Parser.parseDescription(userInput);
switch (command) {
caseEXIT:
storage.save(tasks, "tasks.txt");
ui.closeScanner();
ui.showExitMessage();
return;
caseLIST:
ui.showTaskList(tasks);
break;
caseUNMARK:
try {
inttaskNumber = Integer.parseInt(description) - 1;
if (taskNumber >= 0 && taskNumber < tasks.size()) {
tasks.unmarkTask(taskNumber);
} else {
ui.showError("Task number out of range.");
}
} catch (NumberFormatExceptione) {
ui.showError("Invalid task number. Please provide a valid integer.");
}
break;
caseMARK:
try {
inttaskNumber = Integer.parseInt(description) - 1;
if (taskNumber >= 0 && taskNumber < tasks.size()) {
tasks.markTaskAsDone(taskNumber);
} else {
ui.showError("Task number out of range.");
}
} catch (NumberFormatExceptione) {
ui.showError("Invalid task number. Please provide a valid integer.");
}
break;
caseTODO:
try {
if (description.isEmpty()) {
thrownewEmptyTodoException();
}
Todotodo = newTodo(description, false);
tasks.addTask(todo);
} catch (EmptyTodoExceptione) {
System.out.println(e.getMessage());
}
break;
caseDEADLINE:
if (description.isEmpty()) {
try {
thrownewEmptyDeadlineException();
} catch (EmptyDeadlineExceptione) {
System.out.println(e.getMessage());
}
} else {
// Find the index of the deadline separator "/"intseparatorIndex = description.indexOf('/');
if (separatorIndex != -1) { // Ensure the separator exists in the input// Extract the task description and deadlineStringdescriptionString = description.substring(0, separatorIndex).trim();
Stringdeadline = description.substring(separatorIndex + 4).trim();
Stringpattern = "\\d{4}/\\d{2}/\\d{2}";
PatterndatePattern = Pattern.compile(pattern);
Matchermatcher = datePattern.matcher(deadline);
if (matcher.find()) {
DateTimeFormatterformatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
LocalDatelocalDateDeadline = LocalDate.parse(deadline, formatter);
DeadlinedeadlineTask = newDeadline(descriptionString, false, localDateDeadline);
tasks.addTask(deadlineTask);
} else {
System.out.println("Please input your deadline in YYYY/MM/DD format");
}
} else {
System.out.println("Invalid input format for deadline. Please input in the following format: <deadline> <description> /by <YYYY/MM/DD> ");
}
}
break;
caseEVENT:
if (description.isEmpty()) {
try {
thrownewEmptyEventException();
} catch (EmptyEventExceptione) {
System.out.println(e.getMessage());
}
} else {
// Find the indices of the time separatorsintfromIndex = description.indexOf("/from");
inttoIndex = description.indexOf("/to");
if (fromIndex != -1 && toIndex != -1) {
// Extract the task description, startTime, and endTimeStringdescriptionString = description.substring(0, fromIndex).trim();
StringstartTime = description.substring(fromIndex + 5, toIndex).trim();
StringendTime = description.substring(toIndex + 3).trim();
// Create a new Event objectEventeventTask = newEvent(descriptionString, false, startTime, endTime);
tasks.addTask(eventTask);
} else {
System.out.println("Invalid input format for event command.");
}
}
break;
caseDELETE:
try {
inttaskNumber = Integer.parseInt(description) - 1;
if (taskNumber >= 0 && taskNumber < tasks.size()) {
tasks.deleteTask(taskNumber);
} else {
ui.showError("Task number out of range.");
}
} catch (NumberFormatExceptione) {
ui.showError("Invalid task number. Please provide a valid integer.");
}
break;
caseINVALID:
ui.showError("Invalid command. Please try again.");
break;
}
}
}
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.
ℹ️ 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 cs2103@comp.nus.edu.sg if you want to follow up on this post.
The text was updated successfully, but these errors were encountered:
@johnnythesnake12 We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, to help you improve the iP code further.
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
No easy-to-detect issues 👍
Aspect: Brace Style
No easy-to-detect issues 👍
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/duke/Duke.java
lines25-155
: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 Message
possible problems in commit
7f86037
:possible problems in commit
96f087e
:possible problems in commit
f56c1a7
:Suggestion: Follow the given conventions for Git commit messages for future commits (no need to modify past commit messages).
Aspect: Binary files in repo
No easy-to-detect 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
cs2103@comp.nus.edu.sg
if you want to follow up on this post.The text was updated successfully, but these errors were encountered: