Skip to content

Commit

Permalink
assert: remove unreachable code
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Trott authored and targos committed May 28, 2019
1 parent 10e0d7f commit 5bbc6d7
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/internal/assert/assertion_error.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}
Expand Down

0 comments on commit 5bbc6d7

Please sign in to comment.