From 3e588713cca2c1a032ef59e11a14772f94a53dcf Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 27 Nov 2019 22:56:21 -0800 Subject: [PATCH] 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 | 2 ++ 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, 42 insertions(+) diff --git a/benchmark/process/next-tick-breadth-args.js b/benchmark/process/next-tick-breadth-args.js index f7f9882c87e34b..03651dbdbb4eea 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 d9fc37887ec5a3..7c6b2346fd5fad 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 518ed90e58f476..6d556f9186b7c7 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 d8eb5c409a64e4..a01a400d5f4bc5 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 5f91603caa0a5c..bdb3adbbec6b7a 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 781e505ae41ea2..638d8aec149cd5 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 d34080fa668422..1cdae07dc98bdc 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 19f0f6a4af4d0d..fecb73a36013b0 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 6c324a0e381b21..2aeee28958ff10 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -1256,9 +1256,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 5edcbefbfde5c4..56206ece9b0436 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -623,6 +623,7 @@ function needFinish(state) { !state.finished && !state.writing); } + function callFinal(stream, state) { stream._final((err) => { state.pendingcb--; @@ -634,6 +635,7 @@ function callFinal(stream, state) { finishMaybe(stream, state); }); } + function prefinish(stream, state) { if (!state.prefinished && !state.finalCalled) { if (typeof stream._final === 'function' && !state.destroyed) { diff --git a/lib/internal/assert.js b/lib/internal/assert.js index b62b2753c0b907..0f52faab4bcf53 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 cdf6cd7ac7e5bd..7c35a55b1c9455 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 35578e54bb937c..3deebaaa076eb2 100644 --- a/lib/internal/process/task_queues.js +++ b/lib/internal/process/task_queues.js @@ -46,6 +46,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 b6529e43441679..920f0f77261bab 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 e0f20ff5bf0447..0007a3610ad319 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -259,6 +259,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 bc781b0363cc44..963f26c3e48bf2 100644 --- a/test/es-module/test-esm-data-urls.js +++ b/test/es-module/test-esm-data-urls.js @@ -5,6 +5,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 52a108ad0e29b6..eb1da829c95f21 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 925f828f93da36..8b9d6215601e9d 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 8b3bb689675dc3..2642f5184271b6 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 11b3d9b39264a4..fd3c6a7b1608ff 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 cbb5a9a6e580ec..9f40c6279bd64c 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 6d6aedd3a72bf8..51e2c8bc5254e3 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 af40cc33baeda0..4718acf2858499 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 0bece0df426b7b..77601eae6daa9d 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 7a8854860c15f1..4573c9a1b12204 100644 --- a/test/pummel/test-fs-watch-file.js +++ b/test/pummel/test-fs-watch-file.js @@ -89,6 +89,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 7579f51deeb598..55a0d149068ead 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) || {};