-
Notifications
You must be signed in to change notification settings - Fork 111
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
[T2A2][W15-A1] Xu Bili #267
base: master
Are you sure you want to change the base?
Conversation
To avoid the long boolean expression which much more difficult to read compared to if-else statements.
Ready for review |
@@ -266,7 +270,7 @@ private static void processProgramArgs(String[] args) { | |||
setupGivenFileForStorage(args[0]); | |||
} | |||
|
|||
if(args.length == 0) { | |||
if (args.length == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good that coding standard violation was spotted.
@@ -339,8 +345,28 @@ private static boolean hasValidParentDirectory(Path filePath) { | |||
* If a file already exists, it must be a regular file. | |||
*/ | |||
private static boolean hasValidFileName(Path filePath) { | |||
return filePath.getFileName().toString().lastIndexOf('.') > 0 | |||
&& (!Files.exists(filePath) || Files.isRegularFile(filePath)); | |||
if (!hasExtension(filePath)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good that the long condition has been made easier to read.
private static String removePrefixSign(String s, String sign) { | ||
return s.replace(sign, ""); | ||
private static String removePrefix(String fullString, String prefix) { | ||
return fullString.replace(prefix, ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as mentioned in tutorial, the replace behaviour would also remove instances of the prefix
argument that are found else where than the start of fullString
@@ -1150,8 +1204,8 @@ private static String getUsageInfoForExitCommand() { | |||
* @param sign Parameter sign to be removed | |||
* @return string without the sign |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to update the header comments after updating the method.
Some comments added. Feel free to add more comment if you have any questions. Once you are done, you may close the PR after reading comments. |
PR for [LO-Refactor] and [LO-MethodAbstraction].