@Plishh 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/echo/Echo.java lines 22-22:
private boolean awaitingEditInput = false; // To track if we are waiting for a follow-up response
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
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/echo/Ui.java lines 31-31:
//System.out.println(no + " . " + tasks.get(i).toString());
Example from src/main/java/echo/Ui.java lines 52-52:
//System.out.println("Hello, I'm Echo\n" + logo);
Example from src/main/java/echo/Ui.java lines 71-71:
//System.out.println("OOPS!!! " + message);
Suggestion: Remove dead code from the codebase.
Aspect: Method Length
Example from src/main/java/echo/Echo.java lines 50-104:
public String run(String input) {
if (awaitingEditInput) {
// If we are awaiting an edit response, handle the follow-up here
awaitingEditInput = false; // Reset this after handling
return taskToEdit.editTask(input);
}
String[] parts = Parser.parseCommand(input);
String command = parts[0];
try {
switch (command) {
case "bye":
storage.save(tasks.getTasks());
return ui.showGoodbyeMessage();
case "list":
return ui.showTaskList(tasks.getTasks());
case "mark":
tasks.markTask(Integer.parseInt(parts[1]));
return ui.showMarkedTask(tasks.getTask(Integer.parseInt(parts[1])));
case "unmark":
tasks.unmarkTask(Integer.parseInt(parts[1]));
return ui.showUnmarkedTask(tasks.getTask(Integer.parseInt(parts[1])));
case "todo":
Todo todo = tasks.addTodo(parts[1]);
return ui.showTaskAdded(todo, tasks.getTasks().size());
case "deadline":
Deadline deadline = tasks.addDeadline(parts[1]);
return ui.showTaskAdded(deadline, tasks.getTasks().size());
case "event":
Events event = tasks.addEvent(parts[1]);
return ui.showTaskAdded(event, tasks.getTasks().size());
case "delete":
Task removedTask = tasks.deleteTask(Integer.parseInt(parts[1]));
return ui.showTaskRemoved(removedTask, tasks.getTasks().size());
case "find":
String toFind = parts[1];
return tasks.find(toFind);
case "edit":
// Ask the user for further input (follow-up question)
awaitingEditInput = true; // Set to true to track that we're waiting for input
int taskToEditNo = Integer.parseInt(parts[1]); // Store the task to edit
taskToEdit = tasks.getTask(taskToEditNo);
return "What would you like to edit in task " + taskToEdit + "?";
default:
return ui.showErrorMessage("I'm sorry, but I don't know what that means :-(");
}
} catch (EchoException | IOException e) {
return ui.showErrorMessage(e.getMessage());
}
}
Example from src/main/java/echo/Storage.java lines 40-95:
public List<Task> load() throws IOException {
List<Task> tasks = new ArrayList<>();
File file = new File(filePath); //always using same file
assert filePath != null && !filePath.isEmpty() : "File path should be valid.";
if (file.exists()) {
Scanner saveScanner = new Scanner(file);
while (saveScanner.hasNextLine()) {
String input = saveScanner.nextLine();
String[] parts = input.split("\\|");
String type = parts[0];
String marked = parts[1];
String des = parts[2];
String info = parts[3];
switch (type) {
case "T":
Todo todo = new Todo(des);
if (Objects.equals(marked, "1")) {
todo.setDone();
}
tasks.add(todo);
break;
case "D":
String[] details = input.split("/by ", 2);
if (details.length == 2) {
Deadline deadlineTask = new Deadline(des, details[1]);
if (Objects.equals(marked, "1")) {
deadlineTask.setDone();
}
tasks.add(deadlineTask);
}
break;
case "E":
String[] eventDetails = input.split(" /from ", 2);
if (eventDetails.length == 2) {
String[] times = eventDetails[1].split(" /to ", 2);
if (times.length == 2) {
Events eventTask = new Events(des, times[0], times[1]);
if (Objects.equals(marked, "1")) {
eventTask.setDone();
}
tasks.add(eventTask);
}
}
break;
default:
System.out.println("Unknown task type: " + type);
break;
}
}
}
return tasks;
}
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
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 cs2103@comp.nus.edu.sg if you want to follow up on this post.
@Plishh 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/echo/Echo.javalines22-22: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
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/echo/Ui.javalines31-31://System.out.println(no + " . " + tasks.get(i).toString());Example from
src/main/java/echo/Ui.javalines52-52://System.out.println("Hello, I'm Echo\n" + logo);Example from
src/main/java/echo/Ui.javalines71-71://System.out.println("OOPS!!! " + message);Suggestion: Remove dead code from the codebase.
Aspect: Method Length
Example from
src/main/java/echo/Echo.javalines50-104:Example from
src/main/java/echo/Storage.javalines40-95: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
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
cs2103@comp.nus.edu.sgif you want to follow up on this post.