From b533fb3508009e5f567cc776daba8fbf665386a6 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Wed, 8 Apr 2020 18:58:03 +0200 Subject: tools: enable no-else-return lint rule Refs: https://github.com/nodejs/node/pull/32644 Refs: https://github.com/nodejs/node/pull/32662 PR-URL: https://github.com/nodejs/node/pull/32667 Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat --- test/common/dns.js | 17 ++++++++--------- test/common/index.js | 8 +++----- test/common/inspector-helper.js | 3 +-- test/common/shared-lib-util.js | 3 +-- test/common/wpt.js | 30 ++++++++++++++---------------- 5 files changed, 27 insertions(+), 34 deletions(-) (limited to 'test/common') diff --git a/test/common/dns.js b/test/common/dns.js index 37f80dde027..d8a703cc53b 100644 --- a/test/common/dns.js +++ b/test/common/dns.js @@ -36,16 +36,15 @@ function readDomainFromPacket(buffer, offset) { nread: 1 + length + nread, domain: domain ? `${chunk}.${domain}` : chunk }; - } else { - // Pointer to another part of the packet. - assert.strictEqual(length & 0xC0, 0xC0); - // eslint-disable-next-line space-infix-ops, space-unary-ops - const pointeeOffset = buffer.readUInt16BE(offset) &~ 0xC000; - return { - nread: 2, - domain: readDomainFromPacket(buffer, pointeeOffset) - }; } + // Pointer to another part of the packet. + assert.strictEqual(length & 0xC0, 0xC0); + // eslint-disable-next-line space-infix-ops, space-unary-ops + const pointeeOffset = buffer.readUInt16BE(offset) &~ 0xC000; + return { + nread: 2, + domain: readDomainFromPacket(buffer, pointeeOffset) + }; } function parseDNSPacket(buffer) { diff --git a/test/common/index.js b/test/common/index.js index a7528749926..6343425858d 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -309,10 +309,9 @@ function runCallChecks(exitCode) { if ('minimum' in context) { context.messageSegment = `at least ${context.minimum}`; return context.actual < context.minimum; - } else { - context.messageSegment = `exactly ${context.exact}`; - return context.actual !== context.exact; } + context.messageSegment = `exactly ${context.exact}`; + return context.actual !== context.exact; }); failed.forEach(function(context) { @@ -465,9 +464,8 @@ function nodeProcessAborted(exitCode, signal) { // the expected exit codes or signals. if (signal !== null) { return expectedSignals.includes(signal); - } else { - return expectedExitCodes.includes(exitCode); } + return expectedExitCodes.includes(exitCode); } function isAlive(pid) { diff --git a/test/common/inspector-helper.js b/test/common/inspector-helper.js index d430137746d..77d7928af13 100644 --- a/test/common/inspector-helper.js +++ b/test/common/inspector-helper.js @@ -217,9 +217,8 @@ class InspectorSession { return Promise .all(commands.map((command) => this._sendMessage(command))) .then(() => {}); - } else { - return this._sendMessage(commands); } + return this._sendMessage(commands); } waitForNotification(methodOrPredicate, description) { diff --git a/test/common/shared-lib-util.js b/test/common/shared-lib-util.js index e522a71b474..9f891a6043e 100644 --- a/test/common/shared-lib-util.js +++ b/test/common/shared-lib-util.js @@ -36,9 +36,8 @@ function getSharedLibPath() { return path.join(kExecPath, 'node.dll'); } else if (common.isOSX) { return path.join(kExecPath, `libnode.${kShlibSuffix}`); - } else { - return path.join(kExecPath, 'lib.target', `libnode.${kShlibSuffix}`); } + return path.join(kExecPath, 'lib.target', `libnode.${kShlibSuffix}`); } // Get the binary path of stack frames. diff --git a/test/common/wpt.js b/test/common/wpt.js index e33d0c86cc7..e79bd66b370 100644 --- a/test/common/wpt.js +++ b/test/common/wpt.js @@ -73,9 +73,8 @@ class ResourceLoader { text() { return data.toString(); } }; }); - } else { - return fs.readFileSync(file, 'utf8'); } + return fs.readFileSync(file, 'utf8'); } } @@ -603,24 +602,23 @@ class WPTRunner { const matches = code.match(/\/\/ META: .+/g); if (!matches) { return {}; - } else { - const result = {}; - for (const match of matches) { - const parts = match.match(/\/\/ META: ([^=]+?)=(.+)/); - const key = parts[1]; - const value = parts[2]; - if (key === 'script') { - if (result[key]) { - result[key].push(value); - } else { - result[key] = [value]; - } + } + const result = {}; + for (const match of matches) { + const parts = match.match(/\/\/ META: ([^=]+?)=(.+)/); + const key = parts[1]; + const value = parts[2]; + if (key === 'script') { + if (result[key]) { + result[key].push(value); } else { - result[key] = value; + result[key] = [value]; } + } else { + result[key] = value; } - return result; } + return result; } buildQueue() { -- cgit v1.2.3