ella-e / ip Goto Github PK
View Code? Open in Web Editor NEWThis project forked from nus-cs2103-ay2324s2/ip
CS2103T ip project
This project forked from nus-cs2103-ay2324s2/ip
CS2103T ip project
@Ella-e 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 ๐
No easy-to-detect issues ๐
No easy-to-detect issues ๐
No easy-to-detect issues ๐
No easy-to-detect issues ๐
No easy-to-detect issues ๐
Example from src/main/java/duke/Duke.java
lines 67-121
:
public String getResponse(String userInput) {
String response = "";
try {
// use parser to process the userInput
// the parser object contains all the current user input line information
Parser parser = new Parser();
parser.parse(userInput);
// check for end the session
if (parser.getCurrentKey().equals(KeyEnum.EXITKEY)) {
response = ui.onExit();
}
// continue for the functionality
switch (parser.getCurrentKey()) {
case DEADLINE:
case TODO:
case EVENT:
Task task = tasks.addTask(parser.getInputDetail(),
parser.getFrom(), parser.getTo(), parser.getCurrentKey());
storage.writeTasksToFile(tasks);
response = ui.onAddSuccess(task, tasks.getNumOfTasks());
break;
case LIST:
response = ui.showList(tasks);
break;
case MARK:
Task markedTask = tasks.markTaskById(parser.getIndex(), true);
storage.writeTasksToFile(tasks);
response = ui.onMarkDone(markedTask);
break;
case UNMARK:
Task unMarkedTask = tasks.markTaskById(parser.getIndex(), false);
storage.writeTasksToFile(tasks);
response = ui.onUnmarkDone(unMarkedTask);
break;
case DELETE:
Task deletedTask = tasks.deleteTaskById(parser.getIndex());
storage.writeTasksToFile(tasks);
response = ui.onDelete(deletedTask, tasks);
break;
case FIND:
TaskList matchedTasks = tasks.findTasks(parser.getInputDetail());
response = ui.showMatchedList(matchedTasks);
break;
default:
break;
}
} catch (BaseException e) {
response = ui.showErrorMsg(e.getMessage());
} catch (IOException e) {
response = ui.showLoadingError();
}
return response;
}
Example from src/main/java/duke/tasks/TaskList.java
lines 157-201
:
public TaskList findNextDueTasks(int numOfTasks) {
ArrayList<Task> nextTasks = new ArrayList<>(tasks);
nextTasks.removeIf(Task::getIsDone); // remove completed tasks
nextTasks.sort(new Comparator<Task>() {
@Override
public int compare(Task o1, Task o2) {
if (o1 instanceof Todo) {
return 1;
}
if (o2 instanceof Todo) {
return -1;
}
if (o1 instanceof Deadline) {
if (o2 instanceof Deadline) {
return ((Deadline) o1).getBy().compareTo(((Deadline) o2).getBy());
} else if (o2 instanceof Event) {
return ((Deadline) o1).getBy().compareTo(((Event) o2).getBy());
}
} else if (o1 instanceof Event) {
if (o2 instanceof Deadline) {
return ((Event) o1).getBy().compareTo(((Deadline) o2).getBy());
} else if (o2 instanceof Event) {
return ((Event) o1).getBy().compareTo(((Event) o2).getBy());
}
}
return 0;
}
});
if (nextTasks.size() <= numOfTasks) {
return new TaskList(nextTasks);
}
ArrayList<Task> tempTasks = new ArrayList<>();
int counter = numOfTasks;
for (Task task: nextTasks) {
if (counter <= 0) {
break;
}
tempTasks.add(task);
counter--;
}
return new TaskList(tempTasks);
}
Example from src/main/java/duke/utils/Parser.java
lines 32-95
:
public void parse(String userInput) throws InvalidKeyException, EmptyBodyException,
WrongFormatException, InvalidNumberException, DateTimeParseException, InvalidDateTimeException {
String[] userInputSplit = userInput.split(" ");
// verify that the user input is valid
String checkInputMsg = checkSpecialCharacter(userInputSplit);
if (!checkInputMsg.equals("valid")) {
throw new WrongFormatException(checkInputMsg);
}
this.determineCurrentKey(userInputSplit[0]);
switch (this.currentKey) {
case DEADLINE:
if (userInput.length() <= 9) {
throw new EmptyBodyException();
}
try {
inputDetail = userInput.substring(9, userInput.indexOf("/by"));
to = formatDate(userInput.substring(userInput.indexOf("/by") + 4));
} catch (Exception e) {
throw new WrongFormatException("\"deadline content /by yyyy-mm-dd\"");
}
break;
case TODO:
case FIND:
if (userInput.length() <= 5) {
throw new EmptyBodyException();
}
inputDetail = userInput.substring(5);
break;
case EVENT:
if (userInput.length() <= 6) {
throw new EmptyBodyException();
}
try {
inputDetail = userInput.substring(6, userInput.indexOf("/from"));
from = formatDate(userInput.substring(userInput.indexOf("/from") + 6, userInput.indexOf("/to") - 1));
to = formatDate(userInput.substring(userInput.indexOf("/to") + 4));
if (from.isAfter(to)) {
throw new InvalidDateTimeException("The start date should be before the end date");
}
} catch (InvalidDateTimeException e) {
throw e;
} catch (Exception e) {
throw new WrongFormatException("\"event content /from yyyy-mm-dd /to yyyy-mm-dd\"");
}
break;
case MARK:
case UNMARK:
case DELETE:
try {
this.index = new Integer(userInputSplit[1]) - 1;
this.inputDetail = this.index.toString();
} catch (Exception e) {
throw new InvalidNumberException();
}
break;
default:
break;
}
// check if the user input contains only empty spaces.
if (!(currentKey.equals(KeyEnum.LIST) || currentKey.equals(KeyEnum.EXITKEY)) && inputDetail.trim().isEmpty()) {
throw new EmptyBodyException();
}
}
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 ๐
No easy-to-detect issues ๐
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.
@Ella-e 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/duke/tasks/Task.java
lines 7-7
:
private Boolean status;
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)
No easy-to-detect issues ๐
No easy-to-detect issues ๐
No easy-to-detect issues ๐
No easy-to-detect issues ๐
No easy-to-detect issues ๐
No easy-to-detect issues ๐
Example from src/main/java/duke/Duke.java
lines 61-64
:
/**
* You should have your own function to generate a response to user input.
* Replace this stub with your completed method.
*/
Suggestion: Ensure method/class header comments follow the format specified in the coding standard, in particular, the phrasing of the overview statement.
possible problems in commit ea64415
:
Merge branch 'master' into branch-B-Reminders
Update with master
possible problems in commit d9eaeaf
:
Merge branch 'master' into branch-B-Reminders
Update with master
possible problems in commit 46f0322
:
Merge branch 'master' into branch-A-CI
Update with master
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).
Suggestion: Avoid committing binary files (e.g., *.class
, *.jar
, *.exe
) or third-party library files in to the repo.
โน๏ธ 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.