vvidday / ip Goto Github PK
View Code? Open in Web Editor NEWThis project forked from nus-cs2103-ay2223s1/ip
This project forked from nus-cs2103-ay2223s1/ip
@vvidday 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.
No easy-to-detect issues ๐
Example from src/main/java/ekud/util/ParseResult.java
lines 4-4
:
public final boolean terminate;
Example from src/main/java/ekud/util/ParseResult.java
lines 6-6
:
public final boolean saveStorage;
Suggestion: Follow the given naming convention for boolean variables/methods (e.g., use a boolean-sounding prefix).You may ignore the above if you think the name already follows the convention (the script can report false positives in some cases)
Example from src/main/java/ekud/util/Parser.java
lines 59-60
:
}
else {
Suggestion: As specified by the coding standard, use egyptian style braces.
No easy-to-detect issues ๐
No easy-to-detect issues ๐
No easy-to-detect issues ๐
Example from src/main/java/ekud/task/TaskList.java
lines 151-198
:
private Task parseSpecialTask(String description, TaskType type) throws EkudException {
Optional<Task> task = Optional.empty();
String[] parts = description.split(" ");
switch (type) {
case TODO:
if (parts.length < 2) {
throw new EkudException("Description of a TODO cannot be empty.");
}
task = Optional.of(new ToDo(String.join(" ", Arrays.copyOfRange(parts, 1, parts.length))));
break;
case DEADLINE:
// Fallthrough
case EVENT:
int idxOfSeparator = 0;
for (int i = 0; i < parts.length; i++) {
if (type == TaskType.EVENT && parts[i].equals("/at")) {
idxOfSeparator = i;
} else if (type == TaskType.DEADLINE && parts[i].equals("/by")) {
idxOfSeparator = i;
}
}
if (idxOfSeparator == 0) {
String separator = type == TaskType.EVENT ? "/at" : "/by";
throw new EkudException(
String.format("Invalid syntax. Use %s <task> %s <date/time>", type.toString(), separator));
} else if (idxOfSeparator == 1) {
throw new EkudException(String.format("Description of an %s cannot be empty.", type.toString()));
} else if (idxOfSeparator == parts.length - 1) {
throw new EkudException("Date/Time cannot be empty.");
}
String taskDesc = String.join(" ", Arrays.copyOfRange(parts, 1, idxOfSeparator));
String taskDueDate = String.join(" ", Arrays.copyOfRange(parts, idxOfSeparator + 1, parts.length));
if (type == TaskType.EVENT) {
task = Optional.of(new Event(taskDesc, taskDueDate));
} else {
task = Optional.of(new Deadline(taskDesc, taskDueDate));
}
break;
default:
throw new EkudException("Invalid task type.");
}
if (task.isEmpty()) {
throw new EkudException("Unexpected error.");
} else {
return task.get();
}
}
Example from src/main/java/ekud/util/Parser.java
lines 29-63
:
public ParseResult parseCommand(String command, TaskList taskList, NoteList noteList) throws EkudException {
String[] splitCommand = command.split(" ");
String firstWord = splitCommand[0];
if (command.equals("bye")) {
return new ParseResult(true, "Bye. Hope to see you again soon!", false);
} else if (command.equals("list")) {
return new ParseResult(false, taskList.printTasks(), false);
} else if (firstWord.equals("mark")) {
return new ParseResult(false, taskList.markAsDone(command), true);
} else if (firstWord.equals("unmark")) {
return new ParseResult(false, taskList.markAsUndone(command), true);
} else if (firstWord.equals("todo")) {
return new ParseResult(false, taskList.addTask(command, TaskType.TODO), true);
} else if (firstWord.equals("deadline")) {
return new ParseResult(false, taskList.addTask(command, TaskType.DEADLINE), true);
} else if (firstWord.equals("event")) {
return new ParseResult(false, taskList.addTask(command, TaskType.EVENT), true);
} else if (firstWord.equals("delete")) {
return new ParseResult(false, taskList.deleteTask(command), true);
} else if (firstWord.equals("find")) {
return new ParseResult(false, taskList.searchTasks(
String.join(" ", Arrays.copyOfRange(splitCommand, 1, splitCommand.length))), false);
} else if (firstWord.equals("note")) {
return new ParseResult(false,
noteList.addNote(String.join(" ", Arrays.copyOfRange(splitCommand, 1, splitCommand.length))),
true);
} else if (firstWord.equals("deletenote")) {
return new ParseResult(false, noteList.deleteNote(command), true);
} else if (firstWord.equals("listnote")) {
return new ParseResult(false, noteList.printNotes(), false);
}
else {
throw new EkudException("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.
No easy-to-detect issues ๐
Example from src/main/java/ekud/task/Task.java
lines 50-55
:
/**
* Get status icon of task.
*
* @return Character representing the status of the task (whether it is done or
* not)
*/
Suggestion: Ensure method/class header comments follow the format specified in the coding standard, in particular, the phrasing of the overview statement.
No easy-to-detect issues ๐
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 [email protected]
if you want to follow up on this post.
@vvidday 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.
No easy-to-detect issues ๐
Example from src/main/java/ekud/util/ParseResult.java
lines 4-4
:
public final boolean terminate;
Example from src/main/java/ekud/util/ParseResult.java
lines 6-6
:
public final boolean saveStorage;
Suggestion: Follow the given naming convention for boolean variables/methods (e.g., use a boolean-sounding prefix).You may ignore the above if you think the name already follows the convention (the script can report false positives in some cases)
Example from src/main/java/ekud/util/Parser.java
lines 59-60
:
}
else {
Suggestion: As specified by the coding standard, use egyptian style braces.
No easy-to-detect issues ๐
No easy-to-detect issues ๐
No easy-to-detect issues ๐
Example from src/main/java/ekud/task/TaskList.java
lines 151-198
:
private Task parseSpecialTask(String description, TaskType type) throws EkudException {
Optional<Task> task = Optional.empty();
String[] parts = description.split(" ");
switch (type) {
case TODO:
if (parts.length < 2) {
throw new EkudException("Description of a TODO cannot be empty.");
}
task = Optional.of(new ToDo(String.join(" ", Arrays.copyOfRange(parts, 1, parts.length))));
break;
case DEADLINE:
// Fallthrough
case EVENT:
int idxOfSeparator = 0;
for (int i = 0; i < parts.length; i++) {
if (type == TaskType.EVENT && parts[i].equals("/at")) {
idxOfSeparator = i;
} else if (type == TaskType.DEADLINE && parts[i].equals("/by")) {
idxOfSeparator = i;
}
}
if (idxOfSeparator == 0) {
String separator = type == TaskType.EVENT ? "/at" : "/by";
throw new EkudException(
String.format("Invalid syntax. Use %s <task> %s <date/time>", type.toString(), separator));
} else if (idxOfSeparator == 1) {
throw new EkudException(String.format("Description of an %s cannot be empty.", type.toString()));
} else if (idxOfSeparator == parts.length - 1) {
throw new EkudException("Date/Time cannot be empty.");
}
String taskDesc = String.join(" ", Arrays.copyOfRange(parts, 1, idxOfSeparator));
String taskDueDate = String.join(" ", Arrays.copyOfRange(parts, idxOfSeparator + 1, parts.length));
if (type == TaskType.EVENT) {
task = Optional.of(new Event(taskDesc, taskDueDate));
} else {
task = Optional.of(new Deadline(taskDesc, taskDueDate));
}
break;
default:
throw new EkudException("Invalid task type.");
}
if (task.isEmpty()) {
throw new EkudException("Unexpected error.");
} else {
return task.get();
}
}
Example from src/main/java/ekud/util/Parser.java
lines 29-63
:
public ParseResult parseCommand(String command, TaskList taskList, NoteList noteList) throws EkudException {
String[] splitCommand = command.split(" ");
String firstWord = splitCommand[0];
if (command.equals("bye")) {
return new ParseResult(true, "Bye. Hope to see you again soon!", false);
} else if (command.equals("list")) {
return new ParseResult(false, taskList.printTasks(), false);
} else if (firstWord.equals("mark")) {
return new ParseResult(false, taskList.markAsDone(command), true);
} else if (firstWord.equals("unmark")) {
return new ParseResult(false, taskList.markAsUndone(command), true);
} else if (firstWord.equals("todo")) {
return new ParseResult(false, taskList.addTask(command, TaskType.TODO), true);
} else if (firstWord.equals("deadline")) {
return new ParseResult(false, taskList.addTask(command, TaskType.DEADLINE), true);
} else if (firstWord.equals("event")) {
return new ParseResult(false, taskList.addTask(command, TaskType.EVENT), true);
} else if (firstWord.equals("delete")) {
return new ParseResult(false, taskList.deleteTask(command), true);
} else if (firstWord.equals("find")) {
return new ParseResult(false, taskList.searchTasks(
String.join(" ", Arrays.copyOfRange(splitCommand, 1, splitCommand.length))), false);
} else if (firstWord.equals("note")) {
return new ParseResult(false,
noteList.addNote(String.join(" ", Arrays.copyOfRange(splitCommand, 1, splitCommand.length))),
true);
} else if (firstWord.equals("deletenote")) {
return new ParseResult(false, noteList.deleteNote(command), true);
} else if (firstWord.equals("listnote")) {
return new ParseResult(false, noteList.printNotes(), false);
}
else {
throw new EkudException("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.
No easy-to-detect issues ๐
Example from src/main/java/ekud/task/Task.java
lines 50-55
:
/**
* Get status icon of task.
*
* @return Character representing the status of the task (whether it is done or
* not)
*/
Suggestion: Ensure method/class header comments follow the format specified in the coding standard, in particular, the phrasing of the overview statement.
No easy-to-detect issues ๐
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.