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.
  • Loading branch information
Trott committed May 23, 2019
1 parent 99268b1 commit dbfd01f
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 dbfd01f

Please sign in to comment.