@Polygonalr 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/duke/Parser.java
lines 30-113
:
public static Command parse(String input) throws DukeException {
String[] inputSplit = input.split(" ");
switch (inputSplit[0]) {
case "bye":
return new ByeCommand();
case "list":
return new ListCommand();
case "mark":
case "unmark":
// Error handling
if (inputSplit.length < 2) {
throw new DukeException(
"You did not specify what task number to mark as done. Unable to mark task.");
} else if (!isNumeric(inputSplit[1])) {
throw new DukeException(
String.format("Invalid task number provided: %s. Unable to mark task.",
inputSplit[1]));
}
// Return the command
return new MarkCommand(Integer.parseInt(inputSplit[1]) - 1,
inputSplit[0].equals("mark") ? true : false);
case "note":
// Error handling
if (inputSplit.length < 2) {
throw new DukeException("Please provide a description for your new note.");
}
// Return the command
return new NoteCommand(input.substring(5));
case "todo":
// Error handling
if (inputSplit.length < 2) {
throw new DukeException("Please provide a description for your todo.");
}
// Return the command
return new TodoCommand(input.substring(5));
case "deadline":
case "event":
String[] inputSlashSplit = input.split("/");
// Error handling
if (inputSlashSplit.length < 2 || inputSlashSplit[1].split(" ").length < 2) {
throw new DukeException(String.format(
"Please specify a time for your %s.", inputSplit[0]));
}
if (inputSlashSplit[0].split(" ").length < 2) {
throw new DukeException(String.format(
"Please provide a description for your %s.", inputSplit[0]));
}
// Return the commands
String date = input.split("/")[1];
String[] description = inputSlashSplit[0].split(" ");
if (inputSplit[0].equals("deadline")) {
return new DeadlineCommand(String.join(
" ", Arrays.copyOfRange(description, 1, description.length)), date);
} else {
return new EventCommand(String.join(
" ", Arrays.copyOfRange(description, 1, description.length)), date);
}
case "delete":
ListObject type = ListObject.TASK;
// Error handling
if (inputSplit.length < 2) {
throw new DukeException("You did not specify what number to delete.");
}
if (inputSplit[1].startsWith("N")) {
type = ListObject.NOTE;
inputSplit[1] = inputSplit[1].substring(1);
}
if (!isNumeric(inputSplit[1])) {
throw new DukeException(String.format(
"Invalid %s number provided: %s. Unable to delete %s.", type.label, inputSplit[1], type.label));
}
// Return the command
return new DeleteCommand(type, Integer.parseInt(inputSplit[1]) - 1);
case "find":
// Error handling
if (inputSplit.length < 2) {
throw new DukeException("Please provide a search term.");
}
// Return the command
return new FindCommand(input.substring(5));
default:
throw new DukeException("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.
Aspect: Class size
No easy-to-detect issues ๐
Aspect: Header Comments
Example from src/main/java/duke/Duke.java
lines 22-26
:
/**
* Create a new Duke application.
*
* @param filePath path to the save file
*/
Example from src/main/java/duke/Duke.java
lines 39-41
:
/**
* Create a new Duke application with the default save file path.
*/
Example from src/main/java/duke/Duke.java
lines 46-48
:
/**
* Run the Duke application in CLI mode.
*/
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)
No easy-to-detect issues ๐
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 [email protected]
if you want to follow up on this post.