Skip to content

Commit

Permalink
Remove unused variables (#3061)
Browse files Browse the repository at this point in the history
* Remove unused variables

* Change errorDiff()

* Remove escapeInvisibles()
  • Loading branch information
38elements authored and boneskull committed Oct 27, 2017
1 parent 2303c66 commit 1bb6b39
Showing 1 changed file with 7 additions and 31 deletions.
38 changes: 7 additions & 31 deletions lib/reporters/base.js
Expand Up @@ -185,7 +185,6 @@ exports.list = function (failures) {
var index = message ? stack.indexOf(message) : -1;
var actual = err.actual;
var expected = err.expected;
var escape = true;

if (index === -1) {
msg = message;
Expand All @@ -202,7 +201,6 @@ exports.list = function (failures) {
}
// explicitly show diff
if (err.showDiff !== false && sameType(actual, expected) && expected !== undefined) {
escape = false;
if (!(utils.isString(actual) && utils.isString(expected))) {
err.actual = actual = utils.stringify(actual);
err.expected = expected = utils.stringify(expected);
Expand All @@ -213,9 +211,9 @@ exports.list = function (failures) {
msg = '\n ' + color('error message', match ? match[1] : msg);

if (exports.inlineDiffs) {
msg += inlineDiff(err, escape);
msg += inlineDiff(err);
} else {
msg += unifiedDiff(err, escape);
msg += unifiedDiff(err);
}
}

Expand Down Expand Up @@ -366,11 +364,10 @@ function pad (str, len) {
*
* @api private
* @param {Error} err with actual/expected
* @param {boolean} escape
* @return {string} Diff
*/
function inlineDiff (err, escape) {
var msg = errorDiff(err, 'WordsWithSpace', escape);
function inlineDiff (err) {
var msg = errorDiff(err);

// linenos
var lines = msg.split('\n');
Expand Down Expand Up @@ -400,15 +397,11 @@ function inlineDiff (err, escape) {
*
* @api private
* @param {Error} err with actual/expected
* @param {boolean} escape
* @return {string} The diff.
*/
function unifiedDiff (err, escape) {
function unifiedDiff (err) {
var indent = ' ';
function cleanUp (line) {
if (escape) {
line = escapeInvisibles(line);
}
if (line[0] === '+') {
return indent + colorLines('diff added', line);
}
Expand Down Expand Up @@ -440,14 +433,10 @@ function unifiedDiff (err, escape) {
*
* @api private
* @param {Error} err
* @param {string} type
* @param {boolean} escape
* @return {string}
*/
function errorDiff (err, type, escape) {
var actual = escape ? escapeInvisibles(err.actual) : err.actual;
var expected = escape ? escapeInvisibles(err.expected) : err.expected;
return diff['diff' + type](actual, expected).map(function (str) {
function errorDiff (err) {
return diff.diffWordsWithSpace(err.actual, err.expected).map(function (str) {
if (str.added) {
return colorLines('diff added', str.value);
}
Expand All @@ -458,19 +447,6 @@ function errorDiff (err, type, escape) {
}).join('');
}

/**
* Returns a string with all invisible characters in plain text
*
* @api private
* @param {string} line
* @return {string}
*/
function escapeInvisibles (line) {
return line.replace(/\t/g, '<tab>')
.replace(/\r/g, '<CR>')
.replace(/\n/g, '<LF>\n');
}

/**
* Color lines for `str`, using the color `name`.
*
Expand Down

0 comments on commit 1bb6b39

Please sign in to comment.