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

Add basic functionalities for the ClearAllCommand #45

Merged

Conversation

IceWizard4902
Copy link
Collaborator

Todo (maybe enhancement later): Dislay that the list is empty after the clear command,
i.e Showing a prompt saying the list is empty

Todo (maybe enhancement later): Dislay that the list is empty after the clear command,
i.e Showing a prompt saying the list is empty
@codecov-commenter
Copy link

codecov-commenter commented Oct 9, 2021

Codecov Report

Merging #45 (15f4cbb) into master (cb8509f) will decrease coverage by 0.68%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #45      +/-   ##
============================================
- Coverage     71.33%   70.65%   -0.69%     
  Complexity      417      417              
============================================
  Files            74       75       +1     
  Lines          1284     1295      +11     
  Branches        131      132       +1     
============================================
- Hits            916      915       -1     
- Misses          334      345      +11     
- Partials         34       35       +1     
Impacted Files Coverage Δ
...main/java/seedu/address/commons/core/Messages.java 0.00% <ø> (ø)
.../seedu/address/logic/commands/ClearAllCommand.java 0.00% <0.00%> (ø)
.../seedu/address/logic/parser/AddressBookParser.java 89.47% <0.00%> (-10.53%) ⬇️
src/main/java/seedu/address/model/AddressBook.java 84.61% <0.00%> (-7.06%) ⬇️
src/main/java/seedu/address/model/Model.java 100.00% <ø> (ø)
...rc/main/java/seedu/address/model/ModelManager.java 95.91% <0.00%> (-4.09%) ⬇️
...a/seedu/address/model/person/UniquePersonList.java 88.37% <0.00%> (-4.32%) ⬇️
src/main/java/seedu/address/ui/PersonCard.java 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cb8509f...15f4cbb. Read the comment docs.

Copy link
Member

@yongxiangng yongxiangng left a comment

Choose a reason for hiding this comment

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

Looks good to me for the most part. I've left some comments as well. Thanks :^)

Comment on lines 17 to 19
public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Clears all entries from the address book.\n"
+ "Example: " + COMMAND_WORD + " 1";
Copy link
Member

Choose a reason for hiding this comment

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

  • Address book to ForYourInterest
  • " 1" is not needed, see user guide here for the format

Comment on lines 76 to 78
case ClearAllCommand.COMMAND_WORD:
return new ClearAllCommand();

Copy link
Member

Choose a reason for hiding this comment

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

Place this in alphabetical order if possible, in the same order as the import statements

Comment on lines 96 to 102
/**
* Clears every entry from this {@code AddressBook}.
*/
public void clearAllPerson() {
persons.clearAllPerson();
}

Copy link
Member

Choose a reason for hiding this comment

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

Not sure if we should change this @code AddressBook part, we might be able to refactor this all at once in the future

Comment on lines 27 to 37
@Override
public CommandResult execute(Model model) throws CommandException {
List<Person> lastShownList = model.getFilteredPersonList();

if (lastShownList.size() == 0) {
throw new CommandException(Messages.MESSAGE_EMPTY_LIST);
}

model.clearAllPerson();
return new CommandResult(MESSAGE_CLEAR_ALL_SUCCESS);
}
Copy link
Member

Choose a reason for hiding this comment

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

Try to get the unfiltered list.
Using the filtered list may lead to this scenario:

  1. There is data in the JSON file
  2. User filters with find command and uses some nonsense keyword
  3. User gets 0 search results back
  4. lastShownList.size() == 0
  5. Exception thrown saying the JSON file is empty when it is not empty

@yongxiangng yongxiangng merged commit 4015615 into AY2122S1-CS2103-T16-4:master Oct 10, 2021
@IceWizard4902 IceWizard4902 added this to the v1.2 milestone Oct 21, 2021
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.

3 participants