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

Refactoring command to extract all uses of an expression #2702

Closed
pbiggar opened this issue Jul 7, 2020 · 3 comments
Closed

Refactoring command to extract all uses of an expression #2702

pbiggar opened this issue Jul 7, 2020 · 3 comments

Comments

@pbiggar
Copy link
Member

pbiggar commented Jul 7, 2020

I have code like this:

let _ = DB::setv1
          {
            name : request.body.name
            email : request.body.email
            username : request.body.username
            time : Date::now
            coc : request.body.coc == "on"
          }
          request.body.email
          Attendees
let query = "email=" ++ AWS::urlencode request.body.email

which reuses request.body.email three times. I want to extract request.body.email so the code is like this:

let email = request.body.email
let _ = DB::setv1
          {
            name : request.body.name
            email : email
            username : request.body.username
            time : Date::now
            coc : request.body.coc == "on"
          }
          email
          Attendees
let query = "email=" ++ AWS::urlencode email

There exists a refactoring command extract-variable which will just create the let and replace it in the current position. This new command should replace request.body.email in all places that are in scope.

@klebervirgilio
Copy link

@pbiggar would that be something that a newcomer could work on?

@pbiggar
Copy link
Member Author

pbiggar commented Jul 8, 2020

Yes, very much so (that's what the good-early-bug tag is intended to convey 🙂 ).

You can copy the extract-variable code and modify it, and that should get you most of the way there (see the getting started guide for getting the basics of contributing!

@StachuDotNet
Copy link
Member

folded into #5242

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

No branches or pull requests

3 participants