Skip to content

Boilerplate code rediction#265

Merged
alexindigo merged 2 commits intoform-data:masterfrom
trierra:code-duplicates-fix
Oct 2, 2016
Merged

Boilerplate code rediction#265
alexindigo merged 2 commits intoform-data:masterfrom
trierra:code-duplicates-fix

Conversation

@trierra
Copy link
Copy Markdown
Contributor

@trierra trierra commented Sep 30, 2016

Boilerplate code reduced
image

@coveralls
Copy link
Copy Markdown

coveralls commented Sep 30, 2016

Coverage Status

Coverage remained the same at 97.917% when pulling e9239fb on trierra:code-duplicates-fix into 4718dae on form-data:master.

Copy link
Copy Markdown
Member

@alexindigo alexindigo left a comment

Choose a reason for hiding this comment

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

Hey,

Thanksalot (some kind of knight) for the PR, looks awesome!

There are couple things that could use some improvement, but other than that. 👍 💯

Thank you.

Comment thread test/common.js Outdated

form.parse(req);

var fieldsPassed = Object.keys(FIELDS).length;
Copy link
Copy Markdown
Member

@alexindigo alexindigo Sep 30, 2016

Choose a reason for hiding this comment

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

Do you mind to put it to the top of the function?
To keep it with the spirit of hoisting. :)

And actually it would be good at the top of the common.createServer,
so it won't be redefined on each request, in case we'd get multi-request tests.

// prepare form-receiving http server
server = http.createServer(function(req, res) {
var incomingForm = new IncomingForm({uploadDir: common.dir.tmp});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And this one, we need new instance on each request, so it could go into http.createServer of common.js.

Comment thread test/integration/test-http-response.js Outdated
// finish it
common.actions.formOnEnd(res);
});
server = common.createServer(incomingForm, FIELDS, function(fields){
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And with that, you probably can rename common.createServer to common.testFields.

@coveralls
Copy link
Copy Markdown

coveralls commented Oct 1, 2016

Coverage Status

Coverage remained the same at 97.917% when pulling aa99246 on trierra:code-duplicates-fix into 4718dae on form-data:master.

Copy link
Copy Markdown
Member

@alexindigo alexindigo left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Thank you.

@alexindigo alexindigo merged commit f64a4c3 into form-data:master Oct 2, 2016
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

Successfully merging this pull request may close these issues.

3 participants