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
@rycs2812 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.
privateStringgetUsageError(Stringargs, Dukeduke) {
TaskListtaskList = duke.getTaskList();
Stringusage = getCorrectUsage();
Stringerror = "ERROR: \n\n";
asserttaskList != null : "Task list is null";
switch(name) {
case"delete":
if (args.isEmpty()) {
returnerror + "Please specify a task number.\n\n" + usage;
}
try {
intindex = Integer.parseInt(args);
intcount = taskList.getCount();
if (index <= 0 || index > taskList.getCount()) {
returnerror + "Please specify a valid task number. There are "
+ count + " tasks in the list\n\n" + usage;
}
} catch (NumberFormatExceptione) {
returnerror + "Please specify a task number.\n\n" + usage;
}
return"";
case"find":
if (args.isBlank()) {
returnerror + "Please specify at least one keyword.\n\n" + usage;
} elseif (args.charAt(0) != '"' || args.charAt(args.length() - 1) != '"') {
if (args.split(" ").length > 1) {
returnerror + "'find' only expects 1 argument.\n\n If there are multiple "
+ "keywords, please enclose them in quotation marks (\"\").";
}
} else {
if (args.length() == 2 || args.substring(1, args.length() - 1).isBlank()) {
returnerror + "Please specify at least one keyword.\n\n" + usage;
}
}
return"";
case"list":
if (!args.isEmpty()) {
returnerror + "'list' expects no arguments.";
}
return"";
case"deadline":
String[] temp = args.split(" /by ", 2);
if (temp.length < 2) {
returnerror + "Please specify a task and deadline.\n\n" + usage;
} else {
String[] recurring = temp[1].split(" /every ", 2);
intperiod = getPeriod(temp[1]);
if (period < 0) {
returnerror + "Please specify a valid period for recurring tasks.\n\n" + usage;
} elseif (period == 0) {
if (!isValidDate(temp[1])) {
returnerror + "Please specify the due date in the right format.\n\n" + usage;
}
}
if (!isValidDate(recurring[0])) {
returnerror + "Please specify the due date in the right format.\n\n" + usage;
}
}
return"";
case"event":
temp = args.split(" /at ", 2);
if (temp.length < 2) {
returnerror + "Please specify an event and date.\n\n" + usage;
} else {
String[] recurring = temp[1].split(" /every ", 2);
intperiod = getPeriod(temp[1]);
if (period < 0) {
returnerror + "Please specify a valid period for recurring tasks.\n\n" + usage;
} elseif (period == 0) {
if (!isValidDate(temp[1])) {
returnerror + "Please specify the event date in the right format.\n\n" + usage;
}
}
if (!isValidDate(recurring[0])) {
returnerror + "Please specify the due date in the right format.\n\n" + usage;
}
}
return"";
case"todo":
if (args.isEmpty()) {
returnerror + "Please specify a task.\n\n" + usage;
}
return"";
case"mark":
// Fallthroughcase"unmark":
if (args.isEmpty()) {
returnerror + "Please specify a task number\n\n" + usage;
} else {
try {
intindex = Integer.parseInt(args) - 1;
if (index < 0 || index >= taskList.getCount()) {
returnerror + "Please specify a valid task number.\n"
+ "There are " + taskList.getCount()
+ " task(s) in the list.\n\n" + usage;
}
} catch (NumberFormatExceptione) {
returnerror + "Please specify a task number.\n"
+ "\"" + args + "\"" + " is not a task number\n\n" + usage;
}
}
return"";
default:
return"";
}
}
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
No easy-to-detect issues 👍
Aspect: Recent Git Commit Message (Subject Only)
No easy-to-detect issues 👍
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 cs2103@comp.nus.edu.sg if you want to follow up on this post.
The text was updated successfully, but these errors were encountered:
@rycs2812 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/duke/Command.java
lines34-86
:Example from
src/main/java/duke/Command.java
lines106-222
: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
No easy-to-detect issues 👍
Aspect: Recent Git Commit Message (Subject Only)
No easy-to-detect issues 👍
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
cs2103@comp.nus.edu.sg
if you want to follow up on this post.The text was updated successfully, but these errors were encountered: