Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5bbc6d7

Browse filesBrowse files
Trotttargos
authored andcommitted
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: #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>
1 parent 10e0d7f commit 5bbc6d7
Copy full SHA for 5bbc6d7

File tree

Expand file treeCollapse file tree

1 file changed

+3
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-4
lines changed
Open diff view settings
Collapse file

‎lib/internal/assert/assertion_error.js‎

Copy file name to clipboardExpand all lines: lib/internal/assert/assertion_error.js
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,9 @@ class AssertionError extends Error {
391391
if (operator === 'deepEqual') {
392392
res = `${knownOperator}\n\n${res}\n\nshould loosely deep-equal\n\n`;
393393
} else {
394-
const newOperator = kReadableOperator[`${operator}Unequal`];
395-
if (newOperator) {
396-
const eq = operator === 'notDeepEqual' ? 'deep-equal' : 'equal';
397-
res = `${newOperator}\n\n${res}\n\nshould not loosely ${eq}\n\n`;
394+
const newOp = kReadableOperator[`${operator}Unequal`];
395+
if (newOp) {
396+
res = `${newOp}\n\n${res}\n\nshould not loosely deep-equal\n\n`;
398397
} else {
399398
other = ` ${operator} ${other}`;
400399
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.