From 2bfed5b9aabaa2a5ae3afeb236b6ce813752619d Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Fri, 2 Mar 2018 02:44:18 +0000 Subject: [PATCH] lib,test: remove yoda statements --- lib/_stream_readable.js | 2 +- lib/internal/readline.js | 30 +++++++++---------- lib/internal/streams/legacy.js | 6 ++-- test/common/inspector-helper.js | 4 +-- test/parallel/test-dns-multi-channel.js | 2 +- test/parallel/test-fs-watch-recursive.js | 2 +- test/parallel/test-net-pingpong.js | 2 +- .../test-net-server-max-connections.js | 2 +- test/parallel/test-tls-pause.js | 2 +- test/pummel/test-net-throttle.js | 2 +- test/pummel/test-next-tick-infinite-calls.js | 2 +- 11 files changed, 27 insertions(+), 29 deletions(-) diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 5cdc0864a0e1eb..ba231ccda903c1 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -838,7 +838,7 @@ function resume_(stream, state) { Readable.prototype.pause = function() { debug('call pause flowing=%j', this._readableState.flowing); - if (false !== this._readableState.flowing) { + if (this._readableState.flowing !== false) { debug('pause'); this._readableState.flowing = false; this.emit('pause'); diff --git a/lib/internal/readline.js b/lib/internal/readline.js index e3d3007a75c645..979e62090b3b1d 100644 --- a/lib/internal/readline.js +++ b/lib/internal/readline.js @@ -87,33 +87,33 @@ if (process.binding('config').hasIntl) { if ( code >= 0x1100 && ( code <= 0x115f || // Hangul Jamo - 0x2329 === code || // LEFT-POINTING ANGLE BRACKET - 0x232a === code || // RIGHT-POINTING ANGLE BRACKET + code === 0x2329 || // LEFT-POINTING ANGLE BRACKET + code === 0x232a || // RIGHT-POINTING ANGLE BRACKET // CJK Radicals Supplement .. Enclosed CJK Letters and Months - (0x2e80 <= code && code <= 0x3247 && code !== 0x303f) || + code >= 0x2e80 && code <= 0x3247 && code !== 0x303f || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A - 0x3250 <= code && code <= 0x4dbf || + code >= 0x3250 && code <= 0x4dbf || // CJK Unified Ideographs .. Yi Radicals - 0x4e00 <= code && code <= 0xa4c6 || + code >= 0x4e00 && code <= 0xa4c6 || // Hangul Jamo Extended-A - 0xa960 <= code && code <= 0xa97c || + code >= 0xa960 && code <= 0xa97c || // Hangul Syllables - 0xac00 <= code && code <= 0xd7a3 || + code >= 0xac00 && code <= 0xd7a3 || // CJK Compatibility Ideographs - 0xf900 <= code && code <= 0xfaff || + code >= 0xf900 && code <= 0xfaff || // Vertical Forms - 0xfe10 <= code && code <= 0xfe19 || + code >= 0xfe10 && code <= 0xfe19 || // CJK Compatibility Forms .. Small Form Variants - 0xfe30 <= code && code <= 0xfe6b || + code >= 0xfe30 && code <= 0xfe6b || // Halfwidth and Fullwidth Forms - 0xff01 <= code && code <= 0xff60 || - 0xffe0 <= code && code <= 0xffe6 || + code >= 0xff01 && code <= 0xff60 || + code >= 0xffe0 && code <= 0xffe6 || // Kana Supplement - 0x1b000 <= code && code <= 0x1b001 || + code >= 0x1b000 && code <= 0x1b001 || // Enclosed Ideographic Supplement - 0x1f200 <= code && code <= 0x1f251 || + code >= 0x1f200 && code <= 0x1f251 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane - 0x20000 <= code && code <= 0x3fffd + code >= 0x20000 && code <= 0x3fffd ) ) { return true; diff --git a/lib/internal/streams/legacy.js b/lib/internal/streams/legacy.js index 3242b15eabdb0d..9790696bfc7131 100644 --- a/lib/internal/streams/legacy.js +++ b/lib/internal/streams/legacy.js @@ -12,10 +12,8 @@ Stream.prototype.pipe = function(dest, options) { var source = this; function ondata(chunk) { - if (dest.writable) { - if (false === dest.write(chunk) && source.pause) { - source.pause(); - } + if (dest.writable && dest.write(chunk) === false && source.pause) { + source.pause(); } } diff --git a/test/common/inspector-helper.js b/test/common/inspector-helper.js index de0723933f573a..7590cfc104b70a 100644 --- a/test/common/inspector-helper.js +++ b/test/common/inspector-helper.js @@ -241,7 +241,7 @@ class InspectorSession { } _isBreakOnLineNotification(message, line, expectedScriptPath) { - if ('Debugger.paused' === message.method) { + if (message.method === 'Debugger.paused') { const callFrame = message.params.callFrames[0]; const location = callFrame.location; const scriptPath = this._scriptsIdsByUrl.get(location.scriptId); @@ -264,7 +264,7 @@ class InspectorSession { _matchesConsoleOutputNotification(notification, type, values) { if (!Array.isArray(values)) values = [ values ]; - if ('Runtime.consoleAPICalled' === notification.method) { + if (notification.method === 'Runtime.consoleAPICalled') { const params = notification.params; if (params.type === type) { let i = 0; diff --git a/test/parallel/test-dns-multi-channel.js b/test/parallel/test-dns-multi-channel.js index 63e82c3ed791a4..bd88fe0b24fc75 100644 --- a/test/parallel/test-dns-multi-channel.js +++ b/test/parallel/test-dns-multi-channel.js @@ -31,7 +31,7 @@ for (const { socket, reply } of servers) { })); socket.bind(0, common.mustCall(() => { - if (0 === --waiting) ready(); + if (--waiting === 0) ready(); })); } diff --git a/test/parallel/test-fs-watch-recursive.js b/test/parallel/test-fs-watch-recursive.js index 82d87aa2ecbb93..4985ece0e0ec15 100644 --- a/test/parallel/test-fs-watch-recursive.js +++ b/test/parallel/test-fs-watch-recursive.js @@ -24,7 +24,7 @@ const watcher = fs.watch(testDir, { recursive: true }); let watcherClosed = false; watcher.on('change', function(event, filename) { - assert.ok('change' === event || 'rename' === event); + assert.ok(event === 'change' || event === 'rename'); // Ignore stale events generated by mkdir and other tests if (filename !== relativePathOne) diff --git a/test/parallel/test-net-pingpong.js b/test/parallel/test-net-pingpong.js index 9fc59db4e2ff2f..4ab36fc23957b5 100644 --- a/test/parallel/test-net-pingpong.js +++ b/test/parallel/test-net-pingpong.js @@ -53,7 +53,7 @@ function pingPongTest(port, host) { // Since we never queue data (we're always waiting for the PING // before sending a pong) the writeQueueSize should always be less // than one message. - assert.ok(0 <= socket.bufferSize && socket.bufferSize <= 4); + assert.ok(socket.bufferSize >= 0 && socket.bufferSize <= 4); assert.strictEqual(socket.writable, true); assert.strictEqual(socket.readable, true); diff --git a/test/parallel/test-net-server-max-connections.js b/test/parallel/test-net-server-max-connections.js index c73efb3c1ef406..a711e5295be8bf 100644 --- a/test/parallel/test-net-server-max-connections.js +++ b/test/parallel/test-net-server-max-connections.js @@ -88,7 +88,7 @@ function makeConnection(index) { c.on('data', function(b) { gotData = true; - assert.ok(0 < b.length); + assert.ok(b.length > 0); }); c.on('error', function(e) { diff --git a/test/parallel/test-tls-pause.js b/test/parallel/test-tls-pause.js index a6130cd4331f62..e246acff807a91 100644 --- a/test/parallel/test-tls-pause.js +++ b/test/parallel/test-tls-pause.js @@ -60,7 +60,7 @@ server.listen(0, common.mustCall(() => { console.error('sending'); const ret = client.write(Buffer.allocUnsafe(bufSize)); console.error(`write => ${ret}`); - if (false !== ret) { + if (ret !== false) { console.error('write again'); sent += bufSize; assert.ok(sent < 100 * 1024 * 1024); // max 100MB diff --git a/test/pummel/test-net-throttle.js b/test/pummel/test-net-throttle.js index ea48aa74d2f2b8..a08ed85ccd41bb 100644 --- a/test/pummel/test-net-throttle.js +++ b/test/pummel/test-net-throttle.js @@ -39,7 +39,7 @@ const server = net.createServer(function(connection) { connection.write(body.slice(part_N, 2 * part_N)); assert.strictEqual(false, connection.write(body.slice(2 * part_N, N))); console.log(`bufferSize: ${connection.bufferSize}`, 'expecting', N); - assert.ok(0 <= connection.bufferSize && + assert.ok(connection.bufferSize >= 0 && connection.writableLength <= N); connection.end(); }); diff --git a/test/pummel/test-next-tick-infinite-calls.js b/test/pummel/test-next-tick-infinite-calls.js index b72d18fa40c23e..5ee44076dcc2f3 100644 --- a/test/pummel/test-next-tick-infinite-calls.js +++ b/test/pummel/test-next-tick-infinite-calls.js @@ -28,7 +28,7 @@ let complete = 0; // FATAL ERROR: JS Allocation failed - process out of memory // if the depth counter doesn't clear the nextTickQueue properly. (function runner() { - if (1e8 > ++complete) + if (++complete < 1e8) process.nextTick(runner); }());