You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@blackpanther9229 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.
publicstaticCommandparse(StringfullCommand) throwsNahException {
assertfullCommand != null : "fullCommand cannot be null";
String[] cmd = fullCommand.split(" ", 2);
assertcmd[0] != null : "unexpected null value for command";
switch (cmd[0].toLowerCase()) {
case"bye": {
returnnewCommand.ExitCommand();
}
case"nah": {
if (cmd.length < 2) {
returnnewCommand.ReactCommand("nah");
}
inti;
try {
i = parseInt(cmd[1]);
} catch (NumberFormatExceptione) { // the second word is not a numberreturnnewCommand.UnknownCommand();
}
returnnewCommand.NahCommand(i);
}
case"hi": case"hello": case"oke": case"yo": {
returnnewCommand.ReactCommand(cmd[0].toLowerCase());
}
case"clean": {
if (cmd.length >= 2 && !cmd[1].trim().isEmpty()) { // there are nonsense word after 'clean'thrownewNahException(" Nahh!!! Do not type nonsense after 'clean' command\n");
}
returnnewCommand.CleanCommand();
}
case"list": {
if (cmd.length >= 2 && !cmd[1].trim().isEmpty()) { // there are nonsense word after 'list'thrownewNahException(" Nahh!!! Do not type nonsense after 'list' command\n");
}
returnnewCommand.ListCommand();
}
case"find": {
if (cmd.length < 2) {
returnnewCommand.FindCommand("");
}
returnnewCommand.FindCommand(cmd[1]);
}
case"mark": {
if (cmd.length < 2) {
thrownewNahException(// No number for mark command" Nah!!! Mark command needs a number\n");
}
inti;
try {
i = parseInt(cmd[1]);
} catch (NumberFormatExceptione) {
thrownewNahException(
" Nah.Nah!!! Please give me a valid ordinal number for the task\n");
}
returnnewCommand.MarkCommand(i);
}
case"help": {
returnnewCommand.HelpCommand();
}
case"unmark": {
if (cmd.length < 2) {
thrownewNahException(
" Nah!!! Unmark command needs a number\n");
}
inti;
try {
i = parseInt(cmd[1]);
} catch (NumberFormatExceptione) {
thrownewNahException(
" Nah.Nah!!! Please give me a valid ordinal number for the task\n");
}
returnnewCommand.UnmarkCommand(i);
}
case"delete": {
if (cmd.length < 2) {
thrownewNahException(" Nah!!! Delete command needs a number\n");
}
inti;
try {
i = parseInt(cmd[1]);
} catch (NumberFormatExceptione) {
thrownewNahException(
" Nah.Nah!!! Please give me a valid ordinal number for the task\n");
}
returnnewCommand.DeleteCommand(i);
}
case"dueon": {
if (cmd.length < 2) {
thrownewNahException(
" Nah!!! DueOn command needs a time\n");
}
returnnewCommand.DueOnCommand(cmd[1]);
}
case"todo": {
if (cmd.length < 2 || cmd[1].trim().isEmpty()) {
thrownewNahException.LackDescriptionException(
" Nahhhh!!! Todo needs description\n");
}
returnnewCommand.AddCommand(newToDos(cmd[1].trim()));
}
case"deadline": {
if (cmd.length < 2 || cmd[1].trim().isEmpty()) {
thrownewNahException.LackDescriptionException(
" Nahhhhh!!! Deadline needs description\n");
}
String[] des = cmd[1].split("/by", 2);
if (des.length < 2 || des[1].trim().isEmpty()) {
thrownewNahException.LackDescriptionException(
" Nahhhhhhhhh!!! Deadline needs deadline\n");
}
LocalDateTimeby;
try {
by = LocalDateTime.parse(des[1].trim(), DateTimeFormatter.ofPattern("yyyy-MM-dd HHmm"));
} catch (DateTimeParseExceptione) {
thrownewNahException(
" Nahh!!! Time should be in the format yyyy-mm-dd hhmm, with valid date and time\n");
}
returnnewCommand.AddCommand(newDeadlines(des[0].trim(), by));
}
case"event": {
if (cmd.length < 2 || cmd[1].trim().isEmpty()) {
thrownewNahException.LackDescriptionException(
" Nahhhhh!!! Event needs description\n");
}
String[] des = cmd[1].split("/from", 2);
if (des.length < 2 || des[1].trim().isEmpty()) {
thrownewNahException.LackDescriptionException(
" Nahhhhhhhhh!!! Event needs starting time\n");
}
String[] time = des[1].split("/to", 2);
if (time.length < 2 || time[1].trim().isEmpty()) {
thrownewNahException.LackDescriptionException(
" Nahhhhhhhhhhhh!!! Event needs ending time\n");
}
LocalDateTimestart;
LocalDateTimeend;
try {
start = LocalDateTime.parse(time[0].trim(), DateTimeFormatter.ofPattern("yyyy-MM-dd HHmm"));
end = LocalDateTime.parse(time[1].trim(), DateTimeFormatter.ofPattern("yyyy-MM-dd HHmm"));
} catch (DateTimeParseExceptione) {
thrownewNahException(
" Nahh!!! Time should be in the format yyyy-mm-dd hhmm, with valid date and time\n");
}
if (end.isBefore(start)) {
thrownewNahException(" Nah!!! Ending time should be after starting time.");
}
returnnewCommand.AddCommand(newEvents(des[0].trim(), start, end));
}
default: {
returnnewCommand.UnknownCommand();
}
}
}
publicstaticTaskdecode(Strings) throwsNahException {
if (!checkFirstThreeComponent(s)) {
thrownewNahException.InvalidFileValueException();
}
String[] command = s.split("\\|", 3);
if (command[0].trim().equals(TODO)) {
Taskt = newToDos(command[2].trim());
if (isDone(command[1])) {
t.mark();
}
returnt;
}
if (command[0].trim().equals(DEADLINE)) {
String[] des = command[2].split("\\|", 2);
if (des.length < 2 || des[1].trim().isEmpty()) {
thrownewNahException.InvalidFileValueException();
}
try {
LocalDateTimetime = LocalDateTime
.parse(des[1].trim(), DateTimeFormatter.ofPattern(TIME_PATTERN));
Taskt = newDeadlines(des[0].trim(), time);
if (isDone(command[1])) {
t.mark();
}
returnt;
} catch (DateTimeParseExceptione) {
thrownewNahException.InvalidFileValueException();
}
}
if (command[0].trim().equals(EVENT)) {
String[] des = command[2].split("\\|", 2);
if (des.length < 2 || des[1].trim().isEmpty()) {
thrownewNahException.InvalidFileValueException();
}
String[] time = des[1].split("\\|", 2);
if (time.length < 2 || time[1].trim().isEmpty()) {
thrownewNahException.InvalidFileValueException();
}
try {
LocalDateTimestart = LocalDateTime
.parse(time[0].trim(), DateTimeFormatter.ofPattern(TIME_PATTERN));
LocalDateTimeend = LocalDateTime
.parse(time[1].trim(), DateTimeFormatter.ofPattern(TIME_PATTERN));
assertstart.isBefore(end) : "Start time must be before End time";
Taskt = newEvents(des[0].trim(), start, end);
if (isDone(command[1])) {
t.mark();
}
returnt;
} catch (DateTimeParseExceptione) {
thrownewNahException.InvalidFileValueException();
}
}
thrownewNahException.InvalidFileValueException();
}
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.
/** * return a DialogBox for chatBot Nah. * @param text corresponding text * @param img avatar for Nah * @return a DialogBox */
Suggestion: Ensure method/class header comments follow the format specified in the coding standard, in particular, the phrasing of the overview statement.
Make chatBot more user friendly by setting waiting time when closing
window screen
No blank line between subject and body
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).
Aspect: Binary files in repo
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.
The text was updated successfully, but these errors were encountered:
@blackpanther9229 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.
Aspect: Tab Usage
No easy-to-detect issues 👍
Aspect: Naming boolean variables/methods
No easy-to-detect issues 👍
Aspect: Brace Style
No easy-to-detect issues 👍
Aspect: Package Name Style
No easy-to-detect issues 👍
Aspect: Class Name Style
No easy-to-detect issues 👍
Aspect: Dead Code
No easy-to-detect issues 👍
Aspect: Method Length
Example from
src/main/java/nah/parser/Parser.java
lines25-178
:Example from
src/main/java/nah/storage/Decoder.java
lines59-116
: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.
Aspect: Class size
No easy-to-detect issues 👍
Aspect: Header Comments
Example from
src/main/java/nah/Nah.java
lines67-70
:Example from
src/main/java/nah/gui/DialogBox.java
lines85-90
:Example from
src/main/java/nah/gui/DialogBox.java
lines95-100
:Suggestion: Ensure method/class header comments follow the format specified in the coding standard, in particular, the phrasing of the overview statement.
Aspect: Recent Git Commit Message
possible problems in commit
4a0b2d0
: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).
Aspect: Binary files in repo
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.The text was updated successfully, but these errors were encountered: