From 5bbc6d79c31e64f70fde9af617482386ed962e2a Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 23 May 2019 10:32:42 -0700 Subject: [PATCH] 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 Reviewed-By: Beth Griggs Reviewed-By: Ouyang Yadong Reviewed-By: Trivikram Kamat --- lib/internal/assert/assertion_error.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/internal/assert/assertion_error.js b/lib/internal/assert/assertion_error.js index 29c5c966a1d596..18d9951af0ddf0 100644 --- a/lib/internal/assert/assertion_error.js +++ b/lib/internal/assert/assertion_error.js @@ -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}`; }