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
@Ramanathan0908 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.
publicStringparseInput(Stringinput, TaskListtaskList) throwsDukeException {
String[] tokens = input.split(" ", 2);
Stringcommand = tokens[0];
Stringarguments = tokens.length == 2 ? tokens[1] : null;
switch (command) {
case"bye":
return"exit";
case"list":
returntaskList.toString();
case"todo": {
if (arguments == null) {
thrownewDukeException("Todo description cannot be empty");
}
TasknewTask = newToDo(arguments.trim());
taskList.addTask(newTask);
return"I've added: " + newTask + " you have " + taskList.getTaskListSize() + " duke.tasks left";
}
case"deadline": {
if (arguments == null) {
thrownewDukeException("Deadline description cannot be empty");
}
String[] deadlineArgs = arguments.split("/by", 2);
if (deadlineArgs.length == 1) {
thrownewDukeException("Deadline requires a /by date");
}
System.out.println(deadlineArgs[1]);
TasknewTask = newDeadline(deadlineArgs[0].trim(), deadlineArgs[1].trim());
taskList.addTask(newTask);
return"I've added: " + newTask + " you have " + taskList.getTaskListSize() + " tasks left";
}
case"event": {
if (arguments == null) {
thrownewDukeException("Event description cannot be empty");
}
String[] deadlineArgs = arguments.split("/at", 2);
if (deadlineArgs.length == 1) {
thrownewDukeException("Event requires a /at date");
}
TasknewTask = newEvent(deadlineArgs[0].trim(), deadlineArgs[1].trim());
taskList.addTask(newTask);
return"I've added: " + newTask + " you have " + taskList.getTaskListSize() + " tasks left";
}
case"mark": {
try {
if (arguments == null) {
thrownewDukeException("Please enter a valid task number");
}
inttaskNo = Integer.parseInt(arguments) - 1;
TasktaskTobeMarked = taskList.getTask(taskNo);
taskTobeMarked.markDone();
return"I have marked: " + taskTobeMarked + " as done";
} catch (NumberFormatException | IndexOutOfBoundsExceptione) {
thrownewDukeException("Please enter a valid task number");
}
}
case"unmark": {
try {
if (arguments == null) {
thrownewDukeException("Please enter a valid task number");
}
inttaskNo = Integer.parseInt(arguments) - 1;
TasktaskTobeMarked = taskList.getTask(taskNo);
taskTobeMarked.markNotDone();
return"I have marked: " + taskTobeMarked + " as not done";
} catch (NumberFormatException | IndexOutOfBoundsExceptione) {
thrownewDukeException("Please enter a valid task number");
}
}
case"delete": {
try {
if (arguments == null) {
thrownewDukeException("Please enter a valid task number");
}
inttaskNo = Integer.parseInt(arguments) - 1;
TasktaskTobeDeleted = taskList.getTask(taskNo);
taskList.removeTask(taskNo);
return"I have deleted: " + taskTobeDeleted;
} catch (NumberFormatException | IndexOutOfBoundsExceptione) {
thrownewDukeException("Please enter a valid task number");
}
}
case"find": {
if (arguments == null) {
thrownewDukeException("Please enter a keyword to search");
}
TaskListmatchingTasks = newTaskList();
for (inti = 0; i < taskList.getTaskListSize(); i++) {
if (taskList.getTask(i).containsKeyword(arguments.trim())) {
matchingTasks.addTask(taskList.getTask(i));
}
}
return"Here are your matching tasks:\n" + matchingTasks.toString();
}
case"sort": {
taskList.sort();
returntaskList.toString();
}
default:
return"I don't know that command please enter a valid command";
}
}
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.
Suggestion: Ensure method/class header comments follow the format specified in the coding standard, in particular, the phrasing of the overview statement.
ℹ️ 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.
The text was updated successfully, but these errors were encountered:
@Ramanathan0908 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
Example from
src/main/java/duke/dukeExceptions/DukeException.java
lines1-1
:Suggestion: Follow the package naming convention specified by the coding standard.
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
lines38-104
:Example from
src/main/java/duke/Parser.java
lines26-130
: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
Example from
src/main/java/duke/Duke.java
lines128-131
:Example from
src/main/java/duke/TaskList.java
lines23-27
:Example from
src/main/java/duke/tasks/Task.java
lines25-27
:Suggestion: Ensure method/class header comments follow the format specified in the coding standard, in particular, the phrasing of the overview statement.
Aspect: Recent Git Commit Message (Subject Only)
possible problems in commit
c4e9ce3
:resolved merge conflicts
possible problems in commit
f6e4270
:added assertions to document important assumptions
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
[email protected]
if you want to follow up on this post.The text was updated successfully, but these errors were encountered: