You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Douglch 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.
publicstaticCommandparse(StringfullCommand) throwsUnknownCommandException, EmptyDescException {
try {
String[] inputArr = fullCommand.split(" ");
Commandscommand = Commands.valueOf(inputArr[0].toUpperCase());
Stringdesc = "variable not initialised";
StringBuildersb = newStringBuilder();
switch (command) {
caseTODO:
if (inputArr.length == 1) {
thrownewEmptyDescException("OOPS!!! The description of a todo cannot be empty.");
}
for (inti = 1; i < inputArr.length; i++) {
sb.append(inputArr[i]);
if (i != inputArr.length - 1) {
sb.append(" ");
}
}
Todotodo = newTodo(sb.toString().trim());
returnnewTodoCommand(todo);
caseDEADLINE:
if (inputArr.length == 1) {
thrownewEmptyDescException("OOPS!!! The description of a deadline cannot be empty.");
}
for (inti = 1; i < inputArr.length; i++) {
if (inputArr[i].equals("/by")) {
desc = sb.toString();
sb.setLength(0);
continue;
}
sb.append(inputArr[i]);
if (i != inputArr.length - 1) {
sb.append(" ");
}
}
String[] dateTime = sb.toString().split(" ");
assert !desc.isEmpty() : "desc (deadline description) should be filled, otherwise caught by exception";
Deadlinedeadline = newDeadline(desc, dateTime[0], dateTime[1]);
returnnewDeadlineCommand(deadline);
caseEVENT:
if (inputArr.length == 1) {
thrownewEmptyDescException("OOPS!!! The description of an event cannot be empty.");
}
Stringfrom = "local variable not initialised";
for (inti = 1; i < inputArr.length; i++) {
if (inputArr[i].equals("/from")) {
desc = sb.toString();
sb.setLength(0);
continue;
} elseif (inputArr[i].equals("/to")) {
from = sb.toString();
sb.setLength(0);
continue;
}
sb.append(inputArr[i]);
if (i != inputArr.length - 1) {
sb.append(" ");
}
}
assert !desc.isEmpty() : "desc (event description) should be filled, otherwise caught by exception";
assert !from.isEmpty() : "from (event starting date) should be filled";
Eventevent = newEvent(desc, from, sb.toString().trim());
returnnewEventCommand(event);
caseMARK:
index = Integer.parseInt(inputArr[1]);
returnnewMarkCommand(index);
caseUNMARK:
index = Integer.parseInt(inputArr[1]);
returnnewUnmarkCommand(index);
caseDELETE:
index = Integer.parseInt(inputArr[1]);
returnnewDeleteCommand(index);
caseLIST:
returnnewListCommand();
caseBYE:
returnnewByeCommand();
caseFIND:
if (inputArr.length == 1) {
thrownewEmptyDescException("OOPS!!! You need to specify what you want to find!");
}
returnnewFindCommand(inputArr[1]);
caseUNDO:
if (inputArr.length == 1) {
thrownewEmptyDescException("OOPS!!! Please specify how many CRUD versions you want to undo!");
}
intindex = Integer.parseInt(inputArr[1]);
returnnewUndoCommand(index);
default:
assertfalse; // Execution should never reach this point!thrownewUnknownCommandException("OOPS!!! You need to give me an input :-(");
}
} catch (IllegalArgumentExceptione) {
thrownewUnknownCommandException("OOPS!!! I'm sorry, but I don't know what that means :-(");
}
}
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.
/** * The starting date and time of the event. * * @return String representation of the starting date and time set. */
Suggestion: Ensure method/class header comments follow the format specified in the coding standard, in particular, the phrasing of the overview statement.
❗ 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.
The text was updated successfully, but these errors were encountered:
@Douglch 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
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/lele/task/TaskList.java
lines177-177
:// assert this.listSize() >= inputIndex : "Index parameter queried should be within the task size";
Suggestion: Remove dead code from the codebase.
Aspect: Method Length
Example from
src/main/java/lele/parser/Parser.java
lines54-148
: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/lele/Lele.java
lines65-69
:Example from
src/main/java/lele/task/Deadline.java
lines43-47
:Example from
src/main/java/lele/task/Event.java
lines34-38
: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 (Subject Only)
possible problems in commit
bdf730f
:Changed UG images folder name
Suggestion: Follow the given conventions for Git commit messages for future commits (no need to modify past commit messages).
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.The text was updated successfully, but these errors were encountered: