Skip to content

Commit b3c4265

Browse files
aduh95danielleadams
authored andcommitted
test: remove unnecessary noop function args to mustCall()
RefsL #45027 PR-URL: #45047 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Zeyu "Alex" Yang <[email protected]>
1 parent 868b4a3 commit b3c4265

24 files changed

+32
-38
lines changed

test/.eslintrc.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ rules:
4646
message: Use Number.isNaN() instead of the global isNaN() function.
4747
- selector: VariableDeclarator > CallExpression:matches([callee.name='debuglog'], [callee.property.name='debuglog']):not([arguments.0.value='test'])
4848
message: Use 'test' as debuglog value in tests.
49+
- selector: CallExpression:matches([callee.object.name="common"][callee.property.name=/^mustCall/],[callee.name="mustCall"],[callee.name="mustCallAtLeast"])>:first-child[type=/FunctionExpression$/][body.body.length=0]
50+
message: Do not use an empty function, omit the parameter altogether.
4951

5052
# Custom rules in tools/eslint-rules
5153
node-core/prefer-assert-iferror: error

test/async-hooks/test-http-agent-handle-reuse-parallel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const verifyRequest = (idx) => (res) => {
3434
socket = res.socket;
3535
}
3636

37-
res.on('data', common.mustCallAtLeast(() => {}));
37+
res.on('data', common.mustCallAtLeast());
3838
res.on('end', common.mustCall(() => {
3939
if (++responses === 2) {
4040
// Clean up to let the event loop stop.

test/async-hooks/test-http-agent-handle-reuse-serial.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const server = http.createServer(common.mustCall((req, res) => {
4747
// Check that request and response share their socket.
4848
assert.strictEqual(r1.socket, socket);
4949

50-
res.on('data', common.mustCallAtLeast(() => {}));
50+
res.on('data', common.mustCallAtLeast());
5151
res.on('end', common.mustCall(() => {
5252
// setImmediate() to give the agent time to register the freed socket.
5353
setImmediate(common.mustCall(() => {
@@ -70,7 +70,7 @@ const server = http.createServer(common.mustCall((req, res) => {
7070
// Empty payload, to hit the “right” code path.
7171
r2.end('');
7272

73-
res.on('data', common.mustCallAtLeast(() => {}));
73+
res.on('data', common.mustCallAtLeast());
7474
res.on('end', common.mustCall(() => {
7575
// Clean up to let the event loop stop.
7676
server.close();

test/known_issues/test-http-path-contains-unicode.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ assert.strictEqual(expected, '/caf\u{e9}\u{1f436}');
1414

1515
const server = http.createServer(common.mustCall(function(req, res) {
1616
assert.strictEqual(req.url, expected);
17-
req.on('data', common.mustCall(function() {
18-
})).on('end', common.mustCall(function() {
17+
req.on('data', common.mustCall()).on('end', common.mustCall(function() {
1918
server.close();
2019
res.writeHead(200);
2120
res.end('hello world\n');

test/parallel/test-async-hooks-http-agent-destroy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const server = http.createServer(common.mustCall((req, res) => {
5050
// Check that request and response share their socket.
5151
assert.strictEqual(r1.socket, socket);
5252

53-
res.on('data', common.mustCallAtLeast(() => {}));
53+
res.on('data', common.mustCallAtLeast());
5454
res.on('end', common.mustCall(() => {
5555
// setImmediate() to give the agent time to register the freed socket.
5656
setImmediate(common.mustCall(() => {
@@ -66,7 +66,7 @@ const server = http.createServer(common.mustCall((req, res) => {
6666
// Empty payload, to hit the “right” code path.
6767
r2.end('');
6868

69-
res.on('data', common.mustCallAtLeast(() => {}));
69+
res.on('data', common.mustCallAtLeast());
7070
res.on('end', common.mustCall(() => {
7171
// Clean up to let the event loop stop.
7272
server.close();

test/parallel/test-async-hooks-http-agent.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const server = http.createServer(common.mustCall((req, res) => {
4040
// Check that request and response share their socket.
4141
assert.strictEqual(r1.socket, socket);
4242

43-
res.on('data', common.mustCallAtLeast(() => {}));
43+
res.on('data', common.mustCallAtLeast());
4444
res.on('end', common.mustCall(() => {
4545
// setImmediate() to give the agent time to register the freed socket.
4646
setImmediate(common.mustCall(() => {
@@ -62,7 +62,7 @@ const server = http.createServer(common.mustCall((req, res) => {
6262
// Empty payload, to hit the “right” code path.
6363
r2.end('');
6464

65-
res.on('data', common.mustCallAtLeast(() => {}));
65+
res.on('data', common.mustCallAtLeast());
6666
res.on('end', common.mustCall(() => {
6767
// Clean up to let the event loop stop.
6868
server.close();

test/parallel/test-cluster-fork-windowsHide.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ if (!process.argv[2]) {
2020
{ detached: true, stdio: ['ignore', 'ignore', 'ignore', 'ipc'] });
2121

2222
const messageHandlers = {
23-
workerOnline: common.mustCall((msg) => {
24-
}),
23+
workerOnline: common.mustCall(),
2524
mainWindowHandle: common.mustCall((msg) => {
2625
assert.match(msg.value, /0\s*/);
2726
}),

test/parallel/test-cluster-ipc-throw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if (cluster.isPrimary) {
1717
}));
1818
} else {
1919
assert(process.env.PORT);
20-
process.on('uncaughtException', common.mustCall((e) => {}));
20+
process.on('uncaughtException', common.mustCall());
2121
server.listen(process.env.PORT);
2222
server.on('error', common.mustCall((e) => {
2323
cluster.worker.disconnect();

test/parallel/test-cluster-worker-kill-signal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if (cluster.isWorker) {
1313
const http = require('http');
1414
const server = http.Server(() => { });
1515

16-
server.once('listening', common.mustCall(() => { }));
16+
server.once('listening', common.mustCall());
1717
server.listen(0, '127.0.0.1');
1818

1919
} else if (cluster.isMaster) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ if (cluster.isWorker) {
3535
const http = require('http');
3636
const server = http.Server(() => { });
3737

38-
server.once('listening', common.mustCall(() => { }));
38+
server.once('listening', common.mustCall());
3939
server.listen(0, '127.0.0.1');
4040

4141
} else if (cluster.isPrimary) {

0 commit comments

Comments
 (0)