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

refactored lodash out #31

Merged
merged 6 commits into from
Dec 30, 2019
Merged

refactored lodash out #31

merged 6 commits into from
Dec 30, 2019

Conversation

Ore4444
Copy link
Member

@Ore4444 Ore4444 commented Dec 1, 2019

  • left only a few places that use specialized functions of lodash. replaced all the rest with native functions
  • removed util.ts in favor of utils/ folder where each utility function is in a separate file (salvaged a bit from milesj 2.0 branch)
  • removed lodash property from vorpal module
  • applied bug fix to variadic arguments from milesj 2.0 branch (buildCommandArgs.ts)

@Ore4444
Copy link
Member Author

Ore4444 commented Dec 1, 2019

Done: #23 #22
Very partially: #28

Copy link
Member

@AdrieanKhisbe AdrieanKhisbe left a comment

Choose a reason for hiding this comment

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

My two cents:

  • It's one thing to reduce usage of lodash for vanilla usage, it's totaly another one to totally ditch it.
    (not to say to replace it with handmade untested functions)
  • I'm not a huge fan of having a file per utils, where a lot of file amount the 16 are 3 liners, and with a plumbing 17 lines as index! 😷

@Ore4444
Copy link
Member Author

Ore4444 commented Dec 5, 2019

@AdrieanKhisbe

  • I didn't ditch lodash, it's still used in some key places. If there are some methods you prefer are handled by lodash, please be specific so we'll be able to debate.
  • I'm not a huge fan of one huge file with all the utils. How do you prefer handling utils?

@AdrieanKhisbe
Copy link
Member

@Ore4444

  • for starters all the one you reimplemented
  • here's whole continuum between 1 to huge file, and 17 too small. you can group related one in same file having in the end 3/4 files for instance.

@codecov-io
Copy link

codecov-io commented Dec 8, 2019

Codecov Report

Merging #31 into develop will increase coverage by 0.09%.
The diff coverage is 68.16%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #31      +/-   ##
===========================================
+ Coverage    62.26%   62.35%   +0.09%     
===========================================
  Files           14       17       +3     
  Lines         1582     1578       -4     
  Branches       390      395       +5     
===========================================
- Hits           985      984       -1     
+ Misses         591      586       -5     
- Partials         6        8       +2
Impacted Files Coverage Δ
src/intercept.ts 55.55% <ø> (ø) ⬆️
src/logger.ts 0% <0%> (ø) ⬆️
src/history.ts 94.64% <100%> (ø) ⬆️
src/utils/index.ts 100% <100%> (ø)
src/autocomplete-utils.ts 8.2% <14.28%> (ø) ⬆️
src/vorpal-commons.ts 33.33% <25%> (-1.67%) ⬇️
src/utils/formatting.ts 31.42% <31.42%> (ø)
src/ui.ts 51.31% <50%> (ø) ⬆️
src/vorpal.ts 71.84% <64.86%> (-0.23%) ⬇️
src/utils/command.ts 72.3% <72.3%> (ø)
... and 9 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 13f388c...213eaf0. Read the comment docs.

@AdrieanKhisbe AdrieanKhisbe added the Refactor 🛠️ Refactor all the things label Dec 9, 2019
Copy link
Member

@hongaar hongaar left a comment

Choose a reason for hiding this comment

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

LGTM.

We could consider replacing these functions with native ones as well:

Also, I'd be happy not to rely on lodash for trivial things like noop.

@@ -0,0 +1,8 @@
export {buildCommandArgs} from './buildCommandArgs';
Copy link
Member

Choose a reason for hiding this comment

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

You can prevent some boilerplate with

export * from './buildCommandArgs';
// etc.

Copy link
Member Author

Choose a reason for hiding this comment

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

I actually prefer making the export explicit, in case we want to add private helper functions inside the util files, or common helpers to all utils which we don't want to mistakingly export by default. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

Private helper functions wouldn't be exported so they will not pollute the index module, and I guess common helpers would go in their own files? 😉

Copy link
Member

@AdrieanKhisbe AdrieanKhisbe left a comment

Choose a reason for hiding this comment

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

Many things are still to be tuned IMO,

Taking into account your wish to smooth things up (cf the slack #general)
I won't formally Request Changes So that you can get it merge if ever you find more people thinks that can be incorporated as is

src/constants.ts Outdated Show resolved Hide resolved
src/utils/buildCommandArgs.ts Outdated Show resolved Hide resolved
src/utils/formatting/index.ts Outdated Show resolved Hide resolved
src/utils/humanReadableArgName.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,105 @@
import {ICommand, IMatchParts, InputCommand} from '../types/types';
Copy link
Member

Choose a reason for hiding this comment

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

would go perfectly with matchCommand as the two imports line there hint

src/utils/buildCommandArgs.ts Outdated Show resolved Hide resolved
src/vorpal.ts Outdated Show resolved Hide resolved
src/vorpal.ts Outdated Show resolved Hide resolved
Copy link
Member

@AdrieanKhisbe AdrieanKhisbe left a comment

Choose a reason for hiding this comment

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

Far better! :)
Good work @Ore4444 !

Almost mergeable, tell me what you think about these last comments.
(main one being in src/utils/index.ts: https://github.com/vorpaljs-reforged/vorpal/pull/31/files/f1692e44bc3a6e8523fbadfa0b20948f32c0c34b#diff-2cfb1554a9cbe2bf7981031a26f82e4e)

src/command.ts Outdated Show resolved Hide resolved
src/command.ts Outdated Show resolved Hide resolved
src/utils/index.ts Outdated Show resolved Hide resolved
src/utils/matchCommand.ts Outdated Show resolved Hide resolved
src/utils/index.ts Outdated Show resolved Hide resolved
src/utils/index.ts Outdated Show resolved Hide resolved
src/vorpal.ts Show resolved Hide resolved
commandParts.args = (utils.buildCommandArgs(
commandParts.args,
commandParts.command
) as unknown) as string;
Copy link
Member

Choose a reason for hiding this comment

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

feels a bit weird that double cast. Seems a bad smell to me
(or a sign I indeed need raising my typing level :))

Copy link
Member

@AdrieanKhisbe AdrieanKhisbe left a comment

Choose a reason for hiding this comment

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

Good for me!! :)

Thanks for the work @Ore4444!
(and sorry for this review that could have come quicker if I wasn't that much into digestion mode 😁)

@Ore4444 Ore4444 merged commit 8f23128 into develop Dec 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor 🛠️ Refactor all the things
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants