9temare / 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
@9teMare 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
No easy-to-detect issues
No easy-to-detect issues
Example from src/main/java/duke/command/AddCommand.java
lines 30-37
:
/**
* Add the given task to the task list.
* If the task already exists, task will not be added and exception will be thrown.
*
* @param taskList the task list to operate on
* @param ui the ui to operate on
* @param storage the storage to operate on
*/
Example from src/main/java/duke/command/ClearAllCommand.java
lines 15-21
:
/**
* Clear all tasks in the task list.
*
* @param taskList the task list to operate on
* @param ui the ui to operate on
* @param storage the storage to operate on
*/
Example from src/main/java/duke/command/Command.java
lines 12-20
:
/**
* Execute the corresponding command.
* This is an abstract method, all children will have corresponding implementations.
*
* @param tasks the TaskList tasks
* @param ui the ui
* @param storage the storage
* @throws CortanaException the cortana exception
*/
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
[email protected]
if you want to follow up on this post.
@9teMare 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/utils/Parser.java
lines 33-156
:
public Parser() {}
/**
* Parse input to Command.
*
* @param input the user input
* @return the specific Cortana command
* @throws CortanaException the cortana exception
*/
public static Command parse(String input) throws CortanaException {
boolean isExit = input.toLowerCase().replaceAll("[ |\\t]", "").equals("bye");
boolean isListCommand = input.toLowerCase().replaceAll("[ |\\t]", "").equals("list");
boolean isMarkCommand = input.toLowerCase().matches("^mark [-\\d ]+|[\\d ]+");
boolean isUnmarkCommand = input.toLowerCase().matches("^unmark [-\\d ]+|[\\d ]+");
boolean isDeleteCommand = input.toLowerCase().matches("^delete [-\\d ]+|[\\d ]+");
boolean isDeleteAllCommand = input.toLowerCase().matches("^delete all");
boolean isShowAllOnSameDate = input.toLowerCase()
.matches("^show all( )?(\\d{4} ?.?/?-?\\d{1,2} ?.?/?-?\\d{1,2})?( )?(\\d{4})?");
boolean isFindCommand = input.toLowerCase().matches("^find( )? .*");
boolean isViewSchedules = input.toLowerCase()
.matches("^view schedules( )?(\\d{4} ?.?/?-?\\d{1,2} ?.?/?-?\\d{1,2})?");
boolean isEmptyDeadline = input.toLowerCase().replaceAll("[ |\\t]", "").equals("deadline");
boolean isEmptyEvent = input.toLowerCase().replaceAll("[ |\\t]", "").equals("event");
boolean isEmptyTodo = input.toLowerCase().replaceAll("[ |\\t]", "").equals("todo");
boolean isDeadlineWithDescription = input.toLowerCase().matches("^deadline .*");
boolean isEventWithDescription = input.toLowerCase().matches("^event .*");
boolean isTodoWithDescription = input.toLowerCase().matches("^todo .*");
if (isExit) {
return new ExitCommand();
}
if (isListCommand) {
return new ListCommand();
}
if (isMarkCommand) {
String[] indexesString = input.replaceAll("mark ", "").split(" ");
int[] arr = Arrays.stream(indexesString).mapToInt(i -> Integer.parseInt(i) - 1).toArray();
return new MarkCommand(arr);
}
if (isUnmarkCommand) {
String[] indexesString = input.replaceAll("unmark ", "").split(" ");
int[] arr = Arrays.stream(indexesString).mapToInt(i -> Integer.parseInt(i) - 1).toArray();
return new UnmarkCommand(arr);
}
if (isDeleteCommand) {
String[] indexesString = input.replaceAll("delete ", "").split(" ");
int[] arr = Arrays.stream(indexesString).mapToInt(i -> Integer.parseInt(i) - 1).toArray();
return new DeleteCommand(arr);
}
if (isDeleteAllCommand) {
return new DeleteAllCommand();
}
if (isShowAllOnSameDate) {
boolean isWithoutDateTime = input.replaceAll(" ", "").matches("showall");
if (isWithoutDateTime) {
/* user did not specify time */
throw new CortanaException("Please specify the date time you are looking for!");
}
String dateTimeString = input.replaceAll("show all ", "");
return new ShowAllTasksOnSameDateCommand(parseLocalDateTime(dateTimeString), dateTimeString);
}
if (isFindCommand) {
String keyWord = input.replaceAll("find ", "");
if (keyWord.isEmpty()) {
throw new CortanaException("Please specify the keyword you are looking for!");
} else {
return new FindCommand(keyWord);
}
}
if (isViewSchedules) {
boolean isWithoutDateTime = input.replaceAll(" ", "").matches("viewschedules");
if (isWithoutDateTime) {
/* user did not specify time */
throw new CortanaException("Please specify the date time you are looking for!");
}
String dateTimeString = input.replaceAll("view schedules ", "");
return new ViewSchedulesCommand(parseLocalDateTime(dateTimeString).toLocalDate(), dateTimeString);
}
if (isEmptyDeadline || isEmptyEvent || isEmptyTodo) {
/* user does not specify task description*/
String aOrAn = isEmptyEvent ? "an " : "a ";
TaskType taskType = isEmptyDeadline ? TaskType.DEADLINE : isEmptyEvent ? TaskType.EVENT : TaskType.TODO;
throw new CortanaException("OOPS!!! The description of " + aOrAn + taskType
+ " cannot be empty!");
}
boolean hasBy = Pattern.compile("/by .*").matcher(input).find();
boolean hasAt = Pattern.compile("/at .*").matcher(input).find();
String description;
String time;
if (isDeadlineWithDescription && hasBy) {
/* valid deadline command */
String[] actualTask = input.replaceAll("^deadline ", "")
.split("/by ");
description = actualTask[0];
time = actualTask[1];
Deadline deadline = new Deadline(description, parseLocalDateTime(time));
return new AddCommand(deadline);
} else if (isEventWithDescription && hasAt) {
/* valid event command */
String[] actualTask = input.replaceAll("^event ", "").split("/at ");
description = actualTask[0];
time = actualTask[1];
Event event = new Event(description, parseLocalDateTime(time));
return new AddCommand(event);
} else if (isTodoWithDescription) {
/* valid todo command */
description = input.replaceAll("^todo ", "");
Todo todo = new Todo(description);
return new AddCommand(todo);
} else if (isDeadlineWithDescription) {
/* deadline without specifying time with /by */
throw new CortanaException("Please specify the deadline time with the /by keyword!");
} else if (isEventWithDescription) {
/* event without specifying time with /at */
throw new CortanaException("Please specify the event time with the /at keyword!");
} else {
/* invalid command */
throw new CortanaException("I don't know what that means :(");
}
}
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/command/AddCommand.java
lines 30-36
:
/**
* Add a task to the task list.
*
* @param taskList the task list to operate on
* @param ui the ui to operate on
* @param storage the storage to operate on
*/
Example from src/main/java/duke/command/Command.java
lines 12-19
:
/**
* Execute the corresponding command.
*
* @param tasks the TaskList tasks
* @param ui the ui
* @param storage the storage
* @throws CortanaException the cortana exception
*/
Example from src/main/java/duke/command/DeleteAllCommand.java
lines 15-21
:
/**
* Delete all tasks in the task list.
*
* @param taskList the task list to operate on
* @param ui the ui to operate on
* @param storage the storage to operate on
*/
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 364b294
:
Add support for mark/unmark/delete more than 1 task at the same time through varargs
Suggestion: Follow the given conventions for Git commit messages for future commits (no need to modify past commit messages).
[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.