Uh oh!
There was an error while loading. Please reload this page.
test: reduce string concatenations - #12735
Conversation
vsemozhetbyt
commented
Apr 28, 2017
refack
commented
Apr 28, 2017
Will you be able to activate any eslint rules after this? |
@refack There are still ~20 cases like these ones I've abstained to change, at least till I think up some equally readable solutions. But these ones can be addressed with ESLint disabling comments. So |
refack
commented
Apr 28, 2017
You should add those (rule and comment exceptions) as it would provide extra motivation for this PR. |
vsemozhetbyt
commented
Apr 28, 2017
I could do this if there is a minimal consensus if we should restrict this aspect from now on. Maybe some liberality is preferred here by the other collaborators) |
P.S. for things like these ones, I would do a multiline `` with replace `PUT /this HTTP/1.1Content-Type: text/plainTransfer-Encoding: chunked4ping0`.replace(/\r|\n|\r\n/g,'\r\n') |
refack
commented
Apr 28, 2017
Yes, this is only my opinion and I actually want to +1 |
@refack By the way, |
refack
commented
Apr 29, 2017
@vsemozhetbyt I love 2ality 🥇 |
benjamingr
commented
Apr 29, 2017
I like the change but it's huge which makes it impractical to actually review. I went through the first 20-30 and they look good - but I don't feel comfortable with landing this unless someone goes through all changed content. |
vsemozhetbyt
commented
Apr 29, 2017
Maybe we can divide: a reviewer can write down the last file reviewed, next reviewer can start from the next file. |
refack
left a comment
There was a problem hiding this comment.
Almost went over all.
A few nits, some suggestions, and request to change path manipulation to path.join
There was a problem hiding this comment.
There are many such things in the tests. Should we address them in this PR?
There was a problem hiding this comment.
I don't think a path.join is important here, node modules always use / (so it's not an OS compatibility concern). The main advantage of path.join is that it abstracts joining complex paths, for concatenating two strings / should be fine.
That said, if this view is contested - we can just leave it as is in the PR.
There was a problem hiding this comment.
IMHO if we're touching this, so might as well "fix" it. There are multiple path concatenations done as strings, I feel they should all be changed, as path.join is semantically different, even if string concat works.
There was a problem hiding this comment.
It would be ~300 re-editions in the PR...
There was a problem hiding this comment.
Your call @vsemozhetbyt if you have the energy do it. I'll review it.
If you say not this PR I'll retract those comments.
There was a problem hiding this comment.
I am in doubt if there is a minimum consensus for this. If there are 2-3 +1 and no strong -1, I can try to refactor with path.join().
There was a problem hiding this comment.
Like James and Benjamin, I’m fine with leaving this as-is. Leaving path.join() refactors for a later PR sounds good to me. (If there’s consensus they should happen.)
There was a problem hiding this comment.
Yep, seems like a job for a separate PR.
There was a problem hiding this comment.
+0
personally I'd rather you define as vars then do this trick
constmsg_json=JSON.stringify(message);constid_json=JSON.stringify(this.messages_[id]);assert(message['result'],`${msg_json} (response to ${id_json})`);There was a problem hiding this comment.
I've created some new variables if this improved many places per file. But I also tried not to be too creative to not overload the diff.
There was a problem hiding this comment.
not a big fan of the trick... And otherwise you can't fit it in one line...
There was a problem hiding this comment.
+1 to @refack's suggestion, I think it definitely improves the readability.
There was a problem hiding this comment.
const s = this.messages_.map(m => m.id).join(', ');
There was a problem hiding this comment.
The same: I would abstain from refactoring too deep: this will make reviewing and testing a lot more difficult.
There was a problem hiding this comment.
Then I say, leave it as is, comment with TODO
There was a problem hiding this comment.
+1 to @refack's suggestion again. While you're here you might as well simplify, and it's a simple atomic change (so not too painful to review).
There was a problem hiding this comment.
If using map, no need for substring
There was a problem hiding this comment.
-1
IMHO doesn't improve readability.
Maybe:
constexpectedWhite=`${expected.slice(0,60)}\u0020${expected.slice(60,120)}\u0020${expected.slice(120,180)}\u0020${expected.slice(180,240)}\u0020${expected.slice(240,300)}${expected.slice(300,360)}`;There was a problem hiding this comment.
This may not be linted (indents).
There was a problem hiding this comment.
Definitely not a fan of multiline string literals. An array with a join might be an even better option.
constexpectedWrite=[expected.slice(0,60),expected.slice(60,120),expected.slice(120,180),expected.slice(180,240),expected.slice(240,300),expected.slice(300,360)].join(' \n')+'/n';There was a problem hiding this comment.
+-0
IMHO change the whole assembly to [].push(x).join(' ')
refack
commented
Apr 29, 2017
That's a huge PR indeed |
vsemozhetbyt
commented
Apr 29, 2017
I've reverted changes in the |
I don't know what to do. To divide this PR in small ones, I lack criterions (by files number? by tests topics? other?). And I understand that other collaborators may not have my 2 free days to review all the changes (diff is very slow in addition). Feel free to say to close, I shall not consider this as a waste of time, this was a useful experience in many respects for me) |
refack
commented
Apr 29, 2017
IMHO Keep it. It's done, it's good. I'll go over it all. |
refack
commented
Apr 29, 2017
Removed requests to hoist stuff to |
vsemozhetbyt
commented
Apr 30, 2017
O my) Conflicts resolved. New CI: https://ci.nodejs.org/job/node-test-pull-request/7758/ |
vsemozhetbyt
commented
May 5, 2017
Some new conflicts resolved. Hopefully, the last CI: https://ci.nodejs.org/job/node-test-pull-request/7891/ |
vsemozhetbyt
commented
May 5, 2017
Landed in 8b76c3e Sorry for all the conflicts it may cause... |
PR-URL: nodejs#12735 Refs: nodejs#12455 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
gibfahn
commented
Jun 18, 2017
@vsemozhetbyt do you have the patience to backport this to |
vsemozhetbyt
commented
Jun 18, 2017
@gibfahn I can try, but will anybody have the time to review? |
gibfahn
commented
Jun 18, 2017
If you raise the PR I promise to review 😁 . Feel free to assign it to me. |
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
test
Refs: #12455
This is not an exhaustive deliverance from all string concatenations: if a result looked too ugly and messy, I've abstained to change, so some concatenations still remain. I am not sure if we should to add
prefer-template: errorto test.eslintrc.yaml, so I've also abstained from proposing, but let me know if this is discussable.Concerning reviews: #12735 (comment)
test/common.jsonly)