crypto-code / ip Goto Github PK
View Code? Open in Web Editor NEWThis project forked from nus-cs2103-ay2122s1/ip
This project forked from nus-cs2103-ay2122s1/ip
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 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 ๐
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/whobot/main/gui/DisplayBuffer.java
lines 76-135
:
public static void printBuffer() {
long delay = charCount > Gui.getShortTextLimit()
? Gui.getLongTextDelay()
: Gui.getShortTextDelay();
Thread printThread = new Thread(() -> {
if (userInput != null && sendButton != null) {
userInput.setDisable(true);
sendButton.setDisable(true);
int i = 0;
if (!buffer.isEmpty()) {
int finalI = i;
Platform.runLater(() -> {
final Node node = BotDialogBox.getDialog(buffer.get(finalI), false, delay);
FadeTransition transition = new FadeTransition(Duration.millis(300), node);
transition.setFromValue(0);
transition.setToValue(1);
parent.getChildren().add(node);
transition.play();
});
try {
Thread.sleep(delay * buffer.get(i).length());
} catch (InterruptedException e) {
e.printStackTrace();
}
i++;
}
if (buffer.size() > 1) {
for (; i < buffer.size(); i++) {
int finalI1 = i;
Platform.runLater((() -> {
final Node node = BotDialogBox.getDialog(buffer.get(finalI1), true, delay);
FadeTransition transition = new FadeTransition(Duration.millis(300), node);
transition.setFromValue(0);
transition.setToValue(1);
parent.getChildren().add(node);
transition.play();
if (finalI1 == buffer.size() - 1) {
buffer.removeIf(c -> true);
}
}));
try {
Thread.sleep(delay * buffer.get(i).length());
} catch (InterruptedException e) {
e.printStackTrace();
}
if (buffer.size() == 0) {
userInput.setDisable(false);
sendButton.setDisable(false);
}
}
} else {
buffer.removeIf(c -> true);
userInput.setDisable(false);
sendButton.setDisable(false);
}
}
});
printThread.start();
}
Example from src/main/java/whobot/utils/Parser.java
lines 27-106
:
public int parse(String command, UI ui, Storage storage, TaskList taskList) throws WhoBotException {
assert ui != null;
assert storage != null;
assert taskList != null;
Helper helper = new Helper(ui);
if (command.isBlank()) {
throw new WhoBotException("The input is blank. Please enter something.");
}
String[] commandList = command.toLowerCase(Locale.ROOT).split(" ");
//All commands are taken as case-insensitive
if (command.toLowerCase(Locale.ROOT).equals("bye") || command.toLowerCase(Locale.ROOT).equals("goodbye")) {
// If input is bye or goodbye, quits program
if (!WhoBot.isGui()) {
ui.goodbye();
}
storage.saveMemory(taskList.getList());
return -1;
} else if (command.toLowerCase(Locale.ROOT).equals("list")) {
// If input is list, prints list
taskList.printList(ui);
} else if (commandList[0].equals("help")) {
// If input is list, prints list
if (commandList.length == 1) {
helper.showMainHelp();
} else {
helper.showCommandHelp(commandList[1]);
}
} else if (commandList.length == 2 && commandList[0].equals("done")) {
//If input starts with done, mark the specific item in list as done
taskList.markAsDone(commandList[1], ui);
storage.saveMemory(taskList.getList());
} else if (commandList.length == 2 && commandList[0].equals("undo")) {
//If input starts with undo, mark the specific item in list as not done
taskList.markAsUndone(commandList[1], ui);
storage.saveMemory(taskList.getList());
} else if (commandList.length == 2 && commandList[0].equals("delete")) {
//If input starts with delete, delete the specific item in list
taskList.deleteFromList(commandList[1], ui);
storage.saveMemory(taskList.getList());
} else if (commandList[0].equals("todo")) {
//If input starts with todos, add that to list
taskList.addTodo(command, ui);
storage.saveMemory(taskList.getList());
} else if (commandList[0].equals("event")) {
//If input starts with event, add that to list
taskList.addEvent(command, ui);
storage.saveMemory(taskList.getList());
} else if (commandList[0].equals("deadline")) {
//If input starts with deadline, add that to list
taskList.addDeadline(command, ui);
storage.saveMemory(taskList.getList());
} else if (commandList[0].equals("show")) {
//If input starts with show, show tasks on specified date
taskList.showOnDate(command, ui);
} else if (commandList[0].equals("find")) {
//If input starts with todos, add that to list
taskList.findTask(command, ui);
} else if (commandList[0].equals("tag")) {
//If input starts with todos, add that to list
taskList.tagTask(command, ui);
storage.saveMemory(taskList.getList());
} else if (commandList[0].equals("untag")) {
//If input starts with todos, add that to list
taskList.untagTask(command, ui);
storage.saveMemory(taskList.getList());
} else if (commandList[0].equals("list")) {
//If input starts with todos, add that to list
taskList.listTagTask(command, ui);
storage.saveMemory(taskList.getList());
} else {
// Else Invalid
throw new WhoBotException("Oops, That's an invalid command."
+ " Type in help to get list of possible commands.");
}
return 0;
}
Example from src/main/java/whobot/utils/Storage.java
lines 60-116
:
public void readData(ArrayList<Task> list, HashMap<String, ArrayList<Task>> taggedList) throws WhoBotException {
try {
Scanner taskReader = new Scanner(taskFile);
while (taskReader.hasNextLine()) {
String[] data = taskReader.nextLine().split(" \\| ");
if (data[0].equals("T")) {
Todo tempTodo = new Todo(data[2]);
if (data[1].equals("X")) {
tempTodo.markAsDone();
}
if (data.length == 4) {
if (!taggedList.containsKey(data[3])) {
taggedList.put(data[3], new ArrayList<>());
}
taggedList.get(data[3]).add(tempTodo);
tempTodo.setTag(data[3]);
} else {
taggedList.get(NO_TAG).add(tempTodo);
}
list.add(tempTodo);
} else if (data[0].equals("D")) {
Deadline tempDeadline = new Deadline(data[2]);
if (data[1].equals("X")) {
tempDeadline.markAsDone();
}
if (data.length == 4) {
if (!taggedList.containsKey(data[3])) {
taggedList.put(data[3], new ArrayList<>());
}
taggedList.get(data[3]).add(tempDeadline);
tempDeadline.setTag(data[3]);
} else {
taggedList.get(NO_TAG).add(tempDeadline);
}
list.add(tempDeadline);
} else if (data[0].equals("E")) {
Event tempEvent = new Event(data[2]);
if (data[1].equals("X")) {
tempEvent.markAsDone();
}
if (data.length == 4) {
if (!taggedList.containsKey(data[3])) {
taggedList.put(data[3], new ArrayList<>());
}
taggedList.get(data[3]).add(tempEvent);
tempEvent.setTag(data[3]);
} else {
taggedList.get(NO_TAG).add(tempEvent);
}
list.add(tempEvent);
}
}
} catch (FileNotFoundException e) {
throw new WhoBotException("Oops, The file to store my data could not be created."
+ " If you continue, tasks won't be stored permanently.");
}
}
Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods. You may ignore this suggestion if you think a longer method is justified in a particular case.
Example from src/main/java/whobot/main/WhoBot.java
lines 83-87
:
/***
* Main Method
*
* @param args Commandline arguments
*/
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 ๐
โน๏ธ The bot account @cs2103-bot 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.
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/whobot/main/gui/DisplayBuffer.java
lines 78-137
:
public static void printBuffer() {
long delay = charCount > Gui.getShortTextLimit()
? Gui.getLongTextDelay()
: Gui.getShortTextDelay();
Thread printThread = new Thread(() -> {
if (userInput != null && sendButton != null) {
userInput.setDisable(true);
sendButton.setDisable(true);
int i = 0;
if (!buffer.isEmpty()) {
int finalI = i;
Platform.runLater(() -> {
final Node node = BotDialogBox.getDialog(buffer.get(finalI), false, delay);
FadeTransition transition = new FadeTransition(Duration.millis(300), node);
transition.setFromValue(0);
transition.setToValue(1);
parent.getChildren().add(node);
transition.play();
});
try {
Thread.sleep(delay * buffer.get(i).length());
} catch (InterruptedException e) {
e.printStackTrace();
}
i++;
}
if (buffer.size() > 1) {
for (; i < buffer.size(); i++) {
int finalI1 = i;
Platform.runLater((() -> {
final Node node = BotDialogBox.getDialog(buffer.get(finalI1), true, delay);
FadeTransition transition = new FadeTransition(Duration.millis(300), node);
transition.setFromValue(0);
transition.setToValue(1);
parent.getChildren().add(node);
transition.play();
if (finalI1 == buffer.size() - 1) {
buffer.removeIf(c -> true);
}
}));
try {
Thread.sleep(delay * buffer.get(i).length());
} catch (InterruptedException e) {
e.printStackTrace();
}
if (buffer.size() == 0) {
userInput.setDisable(false);
sendButton.setDisable(false);
}
}
} else {
buffer.removeIf(c -> true);
userInput.setDisable(false);
sendButton.setDisable(false);
}
}
});
printThread.start();
}
Example from src/main/java/whobot/utils/Parser.java
lines 27-106
:
public int parse(String command, UI ui, Storage storage, TaskList taskList) throws WhoBotException {
assert ui != null;
assert storage != null;
assert taskList != null;
Helper helper = new Helper(ui);
if (command.isBlank()) {
throw new WhoBotException("The input is blank. Please enter something.");
}
String[] commandList = command.toLowerCase(Locale.ROOT).split(" ");
//All commands are taken as case-insensitive
if (command.toLowerCase(Locale.ROOT).equals("bye") || command.toLowerCase(Locale.ROOT).equals("goodbye")) {
// If input is bye or goodbye, quits program
if (!WhoBot.isGui()) {
ui.goodbye();
}
storage.saveMemory(taskList.getList());
return -1;
} else if (command.toLowerCase(Locale.ROOT).equals("list")) {
// If input is list, prints list
taskList.printList(ui);
} else if (commandList[0].equals("help")) {
// If input is list, prints list
if (commandList.length == 1) {
helper.showMainHelp();
} else {
helper.showCommandHelp(commandList[1]);
}
} else if (commandList.length == 2 && commandList[0].equals("done")) {
//If input starts with done, mark the specific item in list as done
taskList.markAsDone(commandList[1], ui);
storage.saveMemory(taskList.getList());
} else if (commandList.length == 2 && commandList[0].equals("undo")) {
//If input starts with undo, mark the specific item in list as not done
taskList.markAsUndone(commandList[1], ui);
storage.saveMemory(taskList.getList());
} else if (commandList.length == 2 && commandList[0].equals("delete")) {
//If input starts with delete, delete the specific item in list
taskList.deleteFromList(commandList[1], ui);
storage.saveMemory(taskList.getList());
} else if (commandList[0].equals("todo")) {
//If input starts with todos, add that to list
taskList.addTodo(command, ui);
storage.saveMemory(taskList.getList());
} else if (commandList[0].equals("event")) {
//If input starts with event, add that to list
taskList.addEvent(command, ui);
storage.saveMemory(taskList.getList());
} else if (commandList[0].equals("deadline")) {
//If input starts with deadline, add that to list
taskList.addDeadline(command, ui);
storage.saveMemory(taskList.getList());
} else if (commandList[0].equals("show")) {
//If input starts with show, show tasks on specified date
taskList.showOnDate(command, ui);
} else if (commandList[0].equals("find")) {
//If input starts with todos, add that to list
taskList.findTask(command, ui);
} else if (commandList[0].equals("tag")) {
//If input starts with todos, add that to list
taskList.tagTask(command, ui);
storage.saveMemory(taskList.getList());
} else if (commandList[0].equals("untag")) {
//If input starts with todos, add that to list
taskList.untagTask(command, ui);
storage.saveMemory(taskList.getList());
} else if (commandList[0].equals("list")) {
//If input starts with todos, add that to list
taskList.listTagTask(command, ui);
storage.saveMemory(taskList.getList());
} else {
// Else Invalid
throw new WhoBotException("Oops, That's an invalid command."
+ " Type in help to get list of possible commands.");
}
return 0;
}
Example from src/main/java/whobot/utils/Storage.java
lines 60-116
:
public void readData(ArrayList<Task> list, HashMap<String, ArrayList<Task>> taggedList) throws WhoBotException {
try {
Scanner taskReader = new Scanner(taskFile);
while (taskReader.hasNextLine()) {
String[] data = taskReader.nextLine().split(" \\| ");
if (data[0].equals("T")) {
Todo tempTodo = new Todo(data[2]);
if (data[1].equals("X")) {
tempTodo.markAsDone();
}
if (data.length == 4) {
if (!taggedList.containsKey(data[3])) {
taggedList.put(data[3], new ArrayList<>());
}
taggedList.get(data[3]).add(tempTodo);
tempTodo.setTag(data[3]);
} else {
taggedList.get(NO_TAG).add(tempTodo);
}
list.add(tempTodo);
} else if (data[0].equals("D")) {
Deadline tempDeadline = new Deadline(data[2]);
if (data[1].equals("X")) {
tempDeadline.markAsDone();
}
if (data.length == 4) {
if (!taggedList.containsKey(data[3])) {
taggedList.put(data[3], new ArrayList<>());
}
taggedList.get(data[3]).add(tempDeadline);
tempDeadline.setTag(data[3]);
} else {
taggedList.get(NO_TAG).add(tempDeadline);
}
list.add(tempDeadline);
} else if (data[0].equals("E")) {
Event tempEvent = new Event(data[2]);
if (data[1].equals("X")) {
tempEvent.markAsDone();
}
if (data.length == 4) {
if (!taggedList.containsKey(data[3])) {
taggedList.put(data[3], new ArrayList<>());
}
taggedList.get(data[3]).add(tempEvent);
tempEvent.setTag(data[3]);
} else {
taggedList.get(NO_TAG).add(tempEvent);
}
list.add(tempEvent);
}
}
} catch (FileNotFoundException e) {
throw new WhoBotException("Oops, The file to store my data could not be created."
+ " If you continue, tasks won't be stored permanently.");
}
}
Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten 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/whobot/main/WhoBot.java
lines 83-87
:
/***
* Main Method
*
* @param args Commandline arguments
*/
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 ๐
โ 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 @nus-se-bot 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.