Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: remove excess indentation #14090

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/_tls_legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ Object.defineProperty(CryptoStream.prototype, 'bytesWritten', {
CryptoStream.prototype.getPeerCertificate = function(detailed) {
if (this.pair.ssl) {
return common.translatePeerCertificate(
this.pair.ssl.getPeerCertificate(detailed));
this.pair.ssl.getPeerCertificate(detailed));
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ TLSSocket.prototype.setSession = function(session) {
TLSSocket.prototype.getPeerCertificate = function(detailed) {
if (this._handle) {
return common.translatePeerCertificate(
this._handle.getPeerCertificate(detailed));
this._handle.getPeerCertificate(detailed));
}

return null;
Expand Down
7 changes: 3 additions & 4 deletions lib/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ function fatalError(e) {
Error.captureStackTrace(o, fatalError);
process._rawDebug(o.stack);
}
if (process.execArgv.some(
(e) => /^--abort[_-]on[_-]uncaught[_-]exception$/.test(e))) {
if (process.execArgv.some((e) => /^--abort[_-]on[_-]uncaught[_-]exception$/.test(e))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be above 80 chars.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of May, the linter doesn't enforce the line-length rule on lines with regular expression literals. See #12807 for rationale. (Working as intended here too, IMO. I find this much more readable than either the current formatting or any other reasonable formatting I was able to come up with.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose one way to keep it readable and under 80 chars is to assign the regular expression to a variable on the previous line and use the variable here. I would prefer to avoid that because it means this PR is more than formatting changes. I'm not sure how reasonable that is of me, though. :-D

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the info!

I think it would still be nice to move the expression up in it's own variable though, since it prevents the RegExp from being recreated multiple times.

Copy link
Member Author

@Trott Trott Jul 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is inside fatalError() so I don't think RegExp re-creation is an issue. If the RegExp passes, process.abort() is called. If the RegExp fails, process.exit() is called.

process.abort();
}
process.exit(1);
Expand Down Expand Up @@ -434,8 +433,8 @@ function init(asyncId, type, triggerAsyncId, resource) {
for (var i = 0; i < active_hooks_array.length; i++) {
if (typeof active_hooks_array[i][init_symbol] === 'function') {
active_hooks_array[i][init_symbol](
asyncId, type, triggerAsyncId,
resource
asyncId, type, triggerAsyncId,
resource
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ function slowIndexOf(buffer, val, byteOffset, encoding, dir) {
case 'ascii':
case 'hex':
return binding.indexOfBuffer(
buffer, Buffer.from(val, encoding), byteOffset, encoding, dir);
buffer, Buffer.from(val, encoding), byteOffset, encoding, dir);

default:
if (loweredCase) {
Expand Down
8 changes: 4 additions & 4 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ exports.fork = function(modulePath /*, args, options*/) {
// Use a separate fd=3 for the IPC channel. Inherit stdin, stdout,
// and stderr from the parent if silent isn't set.
options.stdio = options.silent ? stdioStringToArray('pipe') :
stdioStringToArray('inherit');
stdioStringToArray('inherit');
} else if (options.stdio.indexOf('ipc') === -1) {
throw new TypeError('Forked processes must have an IPC channel');
}
Expand Down Expand Up @@ -539,9 +539,9 @@ function spawnSync(/*file, args, options*/) {
pipe.input = Buffer.from(input, options.encoding);
} else {
throw new TypeError(util.format(
'stdio[%d] should be Buffer, Uint8Array or string not %s',
i,
typeof input));
'stdio[%d] should be Buffer, Uint8Array or string not %s',
i,
typeof input));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ function pbkdf2(password, salt, iterations, keylen, digest, callback) {

if (digest === undefined) {
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);
Expand Down
31 changes: 16 additions & 15 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,20 +172,21 @@ function isFd(path) {

// Constructor for file stats.
function Stats(
dev,
mode,
nlink,
uid,
gid,
rdev,
blksize,
ino,
size,
blocks,
atim_msec,
mtim_msec,
ctim_msec,
birthtim_msec) {
dev,
mode,
nlink,
uid,
gid,
rdev,
blksize,
ino,
size,
blocks,
atim_msec,
mtim_msec,
ctim_msec,
birthtim_msec
) {
this.dev = dev;
this.mode = mode;
this.nlink = nlink;
Expand Down Expand Up @@ -1285,7 +1286,7 @@ fs.writeFile = function(path, data, options, callback) {

function writeFd(fd, isUserFd) {
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;

writeAll(fd, isUserFd, buffer, 0, buffer.length, position, callback);
Expand Down
6 changes: 3 additions & 3 deletions lib/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ class Session extends EventEmitter {
post(method, params, callback) {
if (typeof method !== 'string') {
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)) {
callback = params;
params = null;
}
if (params && typeof params !== 'object') {
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') {
throw new TypeError(
`"callback" must be a function, got ${typeof callback} instead`);
`"callback" must be a function, got ${typeof callback} instead`);
}

if (!this[connectionSymbol]) {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/bootstrap_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@
if (async_hook_fields[kAfter] > 0) {
do {
NativeModule.require('async_hooks').emitAfter(
async_uid_fields[kCurrentAsyncId]);
async_uid_fields[kCurrentAsyncId]);
// popAsyncIds() returns true if there are more ids on the stack.
} while (popAsyncIds(async_uid_fields[kCurrentAsyncId]));
// Or completely empty the id stack.
Expand Down
8 changes: 4 additions & 4 deletions lib/internal/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ ChildProcess.prototype.spawn = function(options) {
// when i === 0 - we're dealing with stdin
// (which is the only one writable pipe)
stream.socket = createSocket(this.pid !== 0 ?
stream.handle : null, i > 0);
stream.handle : null, i > 0);

if (i > 0 && this.pid !== 0) {
this._closesNeeded++;
Expand All @@ -359,11 +359,11 @@ ChildProcess.prototype.spawn = function(options) {
}

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 ?
stdio[1].socket : null;
stdio[1].socket : null;
this.stderr = stdio.length >= 3 && stdio[2].socket !== undefined ?
stdio[2].socket : null;
stdio[2].socket : null;

this.stdio = [];

Expand Down
7 changes: 5 additions & 2 deletions lib/internal/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ if (process.binding('config').hasIntl) {

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

Expand Down
8 changes: 4 additions & 4 deletions lib/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,12 +736,12 @@ Interface.prototype._moveCursor = function(dx) {
var diffWidth;
if (diffCursor < 0) {
diffWidth = -getStringWidth(
this.line.substring(this.cursor, oldcursor)
);
this.line.substring(this.cursor, oldcursor)
);
} else if (diffCursor > 0) {
diffWidth = getStringWidth(
this.line.substring(this.cursor, oldcursor)
);
this.line.substring(this.cursor, oldcursor)
);
}
moveCursor(this.output, diffWidth, 0);
this.prevRows = newPos.rows;
Expand Down
2 changes: 1 addition & 1 deletion lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ function listOnTimeout() {
function tryOnTimeout(timer, list) {
timer._called = true;
const timerAsyncId = (typeof timer[async_id_symbol] === 'number') ?
timer[async_id_symbol] : null;
timer[async_id_symbol] : null;
var threw = true;
if (timerAsyncId !== null)
emitBefore(timerAsyncId, timer[trigger_id_symbol]);
Expand Down
2 changes: 1 addition & 1 deletion lib/tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) {

if (!valid) {
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.host = host;
err.cert = cert;
Expand Down
7 changes: 3 additions & 4 deletions lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,7 @@ Url.prototype.resolveObject = function resolveObject(relative) {

var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/');
var isRelAbs = (
relative.host ||
relative.pathname && relative.pathname.charAt(0) === '/'
relative.host || relative.pathname && relative.pathname.charAt(0) === '/'
);
var mustEndAbs = (isRelAbs || isSourceAbs ||
(result.host && relative.pathname));
Expand Down Expand Up @@ -865,8 +864,8 @@ Url.prototype.resolveObject = function resolveObject(relative) {
// then it must NOT get a trailing slash.
var last = srcPath.slice(-1)[0];
var hasTrailingSlash = (
(result.host || relative.host || srcPath.length > 1) &&
(last === '.' || last === '..') || last === '');
(result.host || relative.host || srcPath.length > 1) &&
(last === '.' || last === '..') || last === '');

// strip single dots, resolve double dots to parent dir
// if the path tries to go above the root, `up` ends up > 0
Expand Down
4 changes: 2 additions & 2 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ function formatValue(ctx, value, recurseTimes) {
if (typeof value === 'function') {
const ctorName = constructor ? constructor.name : 'Function';
return ctx.stylize(
`[${ctorName}${value.name ? `: ${value.name}` : ''}]`, 'special');
`[${ctorName}${value.name ? `: ${value.name}` : ''}]`, 'special');
}
if (isRegExp(value)) {
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
Expand Down Expand Up @@ -695,7 +695,7 @@ function formatTypedArray(ctx, value, recurseTimes, visibleKeys, keys) {
for (const key of keys) {
if (typeof key === 'symbol' || !numbersOnlyRE.test(key)) {
output.push(
formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
}
}
return output;
Expand Down