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 code further.
IMPORTANT: Note that the script looked for just a few easy-to-detect problems only, and at-most one example is given i.e., there can be other areas/places to improve.
Aspect: Tab Usage
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.java
line 73
:
public static void addTaskScreen() throws IOException, DukeException {
System.out.println("____________________________________________________________");
System.out.println("Please add tasks");
System.out.println("____________________________________________________________");
String str = readCommand();
if (str.equals("bye")) {
saveTask();
finishConversation();
} else if (str.contains("done")) {
markDone(str);
System.out.println("Mark task done");
addTaskScreen();
} else if (str.equals("list")) {
listTask();
addTaskScreen();
} else if ((str.contains("todo"))) {
missingTaskError(str);
int dividerPosition = str.indexOf(" ");
String task = str.substring(dividerPosition + 1);
ToDos newTask = new ToDos(task);
addTask(newTask);
addTaskScreen();
} else if ((str.contains("deadline"))) {
missingTaskError(str);
missingDateTimeError(str);
int dividerPosition = str.indexOf(" ");
int dividerPositionSlash = str.indexOf("/");
String task = str.substring(dividerPosition + 1, dividerPositionSlash);
String by = str.substring(dividerPositionSlash + 4);
Deadlines newTask = new Deadlines(task, by);
addTask(newTask);
addTaskScreen();
} else if ((str.contains("event"))) {
missingTaskError(str);
missingDateTimeError(str);
int dividerPosition = str.indexOf(" ");
int dividerPositionSlash = str.indexOf("/");
String task = str.substring(dividerPosition + 1, dividerPositionSlash);
String calender = str.substring(dividerPositionSlash + 4);
int dateAndTime = calender.indexOf(" ");
String date = calender.substring(0, dateAndTime);
String time = calender.substring(dateAndTime + 1);
Events newTask = new Events(task, date, time);
addTask(newTask);
addTaskScreen();
} else if (str.contains("delete")) {
deleteTask(str);
addTaskScreen();
} else {
wrongInputFormatError(str);
}
}
Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods.