@AaronToh 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/ming/parser/Parser.java lines 41-108:
public static Command parse(String input) throws MingException {
Scanner scanner = new Scanner(input);
String command = scanner.hasNext() ? scanner.next() : "";
String remainder = scanner.hasNextLine() ? scanner.nextLine() : "";
List<String> tags = new ArrayList<>();
int i;
switch (command) {
case "bye":
return new ExitCommand();
case "list":
return new ListCommand();
case "mark":
i = parseIndex(remainder);
return new MarkCommand(i);
case "unmark":
i = parseIndex(remainder);
return new UnmarkCommand(i);
case "delete":
i = parseIndex(remainder);
return new DeleteCommand(i);
case "find":
tags = parseTags(remainder, TAGS_FLAG);
if (!tags.isEmpty()) {
return new FindCommand(tags.get(0), "tag");
} else {
remainder = stripTags(remainder);
checkTaskEmpty(remainder);
return new FindCommand(remainder, "name");
}
case "todo":
tags = parseTags(remainder, TAGS_FLAG);
remainder = stripTags(remainder);
checkTaskEmpty(remainder);
return new TodoCommand(remainder, tags);
case "deadline":
tags = parseTags(remainder, TAGS_FLAG);
remainder = stripTags(remainder);
checkTaskEmpty(remainder);
String[] deadlineParts = parseDeadline(remainder);
return new DeadlineCommand(deadlineParts[0], parseDateTime(deadlineParts[1]), tags);
case "event":
tags = parseTags(remainder, TAGS_FLAG);
remainder = stripTags(remainder);
checkTaskEmpty(remainder);
String[] eventParts = parseEvent(remainder);
return new EventCommand(eventParts[0],
parseDateTime(eventParts[1]),
parseDateTime(eventParts[2]),
tags);
default:
throw new MingException("Unknown command: " + command);
}
}
Example from src/main/java/ming/storage/Storage.java lines 40-98:
public List<Task> load() throws MingException {
List<Task> tasks = new ArrayList<>();
try {
Path directory = path.getParent();
if (!Files.exists(directory)) {
Files.createDirectories(directory);
}
if (!Files.exists(path)) {
Files.createFile(path);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
Scanner dataScanner;
try {
dataScanner = new Scanner(path.toFile());
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
while (dataScanner.hasNextLine()) {
String[] parts = dataScanner.nextLine().split(" \\| ");
boolean isDone = parts[1].equals("1");
switch (parts[0]) {
case "T":
Task todo = new Todo(parts[2], new ArrayList<>());
if (isDone) {
todo.markAsDone();
}
tasks.add(todo);
break;
case "D":
Task deadline = new Deadline(parts[2],
LocalDateTime.parse(parts[3], FORMATTER),
new ArrayList<>());
if (isDone) {
deadline.markAsDone();
}
tasks.add(deadline);
break;
case "E":
Task event = new Event(parts[2],
LocalDateTime.parse(parts[3], FORMATTER),
LocalDateTime.parse(parts[4], FORMATTER),
new ArrayList<>());
if (isDone) {
event.markAsDone();
}
tasks.add(event);
break;
default:
System.out.println("Unknown task type: " + parts[0]);
}
}
return tasks;
}
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
No easy-to-detect issues 👍
Aspect: Recent Git Commit Messages
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.
@AaronToh 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/ming/parser/Parser.javalines41-108:Example from
src/main/java/ming/storage/Storage.javalines40-98: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
No easy-to-detect issues 👍
Aspect: Recent Git Commit Messages
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.