Skip to content

tools,test: var to const#13732

Merged
refack merged 7 commits intonodejs:masterfrom
BridgeAR:var-to-const
Jul 2, 2017
Merged

tools,test: var to const#13732
refack merged 7 commits intonodejs:masterfrom
BridgeAR:var-to-const

Conversation

@BridgeAR
Copy link
Member

@BridgeAR BridgeAR commented Jun 17, 2017

As far as I know using const is preferable in almost all situations, so this converts probably all var declarations to const, if possible.

If this is not what you want, I'm happy to close this again or split into smaller parts.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

tools,test

@nodejs-github-bot nodejs-github-bot added benchmark Issues and PRs related to the benchmark subsystem. buffer Issues and PRs related to the buffer subsystem. child_process Issues and PRs related to the child_process subsystem. cluster Issues and PRs related to the cluster subsystem. crypto Issues and PRs related to the crypto subsystem. dgram Issues and PRs related to the dgram subsystem / UDP. domain Issues and PRs related to the domain subsystem. v8 engine Issues and PRs related to the V8 dependency. labels Jun 17, 2017
@mscdex
Copy link
Contributor

mscdex commented Jun 17, 2017

Even though we're TurboFan by default now, I would still be cautious about permanent deopts when using const/let. You might want to at least run a make test-check-deopts | grep -ivP ' <(?:\/|SharedFunctionInfo)' and see what aborted/disabled optimizations shows up. Some are expected though, such as the deopts in domain and vm.

@BridgeAR
Copy link
Member Author

@mscdex I did that and there was no new constant deopt.

@mscdex
Copy link
Contributor

mscdex commented Jun 17, 2017

Actually I just checked current master and it looks like make test-check-deopts is broken again :-(

Typically you will see a lot of output with that command I gave, because tests tend to have a lot of deopts (although the grep ignores the content of those deopt messages it still prints the filenames).

EDIT: It looks like I was mistaken. I'm guessing I just haven't ran that since the switch to V8 5.9 and TurboFan by default. There's only about 6 perm deopts as of this writing and I believe they're all inside the tests themselves.

@vsemozhetbyt
Copy link
Contributor

@vsemozhetbyt vsemozhetbyt added test Issues and PRs related to the tests. tools Issues and PRs related to the tools directory. http Issues or PRs related to the http subsystem. stream Issues and PRs related to the stream subsystem. tls Issues and PRs related to the tls subsystem. console Issues and PRs related to the console subsystem. dns Issues and PRs related to the dns subsystem. events Issues and PRs related to the events subsystem / EventEmitter. fs Issues and PRs related to the fs subsystem / file system. https Issues or PRs related to the https subsystem. module Issues and PRs related to the module subsystem. process Issues and PRs related to the process subsystem. net Issues and PRs related to the net subsystem. path Issues and PRs related to the path subsystem. url Issues and PRs related to the legacy built-in url module. util Issues and PRs related to the built-in util module. querystring Issues and PRs related to the built-in querystring module. labels Jun 17, 2017
@gibfahn
Copy link
Member

gibfahn commented Jun 18, 2017

@gibfahn the prefer-const rule only changes let, not var.
I'll move the lib and benchmark parts out as you requested.

Yes, but we also have the no-var rule for tests.

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Jun 18, 2017

@gibfahn We had // eslint-disable-next-line no-var in that single place in test.

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems this line can be removed now.

Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

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

LGTM with @vsemozhetbyt's comment addressed.

@jasnell
Copy link
Member

jasnell commented Jun 19, 2017

While the code changes look good, I'd much rather the changes to each of the separate tools be in their own separate commits. On the off chance that we need to revert any particular item, it would make it significantly easier.

@refack
Copy link
Contributor

refack commented Jun 19, 2017

While the code changes look good, I'd much rather the changes to each of the separate tools be in their own separate commits. On the off chance that we need to revert any particular item, it would make it significantly easier.

@BridgeAR If I understand @jasnell correctly separate commits not PRs (not like we did for /libs/. Just saying...)

@BridgeAR
Copy link
Member Author

Comments addressed. I'm not to sure about the commit messages though.

@refack
Copy link
Contributor

refack commented Jun 19, 2017

Comments addressed. I'm not to sure about the commit messages though.

Personally I would do tools: TOOLNAME - var to const
But let's wait for further feedback.

@cjihrig
Copy link
Contributor

cjihrig commented Jun 19, 2017

Maybe even tools: change var to const in TOOLNAME (as long as it fits in 50 characters).

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion
const {li, in_license_block: lic} = paragraph;

Copy link
Contributor

Choose a reason for hiding this comment

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

const line_indent = Math.floor(line_strip_length / 2) * 2;

Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion:
module.exports = function({report, options:requiredModules})

@refack
Copy link
Contributor

refack commented Jun 19, 2017

About my suggestions, if we're churning, let's make some butter (or code better).
But wait for more feedback.

@BridgeAR
Copy link
Member Author

PTAL

I'd rebase and address the comments after getting some more feedback.

@BridgeAR
Copy link
Member Author

BridgeAR commented Jul 2, 2017

Rebased and comments addressed

@refack
Copy link
Contributor

refack commented Jul 2, 2017

Copy link
Contributor

Choose a reason for hiding this comment

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

something here fails the linter:

Running JS linter...
./node tools/jslint.js -j 2 -f tap -o test-eslint.tap \
	benchmark doc lib test tools
/usr/home/iojs/build/workspace/node-test-linter/tools/eslint/lib/rule-context.js:210
        this.eslint.report(
            ^

TypeError: Cannot read property 'eslint' of undefined
    at report (/usr/home/iojs/build/workspace/node-test-linter/tools/eslint/lib/rule-context.js:210:13)
    at /usr/home/iojs/build/workspace/node-test-linter/tools/eslint-rules/required-modules.js:79:11
    at Array.forEach (native)
    at Linter.Program:exit (/usr/home/iojs/build/workspace/node-test-linter/tools/eslint-rules/required-modules.js:78:24)
    at emitOne (events.js:101:20)
    at Linter.emit (events.js:188:7)
    at NodeEventGenerator.applySelector (/usr/home/iojs/build/workspace/node-test-linter/tools/eslint/lib/util/node-event-generator.js:265:26)
    at NodeEventGenerator.applySelectors (/usr/home/iojs/build/workspace/node-test-linter/tools/eslint/lib/util/node-event-generator.js:294:22)
    at NodeEventGenerator.leaveNode (/usr/home/iojs/build/workspace/node-test-linter/tools/eslint/lib/util/node-event-generator.js:317:14)
    at CodePathAnalyzer.leaveNode (/usr/home/iojs/build/workspace/node-test-linter/tools/eslint/lib/code-path-analysis/code-path-analyzer.js:622:23)
    at Traverser.leave (/usr/home/iojs/build/workspace/node-test-linter/tools/eslint/lib/linter.js:925:36)
gmake: *** [Makefile:876: jslint-ci] Error 2
/usr/home/iojs/build/workspace/node-test-linter/tools/eslint/lib/rule-context.js:210
        this.eslint.report(
            ^

https://ci.nodejs.org/job/node-test-linter/10203/console

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@refack
Copy link
Contributor

refack commented Jul 2, 2017

BridgeAR added 7 commits July 2, 2017 19:26
PR-URL: nodejs#13732
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
PR-URL: nodejs#13732
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
PR-URL: nodejs#13732
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
PR-URL: nodejs#13732
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
PR-URL: nodejs#13732
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
PR-URL: nodejs#13732
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
PR-URL: nodejs#13732
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
@refack
Copy link
Contributor

refack commented Jul 2, 2017

@refack
Copy link
Contributor

refack commented Jul 2, 2017

@nodejs/build this PR touches some of the tools that are not covered by the tests, anyway to verify they work as expected also where the are needed?

@addaleax addaleax mentioned this pull request Jul 3, 2017
@joaocgreis
Copy link
Member

@refack If I'm not missing anything, this only influences make doc and and the licence displayed by the MSI (since common and eslint run in CI). https://nodejs.org/download/nightly/v9.0.0-nightly20170703fe730d34ce/ already has this change, the docs folder and the MSI seem to have been correctly generated.

@refack
Copy link
Contributor

refack commented Jul 4, 2017

@refack If I'm not missing anything, this only influences make doc and and the licence displayed by the MSI (since common and eslint run in CI). https://nodejs.org/download/nightly/v9.0.0-nightly20170703fe730d34ce/ already has this change, the docs folder and the MSI seem to have been correctly generated.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib / src Issues and PRs related to general changes in the lib or src directory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants