-
Notifications
You must be signed in to change notification settings - Fork 0
Description
@shadhankkk 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
Example from src/main/java/duke/Duke.java lines 954-954:
// String exitCommand = "bye";Example from src/main/java/duke/Duke.java lines 955-955:
// String listCommand = "list";Example from src/main/java/duke/Duke.java lines 958-958:
// "What can I do for you?";Suggestion: Remove dead code from the codebase.
Aspect: Method Length
Example from src/main/java/duke/Duke.java lines 806-950:
public String getResponse(String input) {
parser.readInput(input);
String response = "";
String command = parser.getArgument(' ');
taskList = storage.load();
if(command.equals(exitCommand)) {
ui.printClosing();
response = "bye!";
} else if(command.equals("list")) {
response = taskList.listTasks();
} else if(command.equals("mark")) {
int rankToMark = Integer.valueOf(parser.getArgument('\n'));
response = taskList.markTask(rankToMark);
} else if(command.equals("unmark")) {
int rankToUnmark = Integer.valueOf(parser.getArgument('\n'));
response = taskList.unmarkTask(rankToUnmark);
} else if(command.equals("todo")) {
if(input.length() == 4) {
ui.printError("Error: The description of a todo cannot be empty. Terminating program.");
response = "Error: The description of a todo cannot be empty.";
}
String taskName = parser.getArgument('\n');
if(isEmptyString(taskName)) {
ui.printError("Error: The description of a todo cannot be empty. Terminating program.");
response = "Error: The description of a todo cannot be empty.";
}
taskName = taskName.trim();
response = taskList.addTask(new Task(taskName, TODO));
} else if(command.equals("deadline")) {
if(input.length() <= 9) {
ui.printError("Error: The description of a deadline cannot be empty. Terminating program.");
response = "Error: The description of a deadline cannot be empty.";
}
String taskName = parser.getArgument('/', 4);
if(isEmptyString(taskName)) {
ui.printError("Error: The description of a deadline cannot be empty. Terminating program.");
response = "Error: The description of a deadline cannot be empty.";
}
if(input.length() <= 9 + taskName.length() + 4) {
ui.printError("Error: No deadline provided. Terminating program.");
response = "Error: No deadline provided.";
}
String deadline = parser.getArgument('\n');
deadline = deadline.trim();
if(isEmptyString(deadline)) {
ui.printError("Error: No deadline provided. Terminating program.");
response = "Error: No deadline provided.";
}
taskName = taskName.trim();
response = taskList.addTask(new Task(taskName, DEADLINE, deadline));
} else if(command.equals("event")) {
if(input.length() <= 5) {
ui.printError("Error: The description of an event cannot be empty. Terminating program.");
response = "Error: The description of an event cannot be empty.";
}
String taskName = parser.getArgument('/', 6);
if(isEmptyString(taskName)) {
ui.printError("Error: The description of an event cannot be empty. Terminating program.");
response = "Error: The description of an event cannot be empty.";
}
if(input.length() <= 6 + taskName.length() + 6) {
ui.printError("Error: No start time provided for event. Terminating program.");
response = "Error: No start time provided for event.";
}
String startTime = parser.getArgument('/', 4);
if(isEmptyString(startTime)) {
ui.printError("Error: No start time provided for event. Terminating program.");
response = "Error: No start time provided for event.";
}
if(input.length() <= 6 + taskName.length() + 6 + startTime.length() + 4) {
ui.printError("Error: No end time provided for event. Terminating program.");
response = "Error: No end time provided for event.";
}
String endTime = parser.getArgument('\n');
endTime = endTime.trim();
if(isEmptyString(endTime)) {
ui.printError("Error: No end time provided for event. Terminating program.");
response = "Error: No end time provided for event.";
}
taskName = taskName.trim();
startTime = startTime.trim();
String[] eventTimings = new String[] {startTime, endTime};
response = taskList.addTask(new Task(taskName, EVENT, eventTimings));
} else if(command.equals("delete")) {
if(input.length() <= 7) {
ui.printError("Error: You need to specify which task to delete. Terminating program.");
response = "Error: You need to specify which task to delete.";
}
int rankToDelete = Integer.valueOf(parser.getArgument('\n'));
response = taskList.deleteTask(rankToDelete);
} else if(command.equals("find")) {
if(input.length() <= 5) {
ui.printError("Error: You need to give a search query. Terminating program.");
response = "Error: You need to give a search query.";
}
String query = parser.getArgument('\n');
response = taskList.fetchQuery(query);
} else {
System.out.println("Error: Invalid input, terminating program.");
return "Error: Invalid input";
}
storage.save(taskList);
return response;
}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
src\main\java\duke\Duke.java(1117 lines)
Suggestion: Consider breaking large classes into smaller ones, if appropriate. A long class is a sign that perhaps it is dong 'too much'.
Aspect: Header Comments
No easy-to-detect issues 👍
Aspect: Recent Git Commit Message
possible problems in commit 77314b5:
Completed Level-10
- Not in imperative mood (?)
possible problems in commit 4356792:
Completed Week 3 iP
- Not in imperative mood (?)
possible problems in commit e15d486:
Completed Level-9
- Not in imperative mood (?)
Suggestion: Follow the given conventions for Git commit messages for future commits (do not modify past commit messages as doing so will change the commit timestamp that we used to detect your commit timings).
Aspect: Binary files in repo
Suggestion: Avoid committing binary files (e.g., *.class, *.jar, *.exe) or third-party library files in to the repo.
ℹ️ 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.