mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
assert: remove unreachable code
There is only one entry in `kReadableOperator` that ends in `Unequal`. So the value assigned on line 392 can only be truthy if `operator` is `notDeepEqual`. Therefore, the ternary condition on line 394 is always true. Remove the ternary. Coverage reports confirm that the removed code is unused. PR-URL: https://github.com/nodejs/node/pull/27840 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com> Reviewed-By: Ouyang Yadong <oyydoibh@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
1 parent
ff8539e9e7
commit
58fc172bfa
1 file changed
+3
-4
@@ -391,10 +391,9 @@ class AssertionError extends Error {
|
||||
if (operator === 'deepEqual') {
|
||||
res = `${knownOperator}\n\n${res}\n\nshould loosely deep-equal\n\n`;
|
||||
} else {
|
||||
const newOperator = kReadableOperator[`${operator}Unequal`];
|
||||
if (newOperator) {
|
||||
const eq = operator === 'notDeepEqual' ? 'deep-equal' : 'equal';
|
||||
res = `${newOperator}\n\n${res}\n\nshould not loosely ${eq}\n\n`;
|
||||
const newOp = kReadableOperator[`${operator}Unequal`];
|
||||
if (newOp) {
|
||||
res = `${newOp}\n\n${res}\n\nshould not loosely deep-equal\n\n`;
|
||||
} else {
|
||||
other = ` ${operator} ${other}`;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user