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

List and Find Command #198

Merged
merged 19 commits into from
Oct 21, 2020
Merged

Conversation

seanjyjy
Copy link

@seanjyjy seanjyjy commented Oct 18, 2020

Pr Overview

  • ListApplicationCommand and ListApplicationCommandTest
  • FindApplicationCommand and ListApplicationCommandTest
  • Abstract out some common strings into the GeneralStringUtil
  • Reformatted how the test case looks like in MainParserTest so that it looks neater.
  • Shifted the tab parser to be part of the util file

@codecov-io
Copy link

codecov-io commented Oct 18, 2020

Codecov Report

Merging #198 into master will increase coverage by 0.45%.
The diff coverage is 75.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #198      +/-   ##
============================================
+ Coverage     49.35%   49.81%   +0.45%     
- Complexity      772      794      +22     
============================================
  Files           185      187       +2     
  Lines          3432     3485      +53     
  Branches        394      394              
============================================
+ Hits           1694     1736      +42     
- Misses         1636     1644       +8     
- Partials        102      105       +3     
Impacted Files Coverage Δ Complexity Δ
...main/java/seedu/address/commons/core/Messages.java 0.00% <ø> (ø) 0.00 <0.00> (ø)
...java/seedu/address/logic/commands/ListCommand.java 100.00% <ø> (ø) 2.00 <0.00> (ø)
...va/seedu/address/logic/commands/SwitchCommand.java 100.00% <ø> (ø) 7.00 <0.00> (ø)
...seedu/address/logic/commands/find/FindCommand.java 100.00% <ø> (+100.00%) 1.00 <0.00> (+1.00)
...in/java/seedu/address/logic/parser/ParserUtil.java 97.22% <ø> (-0.34%) 14.00 <0.00> (-2.00)
.../java/seedu/address/ui/display/CompanyDisplay.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...a/seedu/address/ui/display/InformationDisplay.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
.../java/seedu/address/ui/display/ProfileDisplay.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...seedu/address/logic/parser/util/TabParserUtil.java 88.88% <88.88%> (ø) 3.00 <3.00> (?)
.../main/java/seedu/address/commons/util/TabUtil.java 90.00% <100.00%> (-0.91%) 4.00 <0.00> (-2.00)
... and 40 more

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 973fe62...488dd9e. Read the comment docs.

@seanjyjy seanjyjy requested review from a team and removed request for ZoroarkDarkrai, orzymandias and keanecjy October 18, 2020 16:11
Copy link

@shawn-nyk shawn-nyk left a comment

Choose a reason for hiding this comment

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

Great work! Apart from the minor comments made, will wait to hear the reply on how we should be using String constants from the GeneralStringUtil class. [My take as discussed is that perhaps we should use it only when they appear in code that is not part of defining yet another String constant (e.g. we should use it in line 106 of Card.java, as opposed to the MESSAGE_USAGE definitions of the various commands, since they are themselves String constants, in which using other String constants should be used only for consistency purposes).]


public static final String COMMAND_WORD = "list";

public static final String MESSAGE_SUCCESS = "Listed all applications";

Choose a reason for hiding this comment

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

As all our list commands are going to have similar success messages, perhaps we could do what we did with the rest of the commands which would be to add something like this after line 25: String listSuccessMessage = String.format(MESSAGE_LISTED_ITEMS, APPLICATION_NAME); where MESSAGE_LISTED_ITEMS resides in Messages.java and goes something like: "Listed all %1$s items";? Just a suggestion!

Copy link
Author

Choose a reason for hiding this comment

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

oh this sounds great, will abstract it into messages.java then

*/
public class ListApplicationCommand extends ListCommand {

public static final String COMMAND_WORD = "list";

Choose a reason for hiding this comment

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

Is this redundant given that ListApplicationCommand can use ListCommand's COMMAND_WORD? This is with regards to how all the other commands exhibit the same pattern in that they use the parent's COMMAND_WORD.

Copy link
Author

@seanjyjy seanjyjy Oct 19, 2020

Choose a reason for hiding this comment

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

Ah, yes that is true, will make the relevant changes once we get our affirmation regarding the above dicussions

…into list-command

� Conflicts:
�	src/main/java/seedu/address/logic/parser/util/GeneralParserUtil.java
…into list-command

� Conflicts:
�	src/main/java/seedu/address/logic/commands/find/FindApplicationCommand.java
�	src/test/java/seedu/address/testutil/application/SampleApplicationItems.java
@seanjyjy seanjyjy linked an issue Oct 21, 2020 that may be closed by this pull request
@seanjyjy seanjyjy linked an issue Oct 21, 2020 that may be closed by this pull request
Copy link

@shawn-nyk shawn-nyk left a comment

Choose a reason for hiding this comment

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

Great work Sean! Perhaps just a few minor nits to fix and we'll be good to merge.

/** Find message: First string refers to the number if item found */
public static final String MESSAGE_FIND_APPLICATION_SUCCESS = "%1$d applications listed!";
/** Find message: First string refers to the number if item found. second string refers to the item type. */
public static final String MESSAGE_FIND_SUCCESS = "%1$d %2$s listed!";

Choose a reason for hiding this comment

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

Super minor point, but with regards to the phrasing, I suppose this might read a little awkwardly for more than 1 item found, such as "3 company listed!"? But it's just the phrasing so it's not a big deal and we can probably handle this in the future if we want!

Copy link
Author

Choose a reason for hiding this comment

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

yeah i did thought about it, but it feels weird if we have to add in a condition for it LOL for whether to display the extra s. Hmm i think since we are dealing with a 1 vs Infinite amount, it feels like having the s should make sense right O:

Copy link
Author

Choose a reason for hiding this comment

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

I think I will temporarily put this as %1$d %2$s items found!

Choose a reason for hiding this comment

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

oh yea great idea!

@@ -30,15 +29,9 @@ public static TabName getSwitchTabName(String tab) throws ParseException {
tabName = TabName.PROFILE;
break;
default:
throw new ParseException(MESSAGE_INVALID_TAB);
throw new ParseException(MESSAGE_INVALID_ITEM_TYPE);

Choose a reason for hiding this comment

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

Will this throw an inappropriate error message? Correct me if I'm mistaken, but does this throw the error message "Item type has to be either 'com', 'int', 'app' or 'me'"? If so, I believe that since we can't run switch int, should we revert back to the old error message / something along the lines of "Item type has to be either 'com', 'app' or 'me'"?

Copy link
Author

@seanjyjy seanjyjy Oct 21, 2020

Choose a reason for hiding this comment

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

hmm, I think since this is a more towards only switch kind of command, I believe I should make a separate message then. Are there any other commands that have the same issue? I believe list and find as well right?

Choose a reason for hiding this comment

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

Yup true! Sounds good!

@shawn-nyk shawn-nyk merged commit d94502c into AY2021S1-CS2103T-T15-4:master Oct 21, 2020
@seanjyjy seanjyjy added the Code label Nov 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants