Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLuigi Pinca <luigipinca@gmail.com>2020-04-08 19:58:03 +0300
committerLuigi Pinca <luigipinca@gmail.com>2020-05-16 07:42:16 +0300
commitb533fb3508009e5f567cc776daba8fbf665386a6 (patch)
tree4b7bbfdc2feeee93b855b01abd2e56f499b70d0a /test
parent1cb80d1e0590eeb3daf495bddfcf5237a99aa9b7 (diff)
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 <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js3
-rw-r--r--test/async-hooks/init-hooks.js13
-rw-r--r--test/common/dns.js17
-rw-r--r--test/common/index.js8
-rw-r--r--test/common/inspector-helper.js3
-rw-r--r--test/common/shared-lib-util.js3
-rw-r--r--test/common/wpt.js30
-rw-r--r--test/parallel/test-fs-mkdir-mode-mask.js5
-rw-r--r--test/parallel/test-fs-utimes.js15
-rw-r--r--test/parallel/test-net-pingpong.js5
-rw-r--r--test/parallel/test-stream2-readable-empty-buffer-no-eof.js3
-rw-r--r--test/parallel/test-trace-events-api.js3
-rw-r--r--test/pummel/test-net-pingpong.js3
13 files changed, 47 insertions, 64 deletions
diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js
index 2ca7050d8ab..78e73e0dc85 100644
--- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js
+++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js
@@ -38,9 +38,8 @@ assert.throws(() => {
name: 'Error'
})(e);
return true;
- } else {
- return true;
}
+ return true;
});
assert.throws(() => {
diff --git a/test/async-hooks/init-hooks.js b/test/async-hooks/init-hooks.js
index b10ec827198..59ecc96b881 100644
--- a/test/async-hooks/init-hooks.js
+++ b/test/async-hooks/init-hooks.js
@@ -165,14 +165,13 @@ class ActivityCollector {
// Worker threads start main script execution inside of an AsyncWrap
// callback, so we don't yield errors for these.
return null;
- } else {
- const err = new Error(`Found a handle whose ${hook}` +
- ' hook was invoked but not its init hook');
- // Don't throw if we see invocations due to an assertion in a test
- // failing since we want to list the assertion failure instead
- if (/process\._fatalException/.test(err.stack)) return null;
- throw err;
}
+ const err = new Error(`Found a handle whose ${hook}` +
+ ' hook was invoked but not its init hook');
+ // Don't throw if we see invocations due to an assertion in a test
+ // failing since we want to list the assertion failure instead
+ if (/process\._fatalException/.test(err.stack)) return null;
+ throw err;
}
return h;
}
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() {
diff --git a/test/parallel/test-fs-mkdir-mode-mask.js b/test/parallel/test-fs-mkdir-mode-mask.js
index 515b982054b..40bd7bec441 100644
--- a/test/parallel/test-fs-mkdir-mode-mask.js
+++ b/test/parallel/test-fs-mkdir-mode-mask.js
@@ -7,15 +7,12 @@ const assert = require('assert');
const path = require('path');
const fs = require('fs');
-let mode;
-
if (common.isWindows) {
common.skip('mode is not supported in mkdir on Windows');
return;
-} else {
- mode = 0o644;
}
+const mode = 0o644;
const maskToIgnore = 0o10000;
const tmpdir = require('../common/tmpdir');
diff --git a/test/parallel/test-fs-utimes.js b/test/parallel/test-fs-utimes.js
index c5ed73733c5..b72d263cf6c 100644
--- a/test/parallel/test-fs-utimes.js
+++ b/test/parallel/test-fs-utimes.js
@@ -31,15 +31,14 @@ tmpdir.refresh();
function stat_resource(resource) {
if (typeof resource === 'string') {
return fs.statSync(resource);
- } else {
- const stats = fs.fstatSync(resource);
- // Ensure mtime has been written to disk
- // except for directories on AIX where it cannot be synced
- if (common.isAIX && stats.isDirectory())
- return stats;
- fs.fsyncSync(resource);
- return fs.fstatSync(resource);
}
+ const stats = fs.fstatSync(resource);
+ // Ensure mtime has been written to disk
+ // except for directories on AIX where it cannot be synced
+ if (common.isAIX && stats.isDirectory())
+ return stats;
+ fs.fsyncSync(resource);
+ return fs.fstatSync(resource);
}
function check_mtime(resource, mtime) {
diff --git a/test/parallel/test-net-pingpong.js b/test/parallel/test-net-pingpong.js
index 99a02eda22f..e87ee10e43d 100644
--- a/test/parallel/test-net-pingpong.js
+++ b/test/parallel/test-net-pingpong.js
@@ -103,10 +103,9 @@ function pingPongTest(port, host) {
assert.strictEqual(client.writable, false);
assert.strictEqual(client.readable, true);
return;
- } else {
- assert.strictEqual(client.writable, true);
- assert.strictEqual(client.readable, true);
}
+ assert.strictEqual(client.writable, true);
+ assert.strictEqual(client.readable, true);
if (count < N) {
client.write('PING');
diff --git a/test/parallel/test-stream2-readable-empty-buffer-no-eof.js b/test/parallel/test-stream2-readable-empty-buffer-no-eof.js
index f1e74ad949c..7be2c358eed 100644
--- a/test/parallel/test-stream2-readable-empty-buffer-no-eof.js
+++ b/test/parallel/test-stream2-readable-empty-buffer-no-eof.js
@@ -95,8 +95,7 @@ function test2() {
r._read = function(n) {
if (!reads--)
return r.push(null); // EOF
- else
- return r.push(Buffer.from('x'));
+ return r.push(Buffer.from('x'));
};
const results = [];
diff --git a/test/parallel/test-trace-events-api.js b/test/parallel/test-trace-events-api.js
index 676e7f31e13..e45f374bab6 100644
--- a/test/parallel/test-trace-events-api.js
+++ b/test/parallel/test-trace-events-api.js
@@ -25,9 +25,8 @@ function getEnabledCategoriesFromCommandLine() {
const indexOfCatFlag = process.execArgv.indexOf('--trace-event-categories');
if (indexOfCatFlag === -1) {
return undefined;
- } else {
- return process.execArgv[indexOfCatFlag + 1];
}
+ return process.execArgv[indexOfCatFlag + 1];
}
const isChild = process.argv[2] === 'child';
diff --git a/test/pummel/test-net-pingpong.js b/test/pummel/test-net-pingpong.js
index b9507d519d8..f21160a1fa2 100644
--- a/test/pummel/test-net-pingpong.js
+++ b/test/pummel/test-net-pingpong.js
@@ -88,9 +88,8 @@ function pingPongTest(host, on_complete) {
if (sent_final_ping) {
assert.strictEqual(client.readyState, 'readOnly');
return;
- } else {
- assert.strictEqual(client.readyState, 'open');
}
+ assert.strictEqual(client.readyState, 'open');
if (count < N) {
client.write('PING');