-
Notifications
You must be signed in to change notification settings - Fork 15
[:coffin:] Refactoring return values #1209
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
The head ref may contain hidden characters: "\u267B-PROD4POD-1930-refreshFiles"
Conversation
Plus it's async, but can't use it as such here
refreshFiles is never used
fhd
left a comment
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.
Think I found a few issues - but probably @RichardSto should also take a look.
| } | ||
| for (const file of storage.files) { | ||
| resolvedFiles.push(await file); | ||
| resolvedFiles.push(file); |
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.
It's called resolvedFiles, and the await is what resolves them. Are you sure this can go?
That said, a more succinct way of doing this would be:
const resolvedFiles = await Promise.all(storage.files);
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.
In that case, I think I'd also change files to filePromises or something like that. It was not entirely clear from the context that was the case.
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.
OK, stat returns a Promise<Stats>. That should have been obvious. Still, naming matters...
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.
I guess pendingFiles would work, though I personally find it obvious enough.
| const handleRemoveFile = (fileID) => { | ||
| setAccount(null); | ||
| return storage.removeFile(fileID); | ||
| storage.removeFile(fileID); |
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.
It appears that return value is actually being used, at least in facebookImport. I didn't check, but I'll just resume storage.removeFile is either async or explicitly returns a promise. So this function explicitly returns said promise so that it can be awaited.
A possibly more clear/modern way of writing this would be:
const handelRemoveFile = async (fileID) => {
setAccount(null);
await storage.removeFile(fileID);
};
# ✍️ Description Assigning a value to an attribute violated encapsulation, which is easy to do in JS, but still. This is a cleaner API, with a private `changeListener` which is assigned when the object is built. ### 🏗️ Works with PROD4POD-1931 Still cleaning up and refactoring the importer, looking at improving coverage. Related to #1209 and #1204, but wanted it to be considered on its own. Also it's a change of API, which is better if considered on its own.
Also ♻️ for consistency
fhd
left a comment
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.
LGTM
✍️ Description
While doing #1204 a bit of refactoring is needed; and I realized this return value is never used. Giving it its own PR since it's a change in API, and want it to be tested with the rest.
Also, some refactoring mainly eliminating
awaitandreturnwhere they're not actually needed.🏗️ Fixes PROD4PROD-1931
It contributes to cleaning the repository, and improve test coverage in
importer; eliminating code that's not used will no doubt contribute to that.