Skip to content

Commit

Permalink
test: remove unused catch bindings
Browse files Browse the repository at this point in the history
PR-URL: #24079
Reviewed-By: Sam Roberts <[email protected]>
Reviewed-By: Wyatt Preul <[email protected]>
  • Loading branch information
cjihrig authored and MylesBorins committed Dec 3, 2018
1 parent 4b456d5 commit 78be477
Show file tree
Hide file tree
Showing 30 changed files with 57 additions and 57 deletions.
8 changes: 4 additions & 4 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ function canCreateSymLink() {
try {
const output = execSync(`${whoamiPath} /priv`, { timout: 1000 });
return output.includes('SeCreateSymbolicLinkPrivilege');
} catch (e) {
} catch {
return false;
}
}
Expand Down Expand Up @@ -455,7 +455,7 @@ function isAlive(pid) {
try {
process.kill(pid, 'SIGCONT');
return true;
} catch (e) {
} catch {
return false;
}
}
Expand Down Expand Up @@ -664,7 +664,7 @@ function getTTYfd() {
if (ttyFd === undefined) {
try {
return fs.openSync('/dev/tty');
} catch (e) {
} catch {
// There aren't any tty fd's available to use.
return -1;
}
Expand All @@ -678,7 +678,7 @@ function runWithInvalidFD(func) {
// be an valid one.
try {
while (fs.fstatSync(fd--) && fd > 0);
} catch (e) {
} catch {
return func(fd);
}

Expand Down
2 changes: 1 addition & 1 deletion test/doctool/test-doctool-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const common = require('../common');
// The doctool currently uses js-yaml from the tool/node_modules/eslint/ tree.
try {
require('../../tools/node_modules/eslint/node_modules/js-yaml');
} catch (e) {
} catch {
common.skip('missing js-yaml (eslint not present)');
}

Expand Down
2 changes: 1 addition & 1 deletion test/doctool/test-doctool-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const common = require('../common');
// The doctool currently uses js-yaml from the tool/node_modules/eslint/ tree.
try {
require('../../tools/node_modules/eslint/node_modules/js-yaml');
} catch (e) {
} catch {
common.skip('missing js-yaml (eslint not present)');
}

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/catch-stdout-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
function write() {
try {
process.stdout.write('Hello, world\n');
} catch (ex) {
} catch {
throw new Error('this should never happen');
}
setImmediate(function() {
Expand Down
2 changes: 1 addition & 1 deletion test/internet/test-dgram-broadcast-multi-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ if (process.argv[2] !== 'child') {
const buf = messages[i++];

if (!buf) {
try { sendSocket.close(); } catch (e) {}
try { sendSocket.close(); } catch {}
return;
}

Expand Down
2 changes: 1 addition & 1 deletion test/internet/test-dgram-multicast-multi-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ if (process.argv[2] !== 'child') {
const buf = messages[i++];

if (!buf) {
try { sendSocket.close(); } catch (e) {}
try { sendSocket.close(); } catch {}
return;
}

Expand Down
4 changes: 2 additions & 2 deletions test/known_issues/test-url-parse-conformance.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ tests.forEach((test) => {
assert.strictEqual(test.pathname, parsed.pathname || '/');
assert.strictEqual(test.search, parsed.search || '');
assert.strictEqual(test.hash, parsed.hash || '');
} catch (err) {
} catch {
// For now, we're just interested in the number of failures.
failed++;
}
}
} catch (err) {
} catch {
// If Parse failed and it wasn't supposed to, treat it as a failure.
if (!test.failure)
failed++;
Expand Down
2 changes: 1 addition & 1 deletion test/message/vm_dont_display_runtime_error.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ try {
filename: 'test.vm',
displayErrors: false
});
} catch (e) {}
} catch {}

console.error('middle');

Expand Down
2 changes: 1 addition & 1 deletion test/message/vm_dont_display_syntax_error.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ try {
filename: 'test.vm',
displayErrors: false
});
} catch (e) {}
} catch {}

console.error('middle');

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ assert.throws(
},
Array
);
} catch (e) {
} catch {
threw = true;
}
assert.ok(threw, 'wrong constructor validation');
Expand Down
12 changes: 6 additions & 6 deletions test/parallel/test-crypto-cipher-decipher.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ testCipher2(Buffer.from('0123456789abcdef'));
// not assert. See https://github.com/nodejs/node-v0.x-archive/issues/4886.
{
const c = crypto.createCipher('aes-256-cbc', 'secret');
try { c.final('xxx'); } catch (e) { /* Ignore. */ }
try { c.final('xxx'); } catch (e) { /* Ignore. */ }
try { c.final('xxx'); } catch (e) { /* Ignore. */ }
try { c.final('xxx'); } catch { /* Ignore. */ }
try { c.final('xxx'); } catch { /* Ignore. */ }
try { c.final('xxx'); } catch { /* Ignore. */ }
const d = crypto.createDecipher('aes-256-cbc', 'secret');
try { d.final('xxx'); } catch (e) { /* Ignore. */ }
try { d.final('xxx'); } catch (e) { /* Ignore. */ }
try { d.final('xxx'); } catch (e) { /* Ignore. */ }
try { d.final('xxx'); } catch { /* Ignore. */ }
try { d.final('xxx'); } catch { /* Ignore. */ }
try { d.final('xxx'); } catch { /* Ignore. */ }
}

// Regression test for https://github.com/nodejs/node-v0.x-archive/issues/5482:
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-file-write-stream2.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ process.on('exit', function() {
function removeTestFile() {
try {
fs.unlinkSync(filepath);
} catch (e) {}
} catch {}
}


Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-realpath-pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ for (const code of [
if (require('fs').realpathSync('/dev/stdin')) {
process.exit(2);
}
} catch (e) {
} catch {
process.exit(1);
}`
]) {
Expand Down
28 changes: 14 additions & 14 deletions test/parallel/test-fs-realpath.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function test_simple_relative_symlink(realpath, realpathSync, callback) {
[
[entry, `../${path.basename(tmpDir)}/cycles/root.js`]
].forEach(function(t) {
try { fs.unlinkSync(t[0]); } catch (e) {}
try { fs.unlinkSync(t[0]); } catch {}
console.log('fs.symlinkSync(%j, %j, %j)', t[1], t[0], 'file');
fs.symlinkSync(t[1], t[0], 'file');
unlink.push(t[0]);
Expand All @@ -126,7 +126,7 @@ function test_simple_absolute_symlink(realpath, realpathSync, callback) {
[
[entry, expected]
].forEach(function(t) {
try { fs.unlinkSync(t[0]); } catch (e) {}
try { fs.unlinkSync(t[0]); } catch {}
console.error('fs.symlinkSync(%j, %j, %j)', t[1], t[0], type);
fs.symlinkSync(t[1], t[0], type);
unlink.push(t[0]);
Expand All @@ -151,13 +151,13 @@ function test_deep_relative_file_symlink(realpath, realpathSync, callback) {
expected);
const linkPath1 = path.join(targetsAbsDir,
'nested-index', 'one', 'symlink1.js');
try { fs.unlinkSync(linkPath1); } catch (e) {}
try { fs.unlinkSync(linkPath1); } catch {}
fs.symlinkSync(linkData1, linkPath1, 'file');

const linkData2 = '../one/symlink1.js';
const entry = path.join(targetsAbsDir,
'nested-index', 'two', 'symlink1-b.js');
try { fs.unlinkSync(entry); } catch (e) {}
try { fs.unlinkSync(entry); } catch {}
fs.symlinkSync(linkData2, entry, 'file');
unlink.push(linkPath1);
unlink.push(entry);
Expand All @@ -178,13 +178,13 @@ function test_deep_relative_dir_symlink(realpath, realpathSync, callback) {
const path1b = path.join(targetsAbsDir, 'nested-index', 'one');
const linkPath1b = path.join(path1b, 'symlink1-dir');
const linkData1b = path.relative(path1b, expected);
try { fs.unlinkSync(linkPath1b); } catch (e) {}
try { fs.unlinkSync(linkPath1b); } catch {}
fs.symlinkSync(linkData1b, linkPath1b, 'dir');

const linkData2b = '../one/symlink1-dir';
const entry = path.join(targetsAbsDir,
'nested-index', 'two', 'symlink12-dir');
try { fs.unlinkSync(entry); } catch (e) {}
try { fs.unlinkSync(entry); } catch {}
fs.symlinkSync(linkData2b, entry, 'dir');
unlink.push(linkPath1b);
unlink.push(entry);
Expand All @@ -208,7 +208,7 @@ function test_cyclic_link_protection(realpath, realpathSync, callback) {
[path.join(tmpDir, '/cycles/realpath-3b'), '../cycles/realpath-3c'],
[path.join(tmpDir, '/cycles/realpath-3c'), '../cycles/realpath-3a']
].forEach(function(t) {
try { fs.unlinkSync(t[0]); } catch (e) {}
try { fs.unlinkSync(t[0]); } catch {}
fs.symlinkSync(t[1], t[0], 'dir');
unlink.push(t[0]);
});
Expand All @@ -235,7 +235,7 @@ function test_cyclic_link_overprotection(realpath, realpathSync, callback) {
const link = `${folder}/cycles`;
let testPath = cycles;
testPath += '/folder/cycles'.repeat(10);
try { fs.unlinkSync(link); } catch (ex) {}
try { fs.unlinkSync(link); } catch {}
fs.symlinkSync(cycles, link, 'dir');
unlink.push(link);
assertEqualPath(realpathSync(testPath), path.resolve(expected));
Expand Down Expand Up @@ -263,7 +263,7 @@ function test_relative_input_cwd(realpath, realpathSync, callback) {
].forEach(function(t) {
const fn = t[0];
console.error('fn=%j', fn);
try { fs.unlinkSync(fn); } catch (e) {}
try { fs.unlinkSync(fn); } catch {}
const b = path.basename(t[1]);
const type = (b === 'root.js' ? 'file' : 'dir');
console.log('fs.symlinkSync(%j, %j, %j)', t[1], fn, type);
Expand Down Expand Up @@ -302,8 +302,8 @@ function test_deep_symlink_mix(realpath, realpathSync, callback) {
$tmpDir/targets/cycles/root.js (hard)
*/
const entry = tmp('node-test-realpath-f1');
try { fs.unlinkSync(tmp('node-test-realpath-d2/foo')); } catch (e) {}
try { fs.rmdirSync(tmp('node-test-realpath-d2')); } catch (e) {}
try { fs.unlinkSync(tmp('node-test-realpath-d2/foo')); } catch {}
try { fs.rmdirSync(tmp('node-test-realpath-d2')); } catch {}
fs.mkdirSync(tmp('node-test-realpath-d2'), 0o700);
try {
[
Expand All @@ -318,7 +318,7 @@ function test_deep_symlink_mix(realpath, realpathSync, callback) {
[`${targetsAbsDir}/nested-index/two/realpath-c`,
`${tmpDir}/cycles/root.js`]
].forEach(function(t) {
try { fs.unlinkSync(t[0]); } catch (e) {}
try { fs.unlinkSync(t[0]); } catch {}
fs.symlinkSync(t[1], t[0]);
unlink.push(t[0]);
});
Expand Down Expand Up @@ -429,14 +429,14 @@ function test_abs_with_kids(realpath, realpathSync, cb) {
['/a/b/c/x.txt',
'/a/link'
].forEach(function(file) {
try { fs.unlinkSync(root + file); } catch (ex) {}
try { fs.unlinkSync(root + file); } catch {}
});
['/a/b/c',
'/a/b',
'/a',
''
].forEach(function(folder) {
try { fs.rmdirSync(root + folder); } catch (ex) {}
try { fs.rmdirSync(root + folder); } catch {}
});
}
function setup() {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-listen-fd-detached-inherit.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function test() {
process.kill(child.pid, 'SIGKILL');
try {
parent.kill();
} catch (e) {}
} catch {}

assert.strictEqual(s, 'hello from child\n');
assert.strictEqual(res.statusCode, 200);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-listen-fd-detached.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function test() {
process.kill(child.pid, 'SIGKILL');
try {
parent.kill();
} catch (e) {}
} catch {}

assert.strictEqual(s, 'hello from child\n');
assert.strictEqual(res.statusCode, 200);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-listen-fd-ebadf.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ let invalidFd = 2;
// Get first known bad file descriptor.
try {
while (fs.fstatSync(++invalidFd));
} catch (e) {
} catch {
// do nothing; we now have an invalid fd
}

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-module-loading-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if (common.isWindows) {
try {
// If MUI != 'en' we'll ignore the content of the message
localeOk = execSync(powerShellFindMUI).toString('utf8').trim() === 'en';
} catch (_) {
} catch {
// It's only a best effort try to find the MUI
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-promises-unhandled-rejections.js
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ asyncTest('Throwing an error inside a rejectionHandled handler goes to' +
setTimeout(function() {
try {
p.catch(function() {});
} catch (e) {
} catch {
done(new Error('fail'));
}
}, 1);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-repl-syntax-error-handling.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function child() {
let caught;
try {
vm.runInThisContext('haf!@##&$!@$*!@', { displayErrors: false });
} catch (er) {
} catch {
caught = true;
}
assert(caught);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-require-deps-deprecation.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ common.expectWarning('DeprecationWarning', deprecatedModules.map((m) => {
for (const m of deprecatedModules) {
try {
require(m);
} catch (err) {}
} catch {}
}

// Instead of checking require, check that resolve isn't pointing toward a
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stdout-close-catch.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ child.stderr.on('data', function(c) {
child.on('close', common.mustCall(function(code) {
try {
output = JSON.parse(output);
} catch (er) {
} catch {
console.error(output);
process.exit(1);
}
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stdout-to-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function test(size, useBuffer, cb) {

try {
fs.unlinkSync(tmpFile);
} catch (e) {}
} catch {}

console.log(`${size} chars to ${tmpFile}...`);

Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-vm-low-stack-space.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const vm = require('vm');
function a() {
try {
return a();
} catch (e) {
} catch {
// Throw an exception as near to the recursion-based RangeError as possible.
return vm.runInThisContext('() => 42')();
}
Expand All @@ -17,7 +17,7 @@ assert.strictEqual(a(), 42);
function b() {
try {
return b();
} catch (e) {
} catch {
// This writes a lot of noise to stderr, but it still works.
return vm.runInNewContext('() => 42')();
}
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-vm-module-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async function checkModuleState() {
const m = new SourceTextModule('import "foo";');
try {
await m.link(common.mustCall(() => ({})));
} catch (err) {
} catch {
assert.strictEqual(m.linkingStatus, 'errored');
m.instantiate();
}
Expand Down Expand Up @@ -218,7 +218,7 @@ async function checkLinking() {
const erroredModule = new SourceTextModule('import "foo";');
try {
await erroredModule.link(common.mustCall(() => ({})));
} catch (err) {
} catch {
// ignored
} finally {
assert.strictEqual(erroredModule.linkingStatus, 'errored');
Expand Down
Loading

0 comments on commit 78be477

Please sign in to comment.