test: remove unnecessary noop function args to mustNotCall()

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Antoine du Hamel 2023-06-24 16:16:07 +02:00 committed by GitHub
parent cebbc57ed2
commit d9f394e607
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 17 additions and 18 deletions

View File

@ -47,7 +47,7 @@ rules:
message: Use Number.isNaN() instead of the global isNaN() function.
- selector: VariableDeclarator > CallExpression:matches([callee.name='debuglog'], [callee.property.name='debuglog']):not([arguments.0.value='test'])
message: Use 'test' as debuglog value in tests.
- 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]
- 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]
message: Do not use an empty function, omit the parameter altogether.
- selector: Identifier[name='webcrypto']
message: Use `globalThis.crypto`.

View File

@ -84,7 +84,7 @@ const execOpts = { encoding: 'utf8', shell: true };
// Verify that if something different than Abortcontroller.signal
// is passed, ERR_INVALID_ARG_TYPE is thrown
assert.throws(() => {
const callback = common.mustNotCall(() => {});
const callback = common.mustNotCall();
execFile(process.execPath, [echoFixture, 0], { signal: 'hello' }, callback);
}, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });

View File

@ -64,7 +64,7 @@ async function validateWrongSignalParam() {
// is passed, ERR_INVALID_ARG_TYPE is thrown
await assert.rejects(async () => {
const callback = common.mustNotCall(() => {});
const callback = common.mustNotCall();
await readFile(fn, { signal: 'hello' }, callback);
}, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });

View File

@ -95,7 +95,7 @@ for (const e of fileInfo) {
// Verify that if something different than Abortcontroller.signal
// is passed, ERR_INVALID_ARG_TYPE is thrown
assert.throws(() => {
const callback = common.mustNotCall(() => {});
const callback = common.mustNotCall();
fs.readFile(fileInfo[0].name, { signal: 'hello' }, callback);
}, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });
}

View File

@ -11,7 +11,7 @@ const http2 = require('http2');
const { NghttpError } = require('internal/http2/util');
// Creating an http1 server here...
const server = http.createServer(common.mustNotCall(() => {}))
const server = http.createServer(common.mustNotCall())
.on('clientError', common.mustCall((error, socket) => {
assert.strictEqual(error.code, 'HPE_PAUSED_H2_UPGRADE');
assert.strictEqual(error.bytesParsed, 24);

View File

@ -32,7 +32,7 @@ const server = https.createServer(options, function(req, res) {
path: '/',
ca,
servername: 'nodejs.org',
}, common.mustNotCall(() => {}));
}, common.mustNotCall());
req.on('error', common.mustCall((err) => {
assert.strictEqual(
@ -45,7 +45,7 @@ const server = https.createServer(options, function(req, res) {
path: '/',
ca,
servername: 'nodejs.org',
}, common.mustNotCall(() => {}));
}, common.mustNotCall());
second.on('error', common.mustCall((err) => {
server.close();

View File

@ -1067,8 +1067,7 @@ for (let i = 0; i < 12; i++) {
rli.question('foo?', common.mustCall((answer) => {
assert.strictEqual(answer, 'baz');
}));
rli.question('bar?', common.mustNotCall(() => {
}));
rli.question('bar?', common.mustNotCall());
rli.write('baz\n');
rli.close();
}

View File

@ -169,7 +169,7 @@ const { setTimeout } = require('timers/promises');
{
const stream = Readable.from([1, 2, 3, 4, 5]);
Object.defineProperty(stream, 'map', {
value: common.mustNotCall(() => {}),
value: common.mustNotCall(),
});
// Check that map isn't getting called.
stream.filter(() => true);

View File

@ -124,7 +124,7 @@ function oneTo5() {
{
const stream = oneTo5();
Object.defineProperty(stream, 'map', {
value: common.mustNotCall(() => {}),
value: common.mustNotCall(),
});
// Check that map isn't getting called.
stream.flatMap(() => true);

View File

@ -132,7 +132,7 @@ const { once } = require('events');
{
const stream = Readable.from([1, 2, 3, 4, 5]);
Object.defineProperty(stream, 'map', {
value: common.mustNotCall(() => {}),
value: common.mustNotCall(),
});
// Check that map isn't getting called.
stream.forEach(() => true);

View File

@ -249,7 +249,7 @@ const assert = require('assert');
{
const read = new Readable({
read: common.mustNotCall(function() {})
read: common.mustNotCall()
});
read.destroy();
assert.strictEqual(read.destroyed, true);

View File

@ -14,6 +14,6 @@ stream.on('error', expectsError({
message: 'May not write null values to stream'
}));
stream.on('data', mustNotCall((chunk) => {}));
stream.on('data', mustNotCall());
stream.on('end', mustNotCall());

View File

@ -164,7 +164,7 @@ function oneTo5Async() {
for (const op of ['some', 'every', 'find']) {
const stream = oneTo5();
Object.defineProperty(stream, 'map', {
value: common.mustNotCall(() => {}),
value: common.mustNotCall(),
});
// Check that map isn't getting called.
stream[op](() => {});

View File

@ -5,9 +5,9 @@ const { Worker } = require('worker_threads');
const assert = require('assert');
new Worker(new URL('data:text/javascript,'))
.on('error', common.mustNotCall(() => {}));
.on('error', common.mustNotCall());
new Worker(new URL('data:text/javascript,export{}'))
.on('error', common.mustNotCall(() => {}));
.on('error', common.mustNotCall());
new Worker(new URL('data:text/plain,'))
.on('error', common.mustCall());
@ -15,7 +15,7 @@ new Worker(new URL('data:text/javascript,module.exports={}'))
.on('error', common.mustCall());
new Worker(new URL('data:text/javascript,await Promise.resolve()'))
.on('error', common.mustNotCall(() => {}));
.on('error', common.mustNotCall());
new Worker(new URL('data:text/javascript,await Promise.reject()'))
.on('error', common.mustCall());
new Worker(new URL('data:text/javascript,await new Promise(()=>{})'))