Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lim Ao Jun Joel] Duke Increments #15

Open
wants to merge 87 commits into
base: master
Choose a base branch
from

Conversation

joel-lim
Copy link

No description provided.

j-lum and others added 30 commits August 6, 2019 15:25
Add toolVersion block in to Gradle code sample to prevent errors.
Gradle defaults to an empty stdin which results in runtime exceptions
when attempting to read from `System.in`. Let's add some sensible
defaults for students who may still need to work with the standard
input stream.
Add configuration for console applications
The OpenJFX plugin expects applications to be modular and bundled
with jlink, resulting in fat jars that are not cross-platform. Let's
manually include the required dependencies so that shadow can package
them properly.
Copy link

@okkhoy okkhoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, you may want to pay specific attention to SLAP. There are a few instances where some code looks repeated. Those can be extracted to methods.

try {
inputLock.acquire();
} catch (InterruptedException e) {
e.printStackTrace();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have some custom exceptions, why not use it here effectively?
In general, printing stacktrace is not considered good exception handling.

}

// Save to disk
try {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, each of this can be extracted out to separate methods to improve the SLAP.

e.printStackTrace();
}
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to add a new line at the end of the file to keep checkstyle happy 😛

*/
public interface Command {
/**
* Parses the given argument string and executes the Command.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the method is really doing both parsing and executing the command, you may want to separate out the two functionalities.

private void executeCommand(String commandWord, String arg) {
try {
commands.get(commandWord).execute(arg, tasks, ui, storage);
} catch (NullPointerException e) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not handle this NPE earlier before calling the execute command?

Comment on lines +21 to +23
dtFormatters.add(DateTimeFormatter.ofPattern("dd/MM/yyyy[ HH][:][mm][:ss]"));
dtFormatters.add(DateTimeFormatter.ofPattern("dd-MM-yyyy[ HH][:][mm][:ss]"));
dtFormatters.add(DateTimeFormatter.ofPattern("dd MM yyyy[ HH][:][mm][:ss]"));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the above ☝️ 🙂

return String.format("deadline\n%s\n%s\n%s", deadline.getName(), deadline.getDateTime(),
deadline.getIsDone());
} else {
assert task instanceof Event;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

private Scanner sc;

public TextUi() {
lineBreak = "===========================================================\n";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is lineBreak here? I don't see it being used immediately.

package duke.ui;

/**
* Allows Duke to display output to the user.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can give a better description in this header comment

String invalidDate = "11/13/2000";
String validDateWithSlash = "11/12/2000";
String validDateWithDash = "11-12-2000";
String validDateWithSpace = "11 12 2000";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when you are writing larger tests, consider moving such setup information to separate methods. find out what @before and @after do in Junit.

@joel-lim
Copy link
Author

Thanks prof for the feedback and suggestions! I will refactor my code to better adhere to SLAP and to reuse code more :-)


save(storage, tasks);

ui.showReply(String.format("Got it. I've added this task:\n %s\nNow you have %d tasks in the list.", newTask,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our static analysis engine detects that your pull request includes a change that a format string \n instead of %n. According to this description, it is a bad practice, since using \n in format string may cause cross-platform issues.


save(storage, tasks);

ui.showReply(String.format("Got it. I've added this task:\n %s\nNow you have %d tasks in the list.", newTask,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our static analysis engine detects that your pull request includes a change that a format string \n instead of %n. According to this description, it is a bad practice, since using \n in format string may cause cross-platform issues.


save(storage, tasks);

ui.showReply(String.format("Got it. I've added this task:\n %s\nNow you have %d tasks in the list.", newTask,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our static analysis engine detects that your pull request includes a change that a format string \n instead of %n. According to this description, it is a bad practice, since using \n in format string may cause cross-platform issues.


Task removed = removeTask(tasks, taskNo);

ui.showReply(String.format("Noted. I've removed this task:\n %s\nNow you have %d tasks in the list.", removed,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our static analysis engine detects that your pull request includes a change that a format string \n instead of %n. According to this description, it is a bad practice, since using \n in format string may cause cross-platform issues.

private String toSaveable(Task task) {
assert task != null : "task should not be null";
if (task instanceof Todo) {
return String.format("todo\n%s\n%s", task.getName(), task.getIsDone());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our static analysis engine detects that your pull request includes a change that a format string \n instead of %n. According to this description, it is a bad practice, since using \n in format string may cause cross-platform issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants