From 359766b2c3f686fe4ebe5cd6bc4e99280e09b450 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 27 Nov 2019 22:56:21 -0800 Subject: benchmark,doc,lib,test: prepare for padding lint rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Upcoming lint rule will require a blank line between consecutive functions. Add it in the places where we don't have it already. PR-URL: https://github.com/nodejs/node/pull/30696 Reviewed-By: Michaƫl Zasso Reviewed-By: Gireesh Punathil Reviewed-By: Trivikram Kamat Reviewed-By: Gus Caplan Reviewed-By: Anna Henningsen Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig Reviewed-By: Denys Otrishko Reviewed-By: Luigi Pinca --- benchmark/process/next-tick-breadth-args.js | 3 +++ benchmark/process/next-tick-depth-args.js | 3 +++ benchmark/timers/set-immediate-breadth-args.js | 2 ++ benchmark/timers/set-immediate-depth-args.js | 2 ++ benchmark/timers/timers-breadth-args.js | 3 +++ benchmark/timers/timers-timeout-nexttick.js | 2 ++ benchmark/timers/timers-timeout-pooled.js | 1 + benchmark/timers/timers-timeout-unpooled.js | 1 + doc/api/assert.md | 2 ++ lib/_stream_writable.js | 3 +++ lib/internal/assert.js | 1 + lib/internal/js_stream_socket.js | 4 ++++ lib/internal/process/task_queues.js | 1 + lib/internal/process/worker_thread_only.js | 1 + lib/repl.js | 1 + test/es-module/test-esm-data-urls.js | 1 + test/parallel/test-event-emitter-listeners.js | 3 +++ test/parallel/test-event-emitter-remove-listeners.js | 1 + test/parallel/test-fs-realpath.js | 1 + test/parallel/test-http-unix-socket-keep-alive.js | 1 + test/parallel/test-repl-options.js | 1 + test/parallel/test-stream-transform-flush-data.js | 1 + test/parallel/test-tls-fast-writing.js | 1 + test/parallel/test-util-promisify.js | 1 + test/pummel/test-fs-watch-file.js | 1 + test/sequential/test-inspector-port-cluster.js | 1 + 26 files changed, 43 insertions(+) diff --git a/benchmark/process/next-tick-breadth-args.js b/benchmark/process/next-tick-breadth-args.js index f7f9882c87..03651dbdbb 100644 --- a/benchmark/process/next-tick-breadth-args.js +++ b/benchmark/process/next-tick-breadth-args.js @@ -13,16 +13,19 @@ function main({ n }) { if (j === n) bench.end(n); } + function cb2(arg1, arg2) { j++; if (j === n) bench.end(n); } + function cb3(arg1, arg2, arg3) { j++; if (j === n) bench.end(n); } + function cb4(arg1, arg2, arg3, arg4) { j++; if (j === n) diff --git a/benchmark/process/next-tick-depth-args.js b/benchmark/process/next-tick-depth-args.js index d9fc37887e..7c6b2346fd 100644 --- a/benchmark/process/next-tick-depth-args.js +++ b/benchmark/process/next-tick-depth-args.js @@ -20,6 +20,7 @@ function main({ n }) { } else bench.end(n); } + function cb3(arg1, arg2, arg3) { if (--counter) { if (counter % 4 === 0) @@ -33,6 +34,7 @@ function main({ n }) { } else bench.end(n); } + function cb2(arg1, arg2) { if (--counter) { if (counter % 4 === 0) @@ -46,6 +48,7 @@ function main({ n }) { } else bench.end(n); } + function cb1(arg1) { if (--counter) { if (counter % 4 === 0) diff --git a/benchmark/timers/set-immediate-breadth-args.js b/benchmark/timers/set-immediate-breadth-args.js index 518ed90e58..6d556f9186 100644 --- a/benchmark/timers/set-immediate-breadth-args.js +++ b/benchmark/timers/set-immediate-breadth-args.js @@ -12,7 +12,9 @@ function main({ n }) { }); function cb1(arg1) {} + function cb2(arg1, arg2) {} + function cb3(arg1, arg2, arg3) {} bench.start(); diff --git a/benchmark/timers/set-immediate-depth-args.js b/benchmark/timers/set-immediate-depth-args.js index d8eb5c409a..a01a400d5f 100644 --- a/benchmark/timers/set-immediate-depth-args.js +++ b/benchmark/timers/set-immediate-depth-args.js @@ -21,6 +21,7 @@ function main({ n }) { setImmediate(cb1, n); } } + function cb2(n, arg2) { if (--n) { if (n % 3 === 0) @@ -31,6 +32,7 @@ function main({ n }) { setImmediate(cb1, n); } } + function cb1(n) { if (--n) { if (n % 3 === 0) diff --git a/benchmark/timers/timers-breadth-args.js b/benchmark/timers/timers-breadth-args.js index 5f91603caa..bdb3adbbec 100644 --- a/benchmark/timers/timers-breadth-args.js +++ b/benchmark/timers/timers-breadth-args.js @@ -12,16 +12,19 @@ function main({ n }) { if (j === n) bench.end(n); } + function cb2(arg1, arg2) { j++; if (j === n) bench.end(n); } + function cb3(arg1, arg2, arg3) { j++; if (j === n) bench.end(n); } + function cb4(arg1, arg2, arg3, arg4) { j++; if (j === n) diff --git a/benchmark/timers/timers-timeout-nexttick.js b/benchmark/timers/timers-timeout-nexttick.js index 781e505ae4..638d8aec14 100644 --- a/benchmark/timers/timers-timeout-nexttick.js +++ b/benchmark/timers/timers-timeout-nexttick.js @@ -19,9 +19,11 @@ function main({ n }) { function cb() { process.nextTick(counter); } + function cb2() { process.nextTick(counter); } + function counter() { count++; if (count === n) diff --git a/benchmark/timers/timers-timeout-pooled.js b/benchmark/timers/timers-timeout-pooled.js index d34080fa66..1cdae07dc9 100644 --- a/benchmark/timers/timers-timeout-pooled.js +++ b/benchmark/timers/timers-timeout-pooled.js @@ -20,6 +20,7 @@ function main({ n }) { if (count === n) bench.end(n); } + function cb2() { count++; if (count === n) diff --git a/benchmark/timers/timers-timeout-unpooled.js b/benchmark/timers/timers-timeout-unpooled.js index 19f0f6a4af..fecb73a360 100644 --- a/benchmark/timers/timers-timeout-unpooled.js +++ b/benchmark/timers/timers-timeout-unpooled.js @@ -20,6 +20,7 @@ function main({ n }) { if (count === n) bench.end(n); } + function cb2() { count++; if (count === n) diff --git a/doc/api/assert.md b/doc/api/assert.md index fa9416ea73..b0c8c378e6 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -1266,9 +1266,11 @@ a string as the second argument gets considered: function throwingFirst() { throw new Error('First'); } + function throwingSecond() { throw new Error('Second'); } + function notThrowing() {} // The second argument is a string and the input function threw an Error. diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index be83320550..cf498e7d93 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -646,6 +646,7 @@ function needFinish(state) { !state.finished && !state.writing); } + function callFinal(stream, state) { stream._final((err) => { state.pendingcb--; @@ -658,6 +659,7 @@ function callFinal(stream, state) { } }); } + function prefinish(stream, state) { if (!state.prefinished && !state.finalCalled) { if (typeof stream._final === 'function' && !state.destroyed) { @@ -736,6 +738,7 @@ function onFinished(stream, state, cb) { stream.emit('error', err); } } + function onfinish() { stream.removeListener('finish', onfinish); stream.removeListener('error', onerror); diff --git a/lib/internal/assert.js b/lib/internal/assert.js index b62b2753c0..0f52faab4b 100644 --- a/lib/internal/assert.js +++ b/lib/internal/assert.js @@ -7,6 +7,7 @@ function lazyError() { } return error; } + function assert(value, message) { if (!value) { const ERR_INTERNAL_ASSERTION = lazyError(); diff --git a/lib/internal/js_stream_socket.js b/lib/internal/js_stream_socket.js index cdf6cd7ac7..7c35a55b1c 100644 --- a/lib/internal/js_stream_socket.js +++ b/lib/internal/js_stream_socket.js @@ -14,9 +14,13 @@ const kCurrentShutdownRequest = Symbol('kCurrentShutdownRequest'); const kPendingShutdownRequest = Symbol('kPendingShutdownRequest'); function isClosing() { return this[owner_symbol].isClosing(); } + function onreadstart() { return this[owner_symbol].readStart(); } + function onreadstop() { return this[owner_symbol].readStop(); } + function onshutdown(req) { return this[owner_symbol].doShutdown(req); } + function onwrite(req, bufs) { return this[owner_symbol].doWrite(req, bufs); } /* This class serves as a wrapper for when the C++ side of Node wants access diff --git a/lib/internal/process/task_queues.js b/lib/internal/process/task_queues.js index 1abbfa78f8..8b2d2d808a 100644 --- a/lib/internal/process/task_queues.js +++ b/lib/internal/process/task_queues.js @@ -49,6 +49,7 @@ const kHasTickScheduled = 0; function hasTickScheduled() { return tickInfo[kHasTickScheduled] === 1; } + function setHasTickScheduled(value) { tickInfo[kHasTickScheduled] = value ? 1 : 0; } diff --git a/lib/internal/process/worker_thread_only.js b/lib/internal/process/worker_thread_only.js index b6529e4344..920f0f7726 100644 --- a/lib/internal/process/worker_thread_only.js +++ b/lib/internal/process/worker_thread_only.js @@ -16,6 +16,7 @@ function lazyWorkerStdio() { if (!workerStdio) workerStdio = createWorkerStdio(); return workerStdio; } + function createStdioGetters() { return { getStdout() { return lazyWorkerStdio().stdout; }, diff --git a/lib/repl.js b/lib/repl.js index bac427bd5a..e304bc2e77 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -273,6 +273,7 @@ function REPLServer(prompt, function pause() { paused = true; } + function unpause() { if (!paused) return; paused = false; diff --git a/test/es-module/test-esm-data-urls.js b/test/es-module/test-esm-data-urls.js index 7efe7a1199..30ae55d01f 100644 --- a/test/es-module/test-esm-data-urls.js +++ b/test/es-module/test-esm-data-urls.js @@ -4,6 +4,7 @@ const assert = require('assert'); function createURL(mime, body) { return `data:${mime},${body}`; } + function createBase64URL(mime, body) { return `data:${mime};base64,${Buffer.from(body).toString('base64')}`; } diff --git a/test/parallel/test-event-emitter-listeners.js b/test/parallel/test-event-emitter-listeners.js index 52a108ad0e..eb1da829c9 100644 --- a/test/parallel/test-event-emitter-listeners.js +++ b/test/parallel/test-event-emitter-listeners.js @@ -26,10 +26,13 @@ const assert = require('assert'); const events = require('events'); function listener() {} + function listener2() {} + function listener3() { return 0; } + function listener4() { return 1; } diff --git a/test/parallel/test-event-emitter-remove-listeners.js b/test/parallel/test-event-emitter-remove-listeners.js index 925f828f93..8b9d621560 100644 --- a/test/parallel/test-event-emitter-remove-listeners.js +++ b/test/parallel/test-event-emitter-remove-listeners.js @@ -25,6 +25,7 @@ const assert = require('assert'); const EventEmitter = require('events'); function listener1() {} + function listener2() {} { diff --git a/test/parallel/test-fs-realpath.js b/test/parallel/test-fs-realpath.js index 8b3bb68967..2642f51842 100644 --- a/test/parallel/test-fs-realpath.js +++ b/test/parallel/test-fs-realpath.js @@ -490,6 +490,7 @@ function test_abs_with_kids(realpath, realpathSync, cb) { try { fs.rmdirSync(root + folder); } catch {} }); } + function setup() { cleanup(); ['', diff --git a/test/parallel/test-http-unix-socket-keep-alive.js b/test/parallel/test-http-unix-socket-keep-alive.js index 11b3d9b392..fd3c6a7b16 100644 --- a/test/parallel/test-http-unix-socket-keep-alive.js +++ b/test/parallel/test-http-unix-socket-keep-alive.js @@ -27,6 +27,7 @@ function asyncLoop(fn, times, cb) { } }); } + function makeKeepAliveRequest(cb) { http.get({ socketPath: common.PIPE, diff --git a/test/parallel/test-repl-options.js b/test/parallel/test-repl-options.js index cbb5a9a6e5..9f40c6279b 100644 --- a/test/parallel/test-repl-options.js +++ b/test/parallel/test-repl-options.js @@ -62,6 +62,7 @@ assert.strictEqual(r1.useColors, r1.rli.terminal); // 2 function writer() {} + function evaler() {} const r2 = repl.start({ input: stream, diff --git a/test/parallel/test-stream-transform-flush-data.js b/test/parallel/test-stream-transform-flush-data.js index 6d6aedd3a7..51e2c8bc52 100644 --- a/test/parallel/test-stream-transform-flush-data.js +++ b/test/parallel/test-stream-transform-flush-data.js @@ -12,6 +12,7 @@ const expected = 'asdf'; function _transform(d, e, n) { n(); } + function _flush(n) { n(null, expected); } diff --git a/test/parallel/test-tls-fast-writing.js b/test/parallel/test-tls-fast-writing.js index af40cc33ba..4718acf285 100644 --- a/test/parallel/test-tls-fast-writing.js +++ b/test/parallel/test-tls-fast-writing.js @@ -68,6 +68,7 @@ server.listen(0, function() { process.exit(0); write(); } + function write() { // This needs to return false eventually while (false !== conn.write(chunk)); diff --git a/test/parallel/test-util-promisify.js b/test/parallel/test-util-promisify.js index 0bece0df42..77601eae6d 100644 --- a/test/parallel/test-util-promisify.js +++ b/test/parallel/test-util-promisify.js @@ -26,6 +26,7 @@ const stat = promisify(fs.stat); { function fn() {} + function promisifedFn() {} fn[promisify.custom] = promisifedFn; assert.strictEqual(promisify(fn), promisifedFn); diff --git a/test/pummel/test-fs-watch-file.js b/test/pummel/test-fs-watch-file.js index 0d897bdc4a..ca8aecc872 100644 --- a/test/pummel/test-fs-watch-file.js +++ b/test/pummel/test-fs-watch-file.js @@ -86,6 +86,7 @@ assert.throws( fs.unwatchFile(filepathTwo, a); ++watchSeenTwo; } + function b() { fs.unwatchFile(filepathTwo, b); ++watchSeenTwo; diff --git a/test/sequential/test-inspector-port-cluster.js b/test/sequential/test-inspector-port-cluster.js index 7579f51dee..55a0d14906 100644 --- a/test/sequential/test-inspector-port-cluster.js +++ b/test/sequential/test-inspector-port-cluster.js @@ -205,6 +205,7 @@ function testRunnerMain() { }); }); } + function masterProcessMain() { const workers = JSON.parse(process.env.workers); const clusterSettings = JSON.parse(process.env.clusterSettings) || {}; -- cgit v1.2.3