@lkldev 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
No easy-to-detect issues 👍
Aspect: Method Length
Example from src/main/java/luke/parser/Parser.java lines 48-91:
private static Map<String, CommandAction> commandActionMap = new HashMap<>() {{
put("bye", CommandAction.EXIT);
put("list", CommandAction.LIST);
put("mark", CommandAction.MARK);
put("unmark", CommandAction.UNMARK);
put("todo", CommandAction.TODO);
put("event", CommandAction.EVENT);
put("deadline", CommandAction.DEADLINE);
put("delete", CommandAction.DELETE);
put("find", CommandAction.FIND);
put("recur", CommandAction.RECUR);
}};
/**
* Parses the specified input and returns the appropriate command.
*
* @param input The specified input to parse.
* @return The appropriate command based on the specified input.
*/
public static Command parse(String input) {
String[] inputs = input.split(" ", 2);
try {
CommandAction cmdAction = commandActionMap.getOrDefault(inputs[0], CommandAction.INVALID);
assert(cmdAction != null);
switch (cmdAction.getCommandActionType()) {
case NO_ACTION:
return new ExitCommand();
case READ:
return prepareReadCommand(cmdAction, inputs);
case ADD:
return prepareAddCommand(cmdAction, inputs);
case UPDATE:
return prepareUpdateCommand(cmdAction, inputs);
default:
return new InvalidCommand();
}
} catch (NumberFormatException e) {
return new InvalidCommand(INVALID_NUMBER_FORMAT_MESSAGE);
} catch (DateTimeParseException e) {
return new InvalidCommand(String.format(INVALID_DATE_FORMAT_MESSAGE, e.getMessage()));
} catch (IllegalArgumentException e) {
return new InvalidCommand(e.getMessage());
}
}
Example from src/test/java/luke/parser/ParserTest.java lines 208-247:
public void recurCommand_invalidInput_incorrectCommandResult() {
String commandString = "recur";
String errorMsg = "Oops, the force has encountered an error:\n%s\nPlease try again :(";
String expected = String.format(errorMsg, "recur has invalid number of arguments.");
testCommand(commandString, expected, new TaskList());
commandString = "recur event sleep /at 12/12/2022 0000";
errorMsg = "Oops, the force has encountered an error:\n%s\nPlease try again :(";
expected = String.format(errorMsg, "recur command requires the every argument.");
testCommand(commandString, expected, new TaskList());
commandString = "recur event sleep /at 12/12/2022 0000 /every second";
errorMsg = "Oops, the force has encountered an error:\n%s\nPlease try again :(";
errorMsg = String.format(errorMsg, "The force does not comprehend the date:\n%s");
expected = String.format(errorMsg, "\"second\" is not a valid argument for every.");
testCommand(commandString, expected, new TaskList());
commandString = "recur /every day";
errorMsg = "Oops, the force has encountered an error:\n%s\nPlease try again :(";
expected = String.format(errorMsg, "recur command requires the task argument.");
testCommand(commandString, expected, new TaskList());
commandString = "recur eat sleep code /every day";
errorMsg = "Oops, the force has encountered an error:\n%s\nPlease try again :(";
errorMsg = String.format(errorMsg, "recur command encountered an error:\n%s");
expected = String.format(errorMsg, "Command not supported.");
testCommand(commandString, expected, new TaskList());
commandString = "recur mark 1 /every day";
errorMsg = "Oops, the force has encountered an error:\n%s\nPlease try again :(";
errorMsg = String.format(errorMsg, "recur command encountered an error:\n%s");
expected = String.format(errorMsg, "Command not supported.");
testCommand(commandString, expected, new TaskList());
commandString = "recur todo /every day";
errorMsg = "Oops, the force has encountered an error:\n%s\nPlease try again :(";
errorMsg = String.format(errorMsg, "recur command encountered an error:\n%s");
expected = String.format(errorMsg, "todo command requires the description argument.");
testCommand(commandString, expected, new TaskList());
}
Example from src/test/java/luke/parser/ParserTest.java lines 250-294:
public void recurCommandAdd_validInput_correctCommandResult() {
LocalDateTime currentDateTimePlusOne = LocalDateTime.now().plusDays(1);
String dateTimeCommandString = DateTimeParser.toCommandString(currentDateTimePlusOne);
String dateTimeString = DateTimeParser.toString(currentDateTimePlusOne);
String commandString = String.format("recur event sleep /at %s /every day", dateTimeCommandString);
String successMessage = "I have added the following task into list: \n\t%s\nnow you have %d tasks in the list.";
String expectedCommandResult = String.format("[R][E][ ] sleep\n\t(at: %s) (every: day)", dateTimeString);
String expected = String.format(successMessage, expectedCommandResult, 1);
testCommand(commandString, expected, new TaskList());
LocalDateTime currentDateTimeMinusOne = LocalDateTime.now().minusDays(1);
LocalDateTime expectedDateTime = currentDateTimeMinusOne.plusWeeks(1);
dateTimeCommandString = DateTimeParser.toCommandString(currentDateTimeMinusOne);
dateTimeString = DateTimeParser.toString(expectedDateTime);
commandString = String.format("recur event sleep /at %s /every week", dateTimeCommandString);
successMessage = "I have added the following task into list: \n\t%s\nnow you have %d tasks in the list.";
expectedCommandResult = String.format("[R][E][ ] sleep\n\t(at: %s) (every: week)", dateTimeString);
expected = String.format(successMessage, expectedCommandResult, 1);
testCommand(commandString, expected, new TaskList());
expectedDateTime = currentDateTimeMinusOne.plusMonths(1);
dateTimeCommandString = DateTimeParser.toCommandString(currentDateTimeMinusOne);
dateTimeString = DateTimeParser.toString(expectedDateTime);
commandString = String.format("recur event sleep /at %s /every month", dateTimeCommandString);
successMessage = "I have added the following task into list: \n\t%s\nnow you have %d tasks in the list.";
expectedCommandResult = String.format("[R][E][ ] sleep\n\t(at: %s) (every: month)", dateTimeString);
expected = String.format(successMessage, expectedCommandResult, 1);
testCommand(commandString, expected, new TaskList());
commandString = String.format("recur todo teach /every month", dateTimeCommandString);
successMessage = "I have added the following task into list: \n\t%s\nnow you have %d tasks in the list.";
expectedCommandResult = String.format("[R][T][ ] teach (every: month)", dateTimeString);
expected = String.format(successMessage, expectedCommandResult, 1);
testCommand(commandString, expected, new TaskList());
expectedDateTime = currentDateTimeMinusOne.plusYears(1);
dateTimeCommandString = DateTimeParser.toCommandString(currentDateTimeMinusOne);
dateTimeString = DateTimeParser.toString(expectedDateTime);
commandString = String.format("recur deadline sleep /by %s /every year", dateTimeCommandString);
successMessage = "I have added the following task into list: \n\t%s\nnow you have %d tasks in the list.";
expectedCommandResult = String.format("[R][D][ ] sleep\n\t(by: %s) (every: year)", dateTimeString);
expected = String.format(successMessage, expectedCommandResult, 1);
testCommand(commandString, expected, new TaskList());
}
Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten 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 (Subject Only)
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.
@lkldev 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
No easy-to-detect issues 👍
Aspect: Method Length
Example from
src/main/java/luke/parser/Parser.javalines48-91:Example from
src/test/java/luke/parser/ParserTest.javalines208-247:Example from
src/test/java/luke/parser/ParserTest.javalines250-294:Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten 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 (Subject Only)
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.