From 530e63a4eb561077ac926d43018025ca8dc4ddaa Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 20 May 2019 16:27:37 -0700 Subject: [PATCH] assert: remove unreachable code In lib/internal/assert/assertion_error.js, line 391 assures that `operator` is 'deepEqual' so there is no need to check the value of `operator` in a ternary on the next line (line 392). Remove the ternary. PR-URL: https://github.com/nodejs/node/pull/27786 Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Yongsheng Zhang Reviewed-By: Richard Lau Reviewed-By: Trivikram Kamat Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- 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 7b62fca0352f5d..29c5c966a1d596 100644 --- a/lib/internal/assert/assertion_error.js +++ b/lib/internal/assert/assertion_error.js @@ -374,9 +374,9 @@ class AssertionError extends Error { } else { let res = inspectValue(actual); let other = inspectValue(expected); - const knownOperators = kReadableOperator[operator]; + const knownOperator = kReadableOperator[operator]; if (operator === 'notDeepEqual' && res === other) { - res = `${knownOperators}\n\n${res}`; + res = `${knownOperator}\n\n${res}`; if (res.length > 1024) { res = `${res.slice(0, 1021)}...`; } @@ -389,8 +389,7 @@ class AssertionError extends Error { other = `${other.slice(0, 509)}...`; } if (operator === 'deepEqual') { - const eq = operator === 'deepEqual' ? 'deep-equal' : 'equal'; - res = `${knownOperators}\n\n${res}\n\nshould loosely ${eq}\n\n`; + res = `${knownOperator}\n\n${res}\n\nshould loosely deep-equal\n\n`; } else { const newOperator = kReadableOperator[`${operator}Unequal`]; if (newOperator) {