Skip to content

Commit fc0ed2e

Browse files
Trottevanlucas
authored andcommitted
lib,benchmark,test: implement consistent braces
This change is in preparation for lint-enforced brace style. PR-URL: #7630 Reviewed-By: Brian White <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Rod Vagg <[email protected]>
1 parent cc7fdf4 commit fc0ed2e

30 files changed

+59
-92
lines changed

benchmark/child_process/child-process-read-ipc.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
2-
if (process.argv[2] === 'child')
3-
{
2+
if (process.argv[2] === 'child') {
43
const len = +process.argv[3];
54
const msg = `"${'.'.repeat(len)}"`;
65
while (true) {

lib/_stream_readable.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -803,9 +803,11 @@ Readable.prototype.wrap = function(stream) {
803803
// important when wrapping filters and duplexes.
804804
for (var i in stream) {
805805
if (this[i] === undefined && typeof stream[i] === 'function') {
806-
this[i] = function(method) { return function() {
807-
return stream[method].apply(stream, arguments);
808-
}; }(i);
806+
this[i] = function(method) {
807+
return function() {
808+
return stream[method].apply(stream, arguments);
809+
};
810+
}(i);
809811
}
810812
}
811813

lib/module.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,7 @@ Module._preloadModules = function(requests) {
622622
var parent = new Module('internal/preload', null);
623623
try {
624624
parent.paths = Module._nodeModulePaths(process.cwd());
625-
}
626-
catch (e) {
625+
} catch (e) {
627626
if (e.code !== 'ENOENT') {
628627
throw e;
629628
}

lib/net.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1158,8 +1158,7 @@ function createServerHandle(address, port, addressType, fd) {
11581158
if (typeof fd === 'number' && fd >= 0) {
11591159
try {
11601160
handle = createHandle(fd);
1161-
}
1162-
catch (e) {
1161+
} catch (e) {
11631162
// Not a fd we can listen on. This will trigger an error.
11641163
debug('listen invalid fd=' + fd + ': ' + e.message);
11651164
return uv.UV_EINVAL;

test/internet/test-dgram-broadcast-multi-process.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ if (process.argv[2] !== 'child') {
9696
//all child process are listening, so start sending
9797
sendSocket.sendNext();
9898
}
99-
}
100-
else if (msg.message) {
99+
} else if (msg.message) {
101100
worker.messagesReceived.push(msg.message);
102101

103102
if (worker.messagesReceived.length === messages.length) {

test/parallel/test-child-process-fork-exec-path.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ if (process.env.FORK) {
1212
assert.equal(process.argv[0], copyPath);
1313
process.send(msg);
1414
process.exit();
15-
}
16-
else {
15+
} else {
1716
common.refreshTmpDir();
1817
try {
1918
fs.unlinkSync(copyPath);
20-
}
21-
catch (e) {
19+
} catch (e) {
2220
if (e.code !== 'ENOENT') throw e;
2321
}
2422
fs.writeFileSync(copyPath, fs.readFileSync(nodePath));

test/parallel/test-child-process-recv-handle.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,12 @@ function worker() {
4949
if (n === 1) {
5050
assert.equal(msg, 'one');
5151
assert.equal(handle, undefined);
52-
}
53-
else if (n === 2) {
52+
} else if (n === 2) {
5453
assert.equal(msg, 'two');
5554
assert.equal(typeof handle, 'object'); // Also matches null, therefore...
5655
assert.ok(handle); // also check that it's truthy.
5756
handle.close();
58-
}
59-
else if (n === 3) {
57+
} else if (n === 3) {
6058
assert.equal(msg, 'three');
6159
assert.equal(handle, undefined);
6260
process.exit();

test/parallel/test-cluster-basic.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ if (cluster.isWorker) {
1818
http.Server(function() {
1919

2020
}).listen(common.PORT, '127.0.0.1');
21-
}
22-
23-
else if (cluster.isMaster) {
21+
} else if (cluster.isMaster) {
2422

2523
var checks = {
2624
cluster: {

test/parallel/test-cluster-bind-privileged-port.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ if (cluster.isMaster) {
1818
cluster.fork().on('exit', common.mustCall(function(exitCode) {
1919
assert.equal(exitCode, 0);
2020
}));
21-
}
22-
else {
21+
} else {
2322
var s = net.createServer(common.fail);
2423
s.listen(42, common.fail.bind(null, 'listen should have failed'));
2524
s.on('error', common.mustCall(function(err) {

test/parallel/test-cluster-bind-twice.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ if (!id) {
6464
process.on('exit', function() {
6565
assert(ok);
6666
});
67-
}
68-
else if (id === 'one') {
67+
} else if (id === 'one') {
6968
if (cluster.isMaster) return startWorker();
7069

7170
http.createServer(common.fail).listen(common.PORT, function() {
@@ -75,8 +74,7 @@ else if (id === 'one') {
7574
process.on('message', function(m) {
7675
if (m === 'QUIT') process.exit();
7776
});
78-
}
79-
else if (id === 'two') {
77+
} else if (id === 'two') {
8078
if (cluster.isMaster) return startWorker();
8179

8280
let ok = false;
@@ -96,8 +94,7 @@ else if (id === 'two') {
9694
ok = true;
9795
});
9896
});
99-
}
100-
else {
97+
} else {
10198
assert(0); // bad command line argument
10299
}
103100

test/parallel/test-cluster-eaddrinuse.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ if (id === 'undefined') {
2121
});
2222
});
2323
});
24-
}
25-
else if (id === 'worker') {
24+
} else if (id === 'worker') {
2625
let server = net.createServer(common.fail);
2726
server.listen(common.PORT, common.fail);
2827
server.on('error', common.mustCall(function(e) {
@@ -36,7 +35,6 @@ else if (id === 'worker') {
3635
}));
3736
});
3837
}));
39-
}
40-
else {
38+
} else {
4139
assert(0); // Bad argument.
4240
}

test/parallel/test-cluster-listening-port.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ if (cluster.isMaster) {
1919
// ensure that the 'listening' handler has been called
2020
assert(port);
2121
});
22-
}
23-
else {
22+
} else {
2423
net.createServer(common.fail).listen(0);
2524
}

test/parallel/test-cluster-message.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ if (cluster.isWorker) {
4040
});
4141

4242
server.listen(common.PORT, '127.0.0.1');
43-
}
44-
45-
else if (cluster.isMaster) {
43+
} else if (cluster.isMaster) {
4644

4745
var checks = {
4846
global: {

test/parallel/test-cluster-net-listen.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ if (cluster.isMaster) {
1414
process.on('exit', function() {
1515
assert.equal(worker, null);
1616
});
17-
}
18-
else {
17+
} else {
1918
// listen() without port should not trigger a libuv assert
2019
net.createServer(common.fail).listen(process.exit);
2120
}

test/parallel/test-cluster-shared-handle-bind-error.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ if (cluster.isMaster) {
1616
server.close();
1717
}));
1818
});
19-
}
20-
else {
19+
} else {
2120
var s = net.createServer(common.fail);
2221
s.listen(common.PORT, common.fail.bind(null, 'listen should have failed'));
2322
s.on('error', common.mustCall(function(err) {

test/parallel/test-cluster-shared-handle-bind-privileged-port.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ if (cluster.isMaster) {
2020
cluster.fork().on('exit', common.mustCall(function(exitCode) {
2121
assert.equal(exitCode, 0);
2222
}));
23-
}
24-
else {
23+
} else {
2524
var s = net.createServer(common.fail);
2625
s.listen(42, common.fail.bind(null, 'listen should have failed'));
2726
s.on('error', common.mustCall(function(err) {

test/parallel/test-cluster-uncaught-exception.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ if (isTestRunner) {
2323
master.on('exit', function(code) {
2424
exitCode = code;
2525
});
26-
}
27-
else if (cluster.isMaster) {
26+
} else if (cluster.isMaster) {
2827
process.on('uncaughtException', function() {
2928
process.nextTick(function() {
3029
process.exit(MAGIC_EXIT_CODE);
@@ -33,7 +32,6 @@ else if (cluster.isMaster) {
3332

3433
cluster.fork();
3534
throw new Error('kill master');
36-
}
37-
else { // worker
35+
} else { // worker
3836
process.exit();
3937
}

test/parallel/test-cluster-worker-death.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ var cluster = require('cluster');
55

66
if (!cluster.isMaster) {
77
process.exit(42);
8-
}
9-
else {
8+
} else {
109
var seenExit = 0;
1110
var seenDeath = 0;
1211
var worker = cluster.fork();

test/parallel/test-crypto-authenticated.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,7 @@ for (var i in TEST_CASES) {
362362
(function() {
363363
if (!test.password) return;
364364
if (common.hasFipsCrypto) {
365-
assert.throws(function()
366-
{ crypto.createCipher(test.algo, test.password); },
365+
assert.throws(() => { crypto.createCipher(test.algo, test.password); },
367366
/not supported in FIPS mode/);
368367
} else {
369368
var encrypt = crypto.createCipher(test.algo, test.password);
@@ -383,8 +382,7 @@ for (var i in TEST_CASES) {
383382
(function() {
384383
if (!test.password) return;
385384
if (common.hasFipsCrypto) {
386-
assert.throws(function()
387-
{ crypto.createDecipher(test.algo, test.password); },
385+
assert.throws(() => { crypto.createDecipher(test.algo, test.password); },
388386
/not supported in FIPS mode/);
389387
} else {
390388
var decrypt = crypto.createDecipher(test.algo, test.password);
@@ -415,9 +413,9 @@ for (var i in TEST_CASES) {
415413
'ipxp9a6i1Mb4USb4', '6fKjEjR3Vl30EUYC');
416414
encrypt.update('blah', 'ascii');
417415
encrypt.final();
418-
assert.throws(function() { encrypt.getAuthTag(); }, / state/);
419-
assert.throws(function() {
420-
encrypt.setAAD(Buffer.from('123', 'ascii')); }, / state/);
416+
assert.throws(() => { encrypt.getAuthTag(); }, / state/);
417+
assert.throws(() => { encrypt.setAAD(Buffer.from('123', 'ascii')); },
418+
/ state/);
421419
})();
422420

423421
(function() {
@@ -432,8 +430,8 @@ for (var i in TEST_CASES) {
432430
// trying to set tag on encryption object:
433431
var encrypt = crypto.createCipheriv(test.algo,
434432
Buffer.from(test.key, 'hex'), Buffer.from(test.iv, 'hex'));
435-
assert.throws(function() {
436-
encrypt.setAuthTag(Buffer.from(test.tag, 'hex')); }, / state/);
433+
assert.throws(() => { encrypt.setAuthTag(Buffer.from(test.tag, 'hex')); },
434+
/ state/);
437435
})();
438436

439437
(function() {

test/parallel/test-debugger-util-regression.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,10 @@ proc.stdout.on('data', (data) => {
3939
stdout.includes('> 4') && nextCount < 4) {
4040
nextCount++;
4141
proc.stdin.write('n\n');
42-
}
43-
else if (stdout.includes('{ a: \'b\' }')) {
42+
} else if (stdout.includes('{ a: \'b\' }')) {
4443
clearTimeout(timer);
4544
proc.stdin.write('.exit\n');
46-
}
47-
else if (stdout.includes('program terminated')) {
45+
} else if (stdout.includes('program terminated')) {
4846
// Catch edge case present in v4.x
4947
// process will terminate after call to util.inspect
5048
common.fail('the program should not terminate');

test/parallel/test-fs-open.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ try {
88
// should throw ENOENT, not EBADF
99
// see https://github.com/joyent/node/pull/1228
1010
fs.openSync('/path/to/file/that/does/not/exist', 'r');
11-
}
12-
catch (e) {
11+
} catch (e) {
1312
assert.equal(e.code, 'ENOENT');
1413
caughtException = true;
1514
}

test/parallel/test-fs-realpath.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ function asynctest(testBlock, args, callback, assertBlock) {
5757
if (assertBlock) {
5858
try {
5959
ignoreError = assertBlock.apply(assertBlock, arguments);
60-
}
61-
catch (e) {
60+
} catch (e) {
6261
err = e;
6362
}
6463
}

test/parallel/test-http-server-stale-close.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ if (process.env.NODE_TEST_FORK_PORT) {
1313
}, process.exit);
1414
req.write('BAM');
1515
req.end();
16-
}
17-
else {
16+
} else {
1817
var server = http.createServer(function(req, res) {
1918
res.writeHead(200, {'Content-Length': '42'});
2019
req.pipe(res);

test/parallel/test-next-tick-errors.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ process.on('uncaughtException', function() {
4040
if (!exceptionHandled) {
4141
exceptionHandled = true;
4242
order.push('B');
43-
}
44-
else {
43+
} else {
4544
// If we get here then the first process.nextTick got called twice
4645
order.push('OOPS!');
4746
}

test/parallel/test-process-argv-0.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ if (process.argv[2] !== 'child') {
1616
process.on('exit', function() {
1717
assert.equal(childArgv0, process.execPath);
1818
});
19-
}
20-
else {
19+
} else {
2120
process.stdout.write(process.argv[0]);
2221
}

test/parallel/test-process-cpuUsage.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,18 @@ assert.throws(function() { process.cpuUsage({ user: null, system: 'c' }); });
4242
assert.throws(function() { process.cpuUsage({ user: 'd', system: null }); });
4343
assert.throws(function() { process.cpuUsage({ user: -1, system: 2 }); });
4444
assert.throws(function() { process.cpuUsage({ user: 3, system: -2 }); });
45-
assert.throws(function() { process.cpuUsage({
46-
user: Number.POSITIVE_INFINITY,
47-
system: 4
48-
});});
49-
assert.throws(function() { process.cpuUsage({
50-
user: 5,
51-
system: Number.NEGATIVE_INFINITY
52-
});});
45+
assert.throws(function() {
46+
process.cpuUsage({
47+
user: Number.POSITIVE_INFINITY,
48+
system: 4
49+
});
50+
});
51+
assert.throws(function() {
52+
process.cpuUsage({
53+
user: 5,
54+
system: Number.NEGATIVE_INFINITY
55+
});
56+
});
5357

5458
// Ensure that the return value is the expected shape.
5559
function validateResult(result) {

test/parallel/test-repl-domain.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ putIn.write = function(data) {
1111
// give a false negative. Don't throw, just print and exit.
1212
if (data === 'OK\n') {
1313
console.log('ok');
14-
}
15-
else {
14+
} else {
1615
console.error(data);
1716
process.exit(1);
1817
}

test/parallel/test-vm-context.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ console.error('test runInContext signature');
3232
var gh1140Exception;
3333
try {
3434
vm.runInContext('throw new Error()', context, 'expected-filename.js');
35-
}
36-
catch (e) {
35+
} catch (e) {
3736
gh1140Exception = e;
3837
assert.ok(/expected-filename/.test(e.stack),
3938
'expected appearance of filename in Error stack');

test/pummel/test-fs-watch-file-slow.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ var nevents = 0;
1111

1212
try {
1313
fs.unlinkSync(FILENAME);
14-
}
15-
catch (e) {
14+
} catch (e) {
1615
// swallow
1716
}
1817

0 commit comments

Comments
 (0)