vishandi / ip Goto Github PK
View Code? Open in Web Editor NEWThis project forked from nus-cs2103-ay2122s2/ip
This project forked from nus-cs2103-ay2122s2/ip
@vishandi 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 ๐
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 95-179
:
public String processUserInput(String userInput) {
assert userInput != null;
String[] userInputs = userInput.split(" ");
String command = userInputs[0];
String response;
try {
switch (command) {
case "bye":
if (userInput.equals("bye")) {
response = Duke.BYE;
return response;
} else {
throw DukeException.DukeInvalidCommand();
}
case "list":
if (userInput.equals("list")) {
response = this.taskList.toString();
return response;
} else {
throw DukeException.DukeInvalidCommand();
}
case "mark":
try {
int index = Integer.parseInt(userInput.substring(MARK_LENGTH)) - 1;
response = this.taskList.markTaskAsDone(index);
writeTasks();
return response;
} catch (NumberFormatException e) {
throw DukeException.DukeInvalidIndex();
} catch (IndexOutOfBoundsException e) {
throw DukeException.DukeInvalidIndex();
} catch (DukeException d) {
throw d;
}
case "unmark":
try {
int index = Integer.parseInt(userInput.substring(UNMARK_LENGTH)) - 1;
response = this.taskList.unmarkTaskAsDone(index);
writeTasks();
return response;
} catch (NumberFormatException e) {
throw DukeException.DukeInvalidIndex();
} catch (IndexOutOfBoundsException e) {
throw DukeException.DukeInvalidIndex();
} catch (DukeException d) {
throw d;
}
case "delete":
try {
int index = Integer.parseInt(userInput.substring(DELETE_LENGTH)) - 1;
response = this.taskList.deleteTaskAtIndex(index);
writeTasks();
return response;
} catch (IndexOutOfBoundsException e) {
throw DukeException.DukeInvalidIndex();
}
case "find":
try {
ArrayList<Task> matchingTasks = this.parser.findTasksByKeyword(userInput,
this.taskList.getTasks());
response = this.ui.getMatchingTasksMessage(matchingTasks);
return response;
} catch (DukeException d) {
throw d;
}
default:
Task task = this.parser.parseTaskFromUi(command, userInput);
if (this.parser.isDuplicate(task, this.taskList.getTasks())) {
throw DukeException.DukeDuplicate();
}
response = this.taskList.addTask(task);
writeTasks();
return response;
}
} catch (DukeException d) {
response = this.ui.getErrorMessage(d);
return response;
}
}
Example from src/main/java/parser/Parser.java
lines 40-90
:
public Task parseTaskFromUi(String command, String userInput) throws DukeException {
assert command != null && userInput != null;
switch (command) {
case "todo":
try {
String description = userInput.split(" ", 2)[1];
description = description.trim();
if (description.equals("")) {
throw DukeException.DukeDescriptionEmpty();
}
return new Todo(description);
} catch (IndexOutOfBoundsException e) {
throw DukeException.DukeDescriptionEmpty();
} catch (DukeException d) {
throw DukeException.DukeDescriptionEmpty();
}
case "deadline":
try {
String[] descriptionAndTime = userInput.substring(9).split(" /by ");
String description = descriptionAndTime[0].trim();
if (description.equals("")) {
throw DukeException.DukeDescriptionEmpty();
}
LocalDate deadlineTime = LocalDate.parse(descriptionAndTime[1].trim());
return new Deadline(description, deadlineTime);
} catch (DukeException d) {
throw DukeException.DukeDescriptionEmpty();
} catch (Exception e) {
throw DukeException.DukeInvalidCommand();
}
case "event":
try {
String[] descriptionAndTime = userInput.substring(6).split(" /at ");
String description = descriptionAndTime[0].trim();
if (description.equals("")) {
throw DukeException.DukeDescriptionEmpty();
}
LocalDate eventTime = LocalDate.parse(descriptionAndTime[1].trim());
return new Event(description, eventTime);
} catch (DukeException d) {
throw DukeException.DukeDescriptionEmpty();
} catch (Exception e) {
throw DukeException.DukeInvalidCommand();
}
default:
throw DukeException.DukeInvalidCommand();
}
}
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/duke/Duke.java
lines 49-53
:
/**
* The main logic of the process of Duke.
* @param args
* @throws DukeException
*/
Example from src/main/java/duke/Duke.java
lines 60-64
:
/**
* Initialize Duke by reading from the default file.
* Greet Users.
* @throws DukeException
*/
Example from src/main/java/duke/Duke.java
lines 69-71
:
/**
* The main process of how Duke runs.
*/
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 @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.
@vishandi 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 101-185
:
public String processUserInput(String userInput) {
assert userInput != null;
String[] userInputs = userInput.split(" ");
String command = userInputs[0];
String response;
try {
switch (command) {
case "bye":
if (userInput.equals("bye")) {
response = Duke.BYE;
return response;
} else {
throw DukeException.DukeInvalidCommand();
}
case "list":
if (userInput.equals("list")) {
response = this.taskList.toString();
return response;
} else {
throw DukeException.DukeInvalidCommand();
}
case "mark":
try {
int index = Integer.parseInt(userInput.substring(MARK_LENGTH)) - 1;
response = this.taskList.markTaskAsDone(index);
writeTasks();
return response;
} catch (NumberFormatException e) {
throw DukeException.DukeInvalidIndex();
} catch (IndexOutOfBoundsException e) {
throw DukeException.DukeInvalidIndex();
} catch (DukeException d) {
throw d;
}
case "unmark":
try {
int index = Integer.parseInt(userInput.substring(UNMARK_LENGTH)) - 1;
response = this.taskList.unmarkTaskAsDone(index);
writeTasks();
return response;
} catch (NumberFormatException e) {
throw DukeException.DukeInvalidIndex();
} catch (IndexOutOfBoundsException e) {
throw DukeException.DukeInvalidIndex();
} catch (DukeException d) {
throw d;
}
case "delete":
try {
int index = Integer.parseInt(userInput.substring(DELETE_LENGTH)) - 1;
response = this.taskList.deleteTaskAtIndex(index);
writeTasks();
return response;
} catch (IndexOutOfBoundsException e) {
throw DukeException.DukeInvalidIndex();
}
case "find":
try {
ArrayList<Task> matchingTasks = this.parser.findTasksByKeyword(userInput,
this.taskList.getTasks());
response = this.ui.getMatchingTasksMessage(matchingTasks);
return response;
} catch (DukeException d) {
throw d;
}
default:
Task task = this.parser.parseTaskFromUi(command, userInput);
if (this.parser.isDuplicate(task, this.taskList.getTasks())) {
throw DukeException.DukeDuplicate();
}
response = this.taskList.addTask(task);
writeTasks();
return response;
}
} catch (DukeException d) {
response = this.ui.getErrorMessage(d);
return response;
}
}
Example from src/main/java/parser/Parser.java
lines 43-93
:
public Task parseTaskFromUi(String command, String userInput) throws DukeException {
assert command != null && userInput != null;
switch (command) {
case "todo":
try {
String description = userInput.split(" ", 2)[1];
description = description.trim();
if (description.equals("")) {
throw DukeException.DukeDescriptionEmpty();
}
return new Todo(description);
} catch (IndexOutOfBoundsException e) {
throw DukeException.DukeDescriptionEmpty();
} catch (DukeException d) {
throw DukeException.DukeDescriptionEmpty();
}
case "deadline":
try {
String[] descriptionAndTime = userInput.substring(9).split(" /by ");
String description = descriptionAndTime[0].trim();
if (description.equals("")) {
throw DukeException.DukeDescriptionEmpty();
}
LocalDate deadlineTime = parseDate(descriptionAndTime[1].trim());
return new Deadline(description, deadlineTime);
} catch (DukeException d) {
throw d;
} catch (Exception e) {
throw DukeException.DukeInvalidCommand();
}
case "event":
try {
String[] descriptionAndTime = userInput.substring(6).split(" /at ");
String description = descriptionAndTime[0].trim();
if (description.equals("")) {
throw DukeException.DukeDescriptionEmpty();
}
LocalDate eventTime = parseDate(descriptionAndTime[1].trim());
return new Event(description, eventTime);
} catch (DukeException d) {
throw d;
} catch (Exception e) {
throw DukeException.DukeInvalidCommand();
}
default:
throw DukeException.DukeInvalidCommand();
}
}
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/duke/Duke.java
lines 40-44
:
/**
* (Another) constructs Duke which directly parse the input to storage attribute.
*
* @param storage any object of IStorage class.
*/
Example from src/main/java/task/Deadline.java
lines 24-29
:
/**
* (Another) constructs Deadline.
*
* @param description the description for the task.
* @param DeadlineTime deadline time for the task.
*/
Example from src/main/java/task/Event.java
lines 24-29
:
/**
* (Another) constructs Event.
*
* @param description the description for the task.
* @param eventTime status of the task.
*/
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.
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.