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

Make Address optional #74

Merged
merged 6 commits into from
Oct 10, 2024

Conversation

dasha3412
Copy link

Fixes #55

Copy link

codecov bot commented Oct 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Files with missing lines Coverage Δ Complexity Δ
...a/seedu/address/logic/parser/AddCommandParser.java 100.00% <100.00%> (ø) 5.00 <0.00> (ø)
.../seedu/address/logic/parser/EditCommandParser.java 92.59% <100.00%> (ø) 11.00 <0.00> (ø)
...in/java/seedu/address/logic/parser/ParserUtil.java 97.05% <ø> (-0.17%) 13.00 <0.00> (-1.00)
.../main/java/seedu/address/model/person/Address.java 92.85% <ø> (ø) 6.00 <0.00> (ø)
.../java/seedu/address/storage/JsonAdaptedPerson.java 100.00% <ø> (ø) 10.00 <0.00> (-1.00)

... and 3 files with indirect coverage changes

@dasha3412 dasha3412 added this to the v1.2 milestone Oct 9, 2024
Copy link

@tingxuanp tingxuanp left a comment

Choose a reason for hiding this comment

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

LGTM overall, I like how you created data for a new person with only a missing address field for the address for testing!


// no address
Person expectedPersonNoAddress = new PersonBuilder(CLIVE).build();
// address tag with blank address

Choose a reason for hiding this comment

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

Similar comment to email and phone PRs, could leave a line break for consistency?

Copy link

@riccoljy riccoljy left a comment

Choose a reason for hiding this comment

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

LGTM -- have a few things to clarify though

@@ -12,10 +12,10 @@ public class Address {
public static final String MESSAGE_CONSTRAINTS = "Addresses can take any values, and it should not be blank";

/*
* The first character of the address must not be a whitespace,
* otherwise " " (a blank string) becomes a valid input.
* As the address is now optional, the validation regex accepts a blank address
Copy link

Choose a reason for hiding this comment

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

Maybe the comment shouldn't include "now"?

Maybe "Validation regex accepts blank address string because address is optional" would be easier to understand for future devs who have no background knowledge that this was from AB3?

@@ -56,7 +56,7 @@ public EditCommand parse(String args) throws ParseException {
editPersonDescriptor.setEmail(ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get()));
}
if (argMultimap.getValue(PREFIX_ADDRESS).isPresent()) {
editPersonDescriptor.setAddress(ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get()));
editPersonDescriptor.setAddress(ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).orElse("")));
Copy link

Choose a reason for hiding this comment

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

I could be misunderstanding this but if argMultimap.getValue(PREFIX_ADDRESS).isPresent() is true, then editPersonDescriptor.setAddress(ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).orElse(""))) will always return the argMultimap.getValue(PREFIX_ADDRESS) value, even if it is a blank string (ie: redundency...?).

Please correct me if I am wrong

@@ -84,11 +91,10 @@ public void toModelType_nullEmail_throwsIllegalValueException() {
}

@Test
public void toModelType_invalidAddress_throwsIllegalValueException() {
public void toModelType_blankAddress_returnsPerson() throws Exception {
Copy link

Choose a reason for hiding this comment

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

Would it better to declare that this function throws IllegalValueException (from person.toModelType())? I see that there is a testcase above that just throws Exception but maybe IllegalValueException would be better?

This was referenced Oct 9, 2024
@riccoljy riccoljy merged commit 26a9a27 into AY2425S1-CS2103T-F15-4:master Oct 10, 2024
4 checks passed
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.

Make address optional in the add command.
3 participants