Skip to content

Commit

Permalink
lib,test: remove yoda statements
Browse files Browse the repository at this point in the history
PR-URL: #18746
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
BridgeAR authored and addaleax committed Mar 5, 2018
1 parent a938e52 commit db8d197
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 29 deletions.
2 changes: 1 addition & 1 deletion lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,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');
Expand Down
30 changes: 15 additions & 15 deletions lib/internal/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions lib/internal/streams/legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/common/inspector-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-dns-multi-channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ for (const { socket, reply } of servers) {
}));

socket.bind(0, common.mustCall(() => {
if (0 === --waiting) ready();
if (--waiting === 0) ready();
}));
}

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-watch-recursive.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-net-pingpong.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-net-server-max-connections.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-tls-pause.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/pummel/test-net-throttle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
2 changes: 1 addition & 1 deletion test/pummel/test-next-tick-infinite-calls.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}());

Expand Down

0 comments on commit db8d197

Please sign in to comment.