@arshinsikka 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/shin/Storage.java lines 23-76:
public ArrayList<Task> load() throws IOException {
ArrayList<Task> tasks = new ArrayList<>();
File file = new File(filePath);
if (!file.exists()) {
file.getParentFile().mkdirs();
file.createNewFile();
return tasks;
}
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
while ((line = br.readLine()) != null) {
String[] taskDetails = line.split("\\|");
String taskType = taskDetails[0].trim();
boolean isDone = taskDetails[1].trim().equals("1");
String description = taskDetails[2].trim();
Task task = null;
switch (taskType) {
case "T":
task = new Todo(description);
break;
case "D":
try {
LocalDate parsedDate = LocalDate.parse(taskDetails[3].trim());
task = new Deadline(description, parsedDate.toString());
} catch (Exception e) {
System.out.println("Error parsing deadline date: " + taskDetails[3]);
}
break;
case "E":
try {
LocalDate fromDate = LocalDate.parse(taskDetails[3].trim());
LocalDate toDate = LocalDate.parse(taskDetails[4].trim());
task = new Event(description, fromDate.toString(), toDate.toString());
} catch (Exception e) {
System.out.println("Error parsing event date: " + taskDetails[3] + " to " + taskDetails[4]);
}
break;
default:
System.out.println("Unknown task type found: " + taskType);
continue;
}
if (task != null) {
if (isDone) {
task.markAsDone();
}
tasks.add(task);
}
}
br.close();
return tasks;
}
Example from src/main/java/shin/Shin.java lines 51-156:
public void run() {
ui.showWelcome();
boolean isExit = false;
while (!isExit) {
try {
String fullCommand = ui.readCommand();
ui.showLine();
String[] parts = Parser.parse(fullCommand); // Get command & arguments
String command = parts[0];
switch (command) {
case "bye":
isExit = true;
System.out.println("Bye. Hope to see you again soon!");
break;
case "list":
tasks.printTasks();
break;
case "todo":
if (parts.length < 2) {
ui.showError("Description for todo cannot be empty!");
break;
}
Task newTodo = new Todo(parts[1]);
tasks.addTask(newTodo);
storage.save(tasks);
ui.showTaskAdded(newTodo, tasks.size());
break;
case "deadline":
if (parts.length < 2 || !parts[1].contains(" /by ")) {
ui.showError("Invalid format! Use: deadline <desc> /by yyyy-MM-dd");
break;
}
String[] deadlineParts = parts[1].split(" /by ");
Task newDeadline = new Deadline(deadlineParts[0], deadlineParts[1]);
tasks.addTask(newDeadline);
storage.save(tasks);
ui.showTaskAdded(newDeadline, tasks.size());
break;
case "event":
if (parts.length < 2 || !parts[1].contains(" /from ") || !parts[1].contains(" /to ")) {
ui.showError("Invalid format! Use: event <desc> /from yyyy-MM-dd /to yyyy-MM-dd");
break;
}
String[] eventParts = parts[1].split(" /from | /to ");
Task newEvent = new Event(eventParts[0], eventParts[1], eventParts[2]);
tasks.addTask(newEvent);
storage.save(tasks);
ui.showTaskAdded(newEvent, tasks.size());
break;
case "mark":
try {
int index = Integer.parseInt(parts[1]) - 1;
tasks.getTask(index).markAsDone();
storage.save(tasks);
System.out.println("Nice! I've marked this task as done:");
System.out.println(" " + tasks.getTask(index));
} catch (Exception e) {
ui.showError("Invalid mark command! Use: mark <task number>");
}
break;
case "unmark":
try {
int index = Integer.parseInt(parts[1]) - 1;
tasks.getTask(index).markAsNotDone();
storage.save(tasks);
System.out.println("OK, I've marked this task as not done yet:");
System.out.println(" " + tasks.getTask(index));
} catch (Exception e) {
ui.showError("Invalid unmark command! Use: unmark <task number>");
}
break;
case "delete":
try {
int indexToDelete = Integer.parseInt(parts[1]) - 1;
Task removedTask = tasks.getTask(indexToDelete);
tasks.removeTask(indexToDelete);
storage.save(tasks);
System.out.println("Noted. I've removed this task:");
System.out.println(" " + removedTask);
System.out.println("Now you have " + tasks.size() + " tasks in the list.");
} catch (Exception e) {
ui.showError("Invalid delete command! Use: delete <task number>");
}
break;
default:
ui.showError("Unknown command.");
}
// Other cases...
ui.showLine();
} catch (Exception e) {
ui.showError(e.getMessage());
}
}
ui.closeScanner();
}
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 Messages
possible problems in commit d6f0541:
Applied Java coding standard fixes
- Not in imperative mood (?)
possible problems in commit 8d5ca47:
- Not in imperative mood (?)
possible problems in commit a7a6c1e:
Added JUnit tests for TaskList and Deadline
- 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
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.
@arshinsikka 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/shin/Storage.javalines23-76:Example from
src/main/java/shin/Shin.javalines51-156: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 Messages
possible problems in commit
d6f0541:possible problems in commit
8d5ca47:possible problems in commit
a7a6c1e: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
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.sgif you want to follow up on this post.