@WuJinhan1 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
Example from src/main/java/Jard/Deadline.java lines 1-1:
Example from src/main/java/Jard/DialogBox.java lines 1-1:
Example from src/main/java/Jard/Event.java lines 1-1:
Suggestion: Follow the package naming convention specified by the coding standard.
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/Jard/Jard.java lines 50-96:
public String getResponse(String input) {
String[] inputParts = Parser.parseCommand(input);
String command = inputParts[0];
String response;
try {
switch (command) {
case "bye":
response = ui.showBye();
break;
case "list":
response = ui.showTaskList(tasks);
break;
case "mark":
int markIndex = Parser.parseTaskIndex(inputParts[1], tasks.size());
Task markTask = tasks.get(markIndex);
markTask.markAsDone();
response = ui.showMarkTask(markTask);
break;
case "unmark":
int unmarkIndex = Parser.parseTaskIndex(inputParts[1], tasks.size());
Task unmarkTask = tasks.get(unmarkIndex);
unmarkTask.markAsNotDone();
response = ui.showUnmarkTask(unmarkTask);
break;
case "delete":
int deleteIndex = Parser.parseTaskIndex(inputParts[1], tasks.size());
Task deleteTask = tasks.remove(deleteIndex);
response = ui.showDeleteTask(deleteTask, tasks.size());
break;
case "find":
String keyword = inputParts[1];
List<Task> matchingTasks = findTasks(keyword);
response = ui.showFindResults(matchingTasks);
break;
default:
Task newTask = Parser.parseTask(input);
tasks.add(newTask);
response = ui.showAddTask(newTask, tasks.size());
break;
}
storage.saveTasks(tasks);
} catch (JardException e) {
response = ui.showError(e.getMessage());
}
return response;
}
Example from src/main/java/Jard/Parser.java lines 29-77:
public static Task parseTask(String input) throws JardException {
String[] inputParts = input.split(" ", 2);
String command = inputParts[0];
if (command.equals("todo")) {
if (inputParts.length > 1) {
return new Todo(inputParts[1]);
} else {
throw new JardException("The description of a todo cannot be empty.");
}
} else if (command.equals("deadline")) {
if (inputParts.length > 1) {
String[] details = inputParts[1].split("/by", 2);
if (details.length < 2) {
throw new JardException("Invalid format! Deadline should be /by.");
}
try {
LocalDateTime byDateTime = parseDateTime(details[1].trim());
return new Deadline(details[0].trim(), byDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HHmm")));
} catch (Exception e) {
throw new JardException("Invalid date and time format for deadline! Use 'yyyy-MM-dd HHmm'.");
}
} else {
throw new JardException("The description of a deadline cannot be empty.");
}
} else if (command.equals("event")) {
if (inputParts.length > 1) {
String[] details = inputParts[1].split("/from|/to");
if (details.length != 3) {
throw new JardException("Invalid format! Events should be /from and /to.");
}
try {
LocalDateTime fromDateTime = parseDateTime(details[1].trim());
LocalDateTime toDateTime = parseDateTime(details[2].trim());
return new Event(
details[0].trim(),
fromDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HHmm")),
toDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HHmm"))
);
} catch (Exception e) {
throw new JardException("Invalid date and time format for event! Use 'yyyy-MM-dd HHmm'.");
}
} else {
throw new JardException("The description of an event cannot be empty.");
}
} else {
throw new JardException("Invalid command!");
}
}
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/Jard/Jard.java lines 102-106:
/**
* The main method serves as the entry point for the application.
*
* @param args Command-line arguments (not used).
*/
Example from src/main/java/Jard/Ui.java lines 11-13:
/**
* Construct a Ui instance.
*/
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 4f244e7:
Add assert statements to document key assumptions in the code
Using Java's assert feature to document important assumptions that should hold at various points in the code helps improve code reliability.
Added assert statements like in the getJardResponse method to document the assumption that both the text and img parameters should not be null.
- body not wrapped at 72 characters: e.g.,
Using Java's assert feature to document important assumptions that should hold at various points in the code helps improve code reliability.
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.
@WuJinhan1 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
Example from
src/main/java/Jard/Deadline.javalines1-1:Example from
src/main/java/Jard/DialogBox.javalines1-1:Example from
src/main/java/Jard/Event.javalines1-1:Suggestion: Follow the package naming convention specified by the coding standard.
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/Jard/Jard.javalines50-96:Example from
src/main/java/Jard/Parser.javalines29-77: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/Jard/Jard.javalines102-106:Example from
src/main/java/Jard/Ui.javalines11-13: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
4f244e7:Using Java's assert feature to document important assumptions that should hold at various points in the code helps improve code reliability.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.