lib: remove excess indentation

In anticipation of stricter linting for indentation, remove instances of
extra indentation that will be flagged by the new rules.

PR-URL: https://github.com/nodejs/node/pull/14090
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Rich Trott 2017-07-05 09:21:40 -07:00
parent 49d13a17b1
commit 0d22858d67
16 changed files with 51 additions and 49 deletions

View File

@ -384,7 +384,7 @@ Object.defineProperty(CryptoStream.prototype, 'bytesWritten', {
CryptoStream.prototype.getPeerCertificate = function(detailed) { CryptoStream.prototype.getPeerCertificate = function(detailed) {
if (this.pair.ssl) { if (this.pair.ssl) {
return common.translatePeerCertificate( return common.translatePeerCertificate(
this.pair.ssl.getPeerCertificate(detailed)); this.pair.ssl.getPeerCertificate(detailed));
} }
return null; return null;

View File

@ -659,7 +659,7 @@ TLSSocket.prototype.setSession = function(session) {
TLSSocket.prototype.getPeerCertificate = function(detailed) { TLSSocket.prototype.getPeerCertificate = function(detailed) {
if (this._handle) { if (this._handle) {
return common.translatePeerCertificate( return common.translatePeerCertificate(
this._handle.getPeerCertificate(detailed)); this._handle.getPeerCertificate(detailed));
} }
return null; return null;

View File

@ -71,8 +71,7 @@ function fatalError(e) {
Error.captureStackTrace(o, fatalError); Error.captureStackTrace(o, fatalError);
process._rawDebug(o.stack); process._rawDebug(o.stack);
} }
if (process.execArgv.some( if (process.execArgv.some((e) => /^--abort[_-]on[_-]uncaught[_-]exception$/.test(e))) {
(e) => /^--abort[_-]on[_-]uncaught[_-]exception$/.test(e))) {
process.abort(); process.abort();
} }
process.exit(1); process.exit(1);
@ -434,8 +433,8 @@ function init(asyncId, type, triggerAsyncId, resource) {
for (var i = 0; i < active_hooks_array.length; i++) { for (var i = 0; i < active_hooks_array.length; i++) {
if (typeof active_hooks_array[i][init_symbol] === 'function') { if (typeof active_hooks_array[i][init_symbol] === 'function') {
active_hooks_array[i][init_symbol]( active_hooks_array[i][init_symbol](
asyncId, type, triggerAsyncId, asyncId, type, triggerAsyncId,
resource resource
); );
} }
} }

View File

@ -763,7 +763,7 @@ function slowIndexOf(buffer, val, byteOffset, encoding, dir) {
case 'ascii': case 'ascii':
case 'hex': case 'hex':
return binding.indexOfBuffer( return binding.indexOfBuffer(
buffer, Buffer.from(val, encoding), byteOffset, encoding, dir); buffer, Buffer.from(val, encoding), byteOffset, encoding, dir);
default: default:
if (loweredCase) { if (loweredCase) {

View File

@ -87,7 +87,7 @@ exports.fork = function(modulePath /*, args, options*/) {
// Use a separate fd=3 for the IPC channel. Inherit stdin, stdout, // Use a separate fd=3 for the IPC channel. Inherit stdin, stdout,
// and stderr from the parent if silent isn't set. // and stderr from the parent if silent isn't set.
options.stdio = options.silent ? stdioStringToArray('pipe') : options.stdio = options.silent ? stdioStringToArray('pipe') :
stdioStringToArray('inherit'); stdioStringToArray('inherit');
} else if (options.stdio.indexOf('ipc') === -1) { } else if (options.stdio.indexOf('ipc') === -1) {
throw new TypeError('Forked processes must have an IPC channel'); throw new TypeError('Forked processes must have an IPC channel');
} }
@ -539,9 +539,9 @@ function spawnSync(/*file, args, options*/) {
pipe.input = Buffer.from(input, options.encoding); pipe.input = Buffer.from(input, options.encoding);
} else { } else {
throw new TypeError(util.format( throw new TypeError(util.format(
'stdio[%d] should be Buffer, Uint8Array or string not %s', 'stdio[%d] should be Buffer, Uint8Array or string not %s',
i, i,
typeof input)); typeof input));
} }
} }
} }

View File

@ -633,7 +633,7 @@ function pbkdf2(password, salt, iterations, keylen, digest, callback) {
if (digest === undefined) { if (digest === undefined) {
throw new TypeError( throw new TypeError(
'The "digest" argument is required and must not be undefined'); 'The "digest" argument is required and must not be undefined');
} }
password = toBuf(password); password = toBuf(password);

View File

@ -172,20 +172,21 @@ function isFd(path) {
// Constructor for file stats. // Constructor for file stats.
function Stats( function Stats(
dev, dev,
mode, mode,
nlink, nlink,
uid, uid,
gid, gid,
rdev, rdev,
blksize, blksize,
ino, ino,
size, size,
blocks, blocks,
atim_msec, atim_msec,
mtim_msec, mtim_msec,
ctim_msec, ctim_msec,
birthtim_msec) { birthtim_msec
) {
this.dev = dev; this.dev = dev;
this.mode = mode; this.mode = mode;
this.nlink = nlink; this.nlink = nlink;
@ -1285,7 +1286,7 @@ fs.writeFile = function(path, data, options, callback) {
function writeFd(fd, isUserFd) { function writeFd(fd, isUserFd) {
var buffer = isUint8Array(data) ? var buffer = isUint8Array(data) ?
data : Buffer.from('' + data, options.encoding || 'utf8'); data : Buffer.from('' + data, options.encoding || 'utf8');
var position = /a/.test(flag) ? null : 0; var position = /a/.test(flag) ? null : 0;
writeAll(fd, isUserFd, buffer, 0, buffer.length, position, callback); writeAll(fd, isUserFd, buffer, 0, buffer.length, position, callback);

View File

@ -43,7 +43,7 @@ class Session extends EventEmitter {
post(method, params, callback) { post(method, params, callback) {
if (typeof method !== 'string') { if (typeof method !== 'string') {
throw new TypeError( throw new TypeError(
`"method" must be a string, got ${typeof method} instead`); `"method" must be a string, got ${typeof method} instead`);
} }
if (!callback && util.isFunction(params)) { if (!callback && util.isFunction(params)) {
callback = params; callback = params;
@ -51,11 +51,11 @@ class Session extends EventEmitter {
} }
if (params && typeof params !== 'object') { if (params && typeof params !== 'object') {
throw new TypeError( throw new TypeError(
`"params" must be an object, got ${typeof params} instead`); `"params" must be an object, got ${typeof params} instead`);
} }
if (callback && typeof callback !== 'function') { if (callback && typeof callback !== 'function') {
throw new TypeError( throw new TypeError(
`"callback" must be a function, got ${typeof callback} instead`); `"callback" must be a function, got ${typeof callback} instead`);
} }
if (!this[connectionSymbol]) { if (!this[connectionSymbol]) {

View File

@ -348,7 +348,7 @@
if (async_hook_fields[kAfter] > 0) { if (async_hook_fields[kAfter] > 0) {
do { do {
NativeModule.require('async_hooks').emitAfter( NativeModule.require('async_hooks').emitAfter(
async_uid_fields[kCurrentAsyncId]); async_uid_fields[kCurrentAsyncId]);
// popAsyncIds() returns true if there are more ids on the stack. // popAsyncIds() returns true if there are more ids on the stack.
} while (popAsyncIds(async_uid_fields[kCurrentAsyncId])); } while (popAsyncIds(async_uid_fields[kCurrentAsyncId]));
// Or completely empty the id stack. // Or completely empty the id stack.

View File

@ -347,7 +347,7 @@ ChildProcess.prototype.spawn = function(options) {
// when i === 0 - we're dealing with stdin // when i === 0 - we're dealing with stdin
// (which is the only one writable pipe) // (which is the only one writable pipe)
stream.socket = createSocket(this.pid !== 0 ? stream.socket = createSocket(this.pid !== 0 ?
stream.handle : null, i > 0); stream.handle : null, i > 0);
if (i > 0 && this.pid !== 0) { if (i > 0 && this.pid !== 0) {
this._closesNeeded++; this._closesNeeded++;
@ -359,11 +359,11 @@ ChildProcess.prototype.spawn = function(options) {
} }
this.stdin = stdio.length >= 1 && stdio[0].socket !== undefined ? this.stdin = stdio.length >= 1 && stdio[0].socket !== undefined ?
stdio[0].socket : null; stdio[0].socket : null;
this.stdout = stdio.length >= 2 && stdio[1].socket !== undefined ? this.stdout = stdio.length >= 2 && stdio[1].socket !== undefined ?
stdio[1].socket : null; stdio[1].socket : null;
this.stderr = stdio.length >= 3 && stdio[2].socket !== undefined ? this.stderr = stdio.length >= 3 && stdio[2].socket !== undefined ?
stdio[2].socket : null; stdio[2].socket : null;
this.stdio = []; this.stdio = [];

View File

@ -84,7 +84,8 @@ if (process.binding('config').hasIntl) {
// Code points are derived from: // Code points are derived from:
// http://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt // http://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt
if (code >= 0x1100 && ( if (
code >= 0x1100 && (
code <= 0x115f || // Hangul Jamo code <= 0x115f || // Hangul Jamo
0x2329 === code || // LEFT-POINTING ANGLE BRACKET 0x2329 === code || // LEFT-POINTING ANGLE BRACKET
0x232a === code || // RIGHT-POINTING ANGLE BRACKET 0x232a === code || // RIGHT-POINTING ANGLE BRACKET
@ -112,7 +113,9 @@ if (process.binding('config').hasIntl) {
// Enclosed Ideographic Supplement // Enclosed Ideographic Supplement
0x1f200 <= code && code <= 0x1f251 || 0x1f200 <= code && code <= 0x1f251 ||
// CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
0x20000 <= code && code <= 0x3fffd)) { 0x20000 <= code && code <= 0x3fffd
)
) {
return true; return true;
} }

View File

@ -736,12 +736,12 @@ Interface.prototype._moveCursor = function(dx) {
var diffWidth; var diffWidth;
if (diffCursor < 0) { if (diffCursor < 0) {
diffWidth = -getStringWidth( diffWidth = -getStringWidth(
this.line.substring(this.cursor, oldcursor) this.line.substring(this.cursor, oldcursor)
); );
} else if (diffCursor > 0) { } else if (diffCursor > 0) {
diffWidth = getStringWidth( diffWidth = getStringWidth(
this.line.substring(this.cursor, oldcursor) this.line.substring(this.cursor, oldcursor)
); );
} }
moveCursor(this.output, diffWidth, 0); moveCursor(this.output, diffWidth, 0);
this.prevRows = newPos.rows; this.prevRows = newPos.rows;

View File

@ -296,7 +296,7 @@ function listOnTimeout() {
function tryOnTimeout(timer, list) { function tryOnTimeout(timer, list) {
timer._called = true; timer._called = true;
const timerAsyncId = (typeof timer[async_id_symbol] === 'number') ? const timerAsyncId = (typeof timer[async_id_symbol] === 'number') ?
timer[async_id_symbol] : null; timer[async_id_symbol] : null;
var threw = true; var threw = true;
if (timerAsyncId !== null) if (timerAsyncId !== null)
emitBefore(timerAsyncId, timer[trigger_id_symbol]); emitBefore(timerAsyncId, timer[trigger_id_symbol]);

View File

@ -220,7 +220,7 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) {
if (!valid) { if (!valid) {
const err = new Error( const err = new Error(
`Hostname/IP doesn't match certificate's altnames: "${reason}"`); `Hostname/IP doesn't match certificate's altnames: "${reason}"`);
err.reason = reason; err.reason = reason;
err.host = host; err.host = host;
err.cert = cert; err.cert = cert;

View File

@ -760,8 +760,7 @@ Url.prototype.resolveObject = function resolveObject(relative) {
var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'); var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/');
var isRelAbs = ( var isRelAbs = (
relative.host || relative.host || relative.pathname && relative.pathname.charAt(0) === '/'
relative.pathname && relative.pathname.charAt(0) === '/'
); );
var mustEndAbs = (isRelAbs || isSourceAbs || var mustEndAbs = (isRelAbs || isSourceAbs ||
(result.host && relative.pathname)); (result.host && relative.pathname));
@ -865,8 +864,8 @@ Url.prototype.resolveObject = function resolveObject(relative) {
// then it must NOT get a trailing slash. // then it must NOT get a trailing slash.
var last = srcPath.slice(-1)[0]; var last = srcPath.slice(-1)[0];
var hasTrailingSlash = ( var hasTrailingSlash = (
(result.host || relative.host || srcPath.length > 1) && (result.host || relative.host || srcPath.length > 1) &&
(last === '.' || last === '..') || last === ''); (last === '.' || last === '..') || last === '');
// strip single dots, resolve double dots to parent dir // strip single dots, resolve double dots to parent dir
// if the path tries to go above the root, `up` ends up > 0 // if the path tries to go above the root, `up` ends up > 0

View File

@ -400,7 +400,7 @@ function formatValue(ctx, value, recurseTimes) {
if (typeof value === 'function') { if (typeof value === 'function') {
const ctorName = constructor ? constructor.name : 'Function'; const ctorName = constructor ? constructor.name : 'Function';
return ctx.stylize( return ctx.stylize(
`[${ctorName}${value.name ? `: ${value.name}` : ''}]`, 'special'); `[${ctorName}${value.name ? `: ${value.name}` : ''}]`, 'special');
} }
if (isRegExp(value)) { if (isRegExp(value)) {
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
@ -695,7 +695,7 @@ function formatTypedArray(ctx, value, recurseTimes, visibleKeys, keys) {
for (const key of keys) { for (const key of keys) {
if (typeof key === 'symbol' || !numbersOnlyRE.test(key)) { if (typeof key === 'symbol' || !numbersOnlyRE.test(key)) {
output.push( output.push(
formatProperty(ctx, value, recurseTimes, visibleKeys, key, true)); formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
} }
} }
return output; return output;