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:
parent
cebbc57ed2
commit
d9f394e607
@ -47,7 +47,7 @@ rules:
|
|||||||
message: Use Number.isNaN() instead of the global isNaN() function.
|
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'])
|
- selector: VariableDeclarator > CallExpression:matches([callee.name='debuglog'], [callee.property.name='debuglog']):not([arguments.0.value='test'])
|
||||||
message: Use 'test' as debuglog value in tests.
|
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.
|
message: Do not use an empty function, omit the parameter altogether.
|
||||||
- selector: Identifier[name='webcrypto']
|
- selector: Identifier[name='webcrypto']
|
||||||
message: Use `globalThis.crypto`.
|
message: Use `globalThis.crypto`.
|
||||||
|
@ -84,7 +84,7 @@ const execOpts = { encoding: 'utf8', shell: true };
|
|||||||
// Verify that if something different than Abortcontroller.signal
|
// Verify that if something different than Abortcontroller.signal
|
||||||
// is passed, ERR_INVALID_ARG_TYPE is thrown
|
// is passed, ERR_INVALID_ARG_TYPE is thrown
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
const callback = common.mustNotCall(() => {});
|
const callback = common.mustNotCall();
|
||||||
|
|
||||||
execFile(process.execPath, [echoFixture, 0], { signal: 'hello' }, callback);
|
execFile(process.execPath, [echoFixture, 0], { signal: 'hello' }, callback);
|
||||||
}, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });
|
}, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });
|
||||||
|
@ -64,7 +64,7 @@ async function validateWrongSignalParam() {
|
|||||||
// is passed, ERR_INVALID_ARG_TYPE is thrown
|
// is passed, ERR_INVALID_ARG_TYPE is thrown
|
||||||
|
|
||||||
await assert.rejects(async () => {
|
await assert.rejects(async () => {
|
||||||
const callback = common.mustNotCall(() => {});
|
const callback = common.mustNotCall();
|
||||||
await readFile(fn, { signal: 'hello' }, callback);
|
await readFile(fn, { signal: 'hello' }, callback);
|
||||||
}, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });
|
}, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ for (const e of fileInfo) {
|
|||||||
// Verify that if something different than Abortcontroller.signal
|
// Verify that if something different than Abortcontroller.signal
|
||||||
// is passed, ERR_INVALID_ARG_TYPE is thrown
|
// is passed, ERR_INVALID_ARG_TYPE is thrown
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
const callback = common.mustNotCall(() => {});
|
const callback = common.mustNotCall();
|
||||||
fs.readFile(fileInfo[0].name, { signal: 'hello' }, callback);
|
fs.readFile(fileInfo[0].name, { signal: 'hello' }, callback);
|
||||||
}, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });
|
}, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ const http2 = require('http2');
|
|||||||
const { NghttpError } = require('internal/http2/util');
|
const { NghttpError } = require('internal/http2/util');
|
||||||
|
|
||||||
// Creating an http1 server here...
|
// Creating an http1 server here...
|
||||||
const server = http.createServer(common.mustNotCall(() => {}))
|
const server = http.createServer(common.mustNotCall())
|
||||||
.on('clientError', common.mustCall((error, socket) => {
|
.on('clientError', common.mustCall((error, socket) => {
|
||||||
assert.strictEqual(error.code, 'HPE_PAUSED_H2_UPGRADE');
|
assert.strictEqual(error.code, 'HPE_PAUSED_H2_UPGRADE');
|
||||||
assert.strictEqual(error.bytesParsed, 24);
|
assert.strictEqual(error.bytesParsed, 24);
|
||||||
|
@ -32,7 +32,7 @@ const server = https.createServer(options, function(req, res) {
|
|||||||
path: '/',
|
path: '/',
|
||||||
ca,
|
ca,
|
||||||
servername: 'nodejs.org',
|
servername: 'nodejs.org',
|
||||||
}, common.mustNotCall(() => {}));
|
}, common.mustNotCall());
|
||||||
|
|
||||||
req.on('error', common.mustCall((err) => {
|
req.on('error', common.mustCall((err) => {
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
@ -45,7 +45,7 @@ const server = https.createServer(options, function(req, res) {
|
|||||||
path: '/',
|
path: '/',
|
||||||
ca,
|
ca,
|
||||||
servername: 'nodejs.org',
|
servername: 'nodejs.org',
|
||||||
}, common.mustNotCall(() => {}));
|
}, common.mustNotCall());
|
||||||
|
|
||||||
second.on('error', common.mustCall((err) => {
|
second.on('error', common.mustCall((err) => {
|
||||||
server.close();
|
server.close();
|
||||||
|
@ -1067,8 +1067,7 @@ for (let i = 0; i < 12; i++) {
|
|||||||
rli.question('foo?', common.mustCall((answer) => {
|
rli.question('foo?', common.mustCall((answer) => {
|
||||||
assert.strictEqual(answer, 'baz');
|
assert.strictEqual(answer, 'baz');
|
||||||
}));
|
}));
|
||||||
rli.question('bar?', common.mustNotCall(() => {
|
rli.question('bar?', common.mustNotCall());
|
||||||
}));
|
|
||||||
rli.write('baz\n');
|
rli.write('baz\n');
|
||||||
rli.close();
|
rli.close();
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ const { setTimeout } = require('timers/promises');
|
|||||||
{
|
{
|
||||||
const stream = Readable.from([1, 2, 3, 4, 5]);
|
const stream = Readable.from([1, 2, 3, 4, 5]);
|
||||||
Object.defineProperty(stream, 'map', {
|
Object.defineProperty(stream, 'map', {
|
||||||
value: common.mustNotCall(() => {}),
|
value: common.mustNotCall(),
|
||||||
});
|
});
|
||||||
// Check that map isn't getting called.
|
// Check that map isn't getting called.
|
||||||
stream.filter(() => true);
|
stream.filter(() => true);
|
||||||
|
@ -124,7 +124,7 @@ function oneTo5() {
|
|||||||
{
|
{
|
||||||
const stream = oneTo5();
|
const stream = oneTo5();
|
||||||
Object.defineProperty(stream, 'map', {
|
Object.defineProperty(stream, 'map', {
|
||||||
value: common.mustNotCall(() => {}),
|
value: common.mustNotCall(),
|
||||||
});
|
});
|
||||||
// Check that map isn't getting called.
|
// Check that map isn't getting called.
|
||||||
stream.flatMap(() => true);
|
stream.flatMap(() => true);
|
||||||
|
@ -132,7 +132,7 @@ const { once } = require('events');
|
|||||||
{
|
{
|
||||||
const stream = Readable.from([1, 2, 3, 4, 5]);
|
const stream = Readable.from([1, 2, 3, 4, 5]);
|
||||||
Object.defineProperty(stream, 'map', {
|
Object.defineProperty(stream, 'map', {
|
||||||
value: common.mustNotCall(() => {}),
|
value: common.mustNotCall(),
|
||||||
});
|
});
|
||||||
// Check that map isn't getting called.
|
// Check that map isn't getting called.
|
||||||
stream.forEach(() => true);
|
stream.forEach(() => true);
|
||||||
|
@ -249,7 +249,7 @@ const assert = require('assert');
|
|||||||
|
|
||||||
{
|
{
|
||||||
const read = new Readable({
|
const read = new Readable({
|
||||||
read: common.mustNotCall(function() {})
|
read: common.mustNotCall()
|
||||||
});
|
});
|
||||||
read.destroy();
|
read.destroy();
|
||||||
assert.strictEqual(read.destroyed, true);
|
assert.strictEqual(read.destroyed, true);
|
||||||
|
@ -14,6 +14,6 @@ stream.on('error', expectsError({
|
|||||||
message: 'May not write null values to stream'
|
message: 'May not write null values to stream'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
stream.on('data', mustNotCall((chunk) => {}));
|
stream.on('data', mustNotCall());
|
||||||
|
|
||||||
stream.on('end', mustNotCall());
|
stream.on('end', mustNotCall());
|
||||||
|
@ -164,7 +164,7 @@ function oneTo5Async() {
|
|||||||
for (const op of ['some', 'every', 'find']) {
|
for (const op of ['some', 'every', 'find']) {
|
||||||
const stream = oneTo5();
|
const stream = oneTo5();
|
||||||
Object.defineProperty(stream, 'map', {
|
Object.defineProperty(stream, 'map', {
|
||||||
value: common.mustNotCall(() => {}),
|
value: common.mustNotCall(),
|
||||||
});
|
});
|
||||||
// Check that map isn't getting called.
|
// Check that map isn't getting called.
|
||||||
stream[op](() => {});
|
stream[op](() => {});
|
||||||
|
@ -5,9 +5,9 @@ const { Worker } = require('worker_threads');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
new Worker(new URL('data:text/javascript,'))
|
new Worker(new URL('data:text/javascript,'))
|
||||||
.on('error', common.mustNotCall(() => {}));
|
.on('error', common.mustNotCall());
|
||||||
new Worker(new URL('data:text/javascript,export{}'))
|
new Worker(new URL('data:text/javascript,export{}'))
|
||||||
.on('error', common.mustNotCall(() => {}));
|
.on('error', common.mustNotCall());
|
||||||
|
|
||||||
new Worker(new URL('data:text/plain,'))
|
new Worker(new URL('data:text/plain,'))
|
||||||
.on('error', common.mustCall());
|
.on('error', common.mustCall());
|
||||||
@ -15,7 +15,7 @@ new Worker(new URL('data:text/javascript,module.exports={}'))
|
|||||||
.on('error', common.mustCall());
|
.on('error', common.mustCall());
|
||||||
|
|
||||||
new Worker(new URL('data:text/javascript,await Promise.resolve()'))
|
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()'))
|
new Worker(new URL('data:text/javascript,await Promise.reject()'))
|
||||||
.on('error', common.mustCall());
|
.on('error', common.mustCall());
|
||||||
new Worker(new URL('data:text/javascript,await new Promise(()=>{})'))
|
new Worker(new URL('data:text/javascript,await new Promise(()=>{})'))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user