Skip to content

Commit 13ac0a5

Browse files
aduh95ruyadorno
authored andcommittedSep 12, 2023
test: remove unnecessary noop function args to mustNotCall()
PR-URL: #48513 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Harshitha K P <harshitha014@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 786fbdb commit 13ac0a5

14 files changed

+17
-18
lines changed
 

‎test/.eslintrc.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ rules:
4747
message: Use Number.isNaN() instead of the global isNaN() function.
4848
- selector: VariableDeclarator > CallExpression:matches([callee.name='debuglog'], [callee.property.name='debuglog']):not([arguments.0.value='test'])
4949
message: Use 'test' as debuglog value in tests.
50-
- 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+
- selector: CallExpression:matches([callee.object.name="common"][callee.property.name=/^must(Not)?Call/],[callee.name="mustCall"],[callee.name="mustCallAtLeast"],[callee.name="mustNotCall"])>:first-child[type=/FunctionExpression$/][body.body.length=0]
5151
message: Do not use an empty function, omit the parameter altogether.
5252

5353
# Custom rules in tools/eslint-rules

‎test/parallel/test-child-process-execfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const execOpts = { encoding: 'utf8', shell: true };
8484
// Verify that if something different than Abortcontroller.signal
8585
// is passed, ERR_INVALID_ARG_TYPE is thrown
8686
assert.throws(() => {
87-
const callback = common.mustNotCall(() => {});
87+
const callback = common.mustNotCall();
8888

8989
execFile(process.execPath, [echoFixture, 0], { signal: 'hello' }, callback);
9090
}, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });

‎test/parallel/test-fs-promises-readfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ async function validateWrongSignalParam() {
6464
// is passed, ERR_INVALID_ARG_TYPE is thrown
6565

6666
await assert.rejects(async () => {
67-
const callback = common.mustNotCall(() => {});
67+
const callback = common.mustNotCall();
6868
await readFile(fn, { signal: 'hello' }, callback);
6969
}, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });
7070

‎test/parallel/test-fs-readfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ for (const e of fileInfo) {
9595
// Verify that if something different than Abortcontroller.signal
9696
// is passed, ERR_INVALID_ARG_TYPE is thrown
9797
assert.throws(() => {
98-
const callback = common.mustNotCall(() => {});
98+
const callback = common.mustNotCall();
9999
fs.readFile(fileInfo[0].name, { signal: 'hello' }, callback);
100100
}, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });
101101
}

‎test/parallel/test-http2-client-http1-server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const http2 = require('http2');
1111
const { NghttpError } = require('internal/http2/util');
1212

1313
// Creating an http1 server here...
14-
const server = http.createServer(common.mustNotCall(() => {}))
14+
const server = http.createServer(common.mustNotCall())
1515
.on('clientError', common.mustCall((error, socket) => {
1616
assert.strictEqual(error.code, 'HPE_PAUSED_H2_UPGRADE');
1717
assert.strictEqual(error.bytesParsed, 24);

‎test/parallel/test-https-agent-session-injection.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const server = https.createServer(options, function(req, res) {
3232
path: '/',
3333
ca,
3434
servername: 'nodejs.org',
35-
}, common.mustNotCall(() => {}));
35+
}, common.mustNotCall());
3636

3737
req.on('error', common.mustCall((err) => {
3838
assert.strictEqual(
@@ -45,7 +45,7 @@ const server = https.createServer(options, function(req, res) {
4545
path: '/',
4646
ca,
4747
servername: 'nodejs.org',
48-
}, common.mustNotCall(() => {}));
48+
}, common.mustNotCall());
4949

5050
second.on('error', common.mustCall((err) => {
5151
server.close();

‎test/parallel/test-readline-interface.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1054,8 +1054,7 @@ for (let i = 0; i < 12; i++) {
10541054
rli.question('foo?', common.mustCall((answer) => {
10551055
assert.strictEqual(answer, 'baz');
10561056
}));
1057-
rli.question('bar?', common.mustNotCall(() => {
1058-
}));
1057+
rli.question('bar?', common.mustNotCall());
10591058
rli.write('baz\n');
10601059
rli.close();
10611060
}

‎test/parallel/test-stream-filter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ const { setTimeout } = require('timers/promises');
169169
{
170170
const stream = Readable.from([1, 2, 3, 4, 5]);
171171
Object.defineProperty(stream, 'map', {
172-
value: common.mustNotCall(() => {}),
172+
value: common.mustNotCall(),
173173
});
174174
// Check that map isn't getting called.
175175
stream.filter(() => true);

‎test/parallel/test-stream-flatMap.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function oneTo5() {
124124
{
125125
const stream = oneTo5();
126126
Object.defineProperty(stream, 'map', {
127-
value: common.mustNotCall(() => {}),
127+
value: common.mustNotCall(),
128128
});
129129
// Check that map isn't getting called.
130130
stream.flatMap(() => true);

‎test/parallel/test-stream-forEach.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ const { once } = require('events');
132132
{
133133
const stream = Readable.from([1, 2, 3, 4, 5]);
134134
Object.defineProperty(stream, 'map', {
135-
value: common.mustNotCall(() => {}),
135+
value: common.mustNotCall(),
136136
});
137137
// Check that map isn't getting called.
138138
stream.forEach(() => true);

‎test/parallel/test-stream-readable-destroy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ const assert = require('assert');
249249

250250
{
251251
const read = new Readable({
252-
read: common.mustNotCall(function() {})
252+
read: common.mustNotCall()
253253
});
254254
read.destroy();
255255
assert.strictEqual(read.destroyed, true);

‎test/parallel/test-stream-readable-next-no-null.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ stream.on('error', expectsError({
1414
message: 'May not write null values to stream'
1515
}));
1616

17-
stream.on('data', mustNotCall((chunk) => {}));
17+
stream.on('data', mustNotCall());
1818

1919
stream.on('end', mustNotCall());

‎test/parallel/test-stream-some-find-every.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ function oneTo5Async() {
164164
for (const op of ['some', 'every', 'find']) {
165165
const stream = oneTo5();
166166
Object.defineProperty(stream, 'map', {
167-
value: common.mustNotCall(() => {}),
167+
value: common.mustNotCall(),
168168
});
169169
// Check that map isn't getting called.
170170
stream[op](() => {});

‎test/parallel/test-worker-data-url.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ const { Worker } = require('worker_threads');
55
const assert = require('assert');
66

77
new Worker(new URL('data:text/javascript,'))
8-
.on('error', common.mustNotCall(() => {}));
8+
.on('error', common.mustNotCall());
99
new Worker(new URL('data:text/javascript,export{}'))
10-
.on('error', common.mustNotCall(() => {}));
10+
.on('error', common.mustNotCall());
1111

1212
new Worker(new URL('data:text/plain,'))
1313
.on('error', common.mustCall());
1414
new Worker(new URL('data:text/javascript,module.exports={}'))
1515
.on('error', common.mustCall());
1616

1717
new Worker(new URL('data:text/javascript,await Promise.resolve()'))
18-
.on('error', common.mustNotCall(() => {}));
18+
.on('error', common.mustNotCall());
1919
new Worker(new URL('data:text/javascript,await Promise.reject()'))
2020
.on('error', common.mustCall());
2121
new Worker(new URL('data:text/javascript,await new Promise(()=>{})'))

0 commit comments

Comments
 (0)
Please sign in to comment.