@ulricolo7 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/neon/Storage.java lines 49-49:
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
No easy-to-detect issues 👍
Aspect: Method Length
Example from src/main/java/neon/Parser.java lines 21-180:
public Object[] processInput(String input) {
String response;
String[] inputArray = input.split(" ", 2);
switch (inputArray[0]) {
case "bye":
return parseBye();
case "list":
response = tasks.printList();
break;
case "mark":
assert extractTaskIndex(input) <= tasks.getSize() : "input out of range";
if (extractTaskIndex(input) > tasks.getSize()) {
response = "input is out of range! do try again\n";
break;
}
response = tasks.markItem(extractTaskIndex(input));
break;
case "unmark":
assert extractTaskIndex(input) <= tasks.getSize() : "input out of range";
if (extractTaskIndex(input) > tasks.getSize()) {
response = "input is out of range! do try again\n";
break;
}
response = tasks.unmarkItem(extractTaskIndex(input));
break;
case "delete":
assert extractTaskIndex(input) <= tasks.getSize() : "input out of range";
if (extractTaskIndex(input) > tasks.getSize()) {
response = "input is out of range! do try again\n";
break;
}
deleteCache = tasks.getTask(extractTaskIndex(input) - 1);
response = tasks.removeTask(extractTaskIndex(input));
break;
case "undo":
String[] undoInputArray = lastInput.split(" ", 2);
String newInput;
switch (undoInputArray[0]) {
case "undo":
response = "last input was an undo! unable to undo an undo\n";
break;
case "mark":
newInput = lastInput.replace("mark", "unmark");
return processInput(newInput);
case "unmark":
newInput = lastInput.replace("unmark", "mark");
return processInput(newInput);
case "delete":
tasks.addTask(deleteCache);
response = "task restored!\n";
break;
case "todo":
tasks.removeTask(tasks.getSize());
response = "todo removed!\n";
break;
case "deadline":
tasks.removeTask(tasks.getSize());
response = "deadline removed!\n";
break;
case "event":
tasks.removeTask(tasks.getSize());
response = "event removed!\n";
break;
default:
response = "last input cannot be undone!\n";
break;
}
break;
case "find":
String taskToFind = input.replace("find", "").trim();
assert !taskToFind.isEmpty() : "no task found";
if (taskToFind.isEmpty()) {
response = "found no description of task! do try again\n";
break;
}
StringBuilder message = new StringBuilder();
message.append("list of tasks:\n");
TaskList foundTask = tasks.findTask(taskToFind);
for (int i = 0; i < foundTask.getSize(); i++) {
message.append(foundTask.getTask(i) + "\n");
}
response = message.toString();
break;
case "todo":
String taskTodo = input.replace("todo", "").trim();
assert !taskTodo.isEmpty() : "no task found";
if (taskTodo.isEmpty()) {
response = "found no description of task! do try again\n";
break;
}
Todo newTodo = new Todo(taskTodo, false);
tasks.addTask(newTodo);
response = "adding todo to list : " + taskTodo + "\n";
break;
case "deadline":
String taskDeadline = input.replace("deadline", "").trim();
String[] partsDeadline = taskDeadline.split("\\s*/by\\s*");
assert partsDeadline.length != 1 : "no task found";
if (partsDeadline.length == 1) {
response = "found no description of task! do try again\n";
break;
}
Deadline newDeadline = new Deadline(partsDeadline[0], false,
(partsDeadline[1]));
tasks.addTask(newDeadline);
response = "adding deadline to list : " + newDeadline.getName() + "\n";
break;
case "event":
String taskEvent = input.replace("event", "").trim();
String[] partsEvent = taskEvent.split("\\s*/from\\s*|\\s*/to\\s*");
assert partsEvent.length != 3 : "incomplete input";
if (partsEvent.length == 1) {
response = "found no description of task! do try again";
break;
} else if (partsEvent.length < 3 || partsEvent[1].isEmpty()) {
response = "dates are incomplete! do try again\n";
break;
}
Event newEvent = new Event(partsEvent[0], false,
partsEvent[1], partsEvent[2]);
tasks.addTask(newEvent);
response = "adding event to list : " + newEvent.getName() + "\n";
break;
default:
response = "cannot read : " + inputArray[0] + "\n";
break;
}
lastInput = input;
return new Object[] {false, 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
No easy-to-detect issues 👍
Aspect: Header Comments
Example from src/main/java/neon/Task.java lines 64-66:
/**
* Assign the value of true into isCompleted.
*/
Example from src/main/java/neon/Task.java lines 71-73:
/**
* Assign the value of false into isCompleted.
*/
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
possible problems in commit c721c47:
Fix code quality
This commit is made to fix a few potential structural issues with the code and also ensure the overall quality of the code.
- body not wrapped at 72 characters: e.g.,
This commit is made to fix a few potential structural issues with the code and also ensure the overall quality of the code.
possible problems in commit 27d0aea:
Add Assertions
Add Assertion into the bot
All of the assertions added are within Parser.java. The intention is to test and check for valid inputs during testing.
Edited much of the code to reflect the intended interaction better as well.
- body not wrapped at 72 characters: e.g.,
All of the assertions added are within Parser.java. The intention is to test and check for valid inputs during testing.
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 👍
❗ 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.
@ulricolo7 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/neon/Storage.javalines49-49: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
No easy-to-detect issues 👍
Aspect: Method Length
Example from
src/main/java/neon/Parser.javalines21-180: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/neon/Task.javalines64-66:Example from
src/main/java/neon/Task.javalines71-73: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
possible problems in commit
c721c47:This commit is made to fix a few potential structural issues with the code and also ensure the overall quality of the code.possible problems in commit
27d0aea:All of the assertions added are within Parser.java. The intention is to test and check for valid inputs during testing.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 👍
❗ 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.