-
Notifications
You must be signed in to change notification settings - Fork 0
Sharing iP code quality feedback [for @andrea-twl] #1
Description
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 one example is given i.e., there can be other areas/places to improve.
Aspect: Tab Usage
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/com/jetbrains/Duke.java lines 7-70:
public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println(logo);
System.out.println("Hello! I'm Duke! \n" +
"What would you like to do today? \n" +
"***********************************");
ArrayList<Task> list = new ArrayList<>();
Scanner sc = new Scanner(System.in);
String input = sc.nextLine();
while (!input.equals("bye")) {
Task task;
try {
if (input.equals("list")) {
displayList(list);
System.out.println("\n");
} else if (input.contains("done")) {
String[] command = input.split(" ");
task = list.get(Integer.parseInt(command[1]) - 1);
System.out.println("Good job! I've marked this task as done:\n " +
task.markDone() +
"\n");
} else if (input.contains("delete")) {
String[] command = input.split(" ");
int index = Integer.parseInt(command[1]) - 1;
task = list.get(index);
System.out.println("Alright, I've deleted this task:\n " +
task +
"\n");
list.remove(index);
System.out.println("Now you have " + list.size() +
" task(s) in the list. \n");
} else if (input.contains("todo") ||
input.contains("deadline") ||
input.contains("event")) {
if (input.contains("todo")) {
task = new ToDo(input);
} else if (input.contains("deadline")) {
task = new Deadline(input);
} else {
task = new Event(input);
}
list.add(task);
System.out.println("Alright! I've added this task: \n " +
task + "\nNow you have " + list.size() +
" task(s) in the list. \n");
} else {
throw new DukeInvalidCommandException();
}
} catch (IndexOutOfBoundsException e) {
System.out.println("Oh no! This task does not exist. D:" );
} catch (Exception e) {
System.out.println(e.getMessage());
}
input = sc.nextLine();
}
sc.close();
System.out.println("Bye! Stay on task!");
}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.
ℹ️ 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 cs2103@comp.nus.edu.sg if you want to follow up on this post.