more 'make check' jsstyle fixes

This commit is contained in:
Trent Mick 2013-03-28 17:39:00 -07:00
parent c9f05b6743
commit 7a6c3f5ce6
11 changed files with 78 additions and 73 deletions

View file

@ -20,8 +20,8 @@ var child_process = require('child_process'),
var assert = require('assert');
var nodeSpawnSupportsStdio = (
Number(process.version.split('.')[0]) >= 0
|| Number(process.version.split('.')[1]) >= 8);
Number(process.version.split('.')[0]) >= 0 ||
Number(process.version.split('.')[1]) >= 8);
@ -103,6 +103,7 @@ function getVersion() {
var format = util.format;
if (!format) {
/* BEGIN JSSTYLED */
// If not node 0.6, then use its `util.format`:
// <https://github.com/joyent/node/blob/master/lib/util.js#L22>:
var inspect = util.inspect;
@ -140,6 +141,7 @@ if (!format) {
}
return str;
};
/* END JSSTYLED */
}
function indent(s) {
@ -438,7 +440,7 @@ function parseArgv(argv) {
}
parsed.outputMode = OM_FROM_NAME[name];
if (parsed.outputMode === undefined) {
throw new Error('unknown output mode: \''+name+"'");
throw new Error('unknown output mode: "'+name+'"');
}
break;
case '-j': // output with JSON.stringify
@ -1186,6 +1188,7 @@ function processFile(file, opts, stylize, callback) {
/**
* From node async module.
*/
/* BEGIN JSSTYLED */
function asyncForEach(arr, iterator, callback) {
callback = callback || function () {};
if (!arr.length) {
@ -1207,6 +1210,7 @@ function asyncForEach(arr, iterator, callback) {
});
});
};
/* END JSSTYLED */
@ -1316,7 +1320,7 @@ function main(argv) {
return;
}
if (opts.pid && opts.args.length > 0) {
warn("bunyan: error: can't use both '-p PID' (%s) and file (%s) args",
warn('bunyan: error: can\'t use both "-p PID" (%s) and file (%s) args',
opts.pid, opts.args.join(' '));
return drainStdoutAndExit(1);
}
@ -1334,18 +1338,19 @@ function main(argv) {
// Pager.
var nodeVer = process.versions.node.split('.').map(Number);
var paginate = (
process.stdout.isTTY
&& process.stdin.isTTY
&& !opts.pids // Don't page if following process output.
&& opts.args.length > 0 // Don't page if no file args to process.
&& process.platform !== 'win32'
&& nodeVer >= [0,8,0]
&& (opts.paginate === true
|| (opts.paginate !== false
&& (!process.env.BUNYAN_NO_PAGER
|| process.env.BUNYAN_NO_PAGER.length === 0))));
process.stdout.isTTY &&
process.stdin.isTTY &&
!opts.pids && // Don't page if following process output.
opts.args.length > 0 && // Don't page if no file args to process.
process.platform !== 'win32' &&
nodeVer >= [0, 8, 0] &&
(opts.paginate === true ||
(opts.paginate !== false &&
(!process.env.BUNYAN_NO_PAGER ||
process.env.BUNYAN_NO_PAGER.length === 0))));
if (paginate) {
var pagerCmd = process.env.PAGER || 'less';
/* JSSTYLED */
assert.ok(pagerCmd.indexOf('"') === -1 && pagerCmd.indexOf("'") === -1,
'cannot parse PAGER quotes yet');
var argv = pagerCmd.split(/\s+/g);

View file

@ -50,7 +50,7 @@ function logOne() {
var msg = [randchoice(words), randchoice(words)].join(' ');
var delay = randint(300);
//console.warn('long-running about to log.%s(..., "%s")', level, msg)
log[level]({"word": randchoice(words), "delay": delay}, msg);
log[level]({'word': randchoice(words), 'delay': delay}, msg);
timeout = setTimeout(logOne, delay);
}

View file

@ -638,8 +638,9 @@ Logger.prototype._applySerializers = function (fields, excludeFields) {
// Check each serializer against these (presuming number of serializers
// is typically less than number of fields).
Object.keys(this.serializers).forEach(function (name) {
if (fields[name] === undefined
|| (excludeFields && excludeFields[name])) {
if (fields[name] === undefined ||
(excludeFields && excludeFields[name]))
{
return;
}
xxx('_applySerializers; apply to "%s" key', name)
@ -900,7 +901,7 @@ var errSerializer = Logger.stdSerializers.err = function err(err) {
function safeCycles() {
var seen = [];
return function (key, val) {
if (!val || typeof val !== 'object') {
if (!val || typeof (val) !== 'object') {
return val;
}
if (seen.indexOf(val) !== -1) {

View file

@ -48,10 +48,10 @@ test('log.info(BUFFER)', function (t) {
var rec = catcher.records[catcher.records.length - 1];
t.equal(rec.msg, inspect(b),
format('log.%s msg is inspect(BUFFER)', lvl));
t.ok(rec["0"] === undefined,
'no "0" array index key in record: ' + inspect(rec["0"]));
t.ok(rec["parent"] === undefined,
'no "parent" array index key in record: ' + inspect(rec["parent"]));
t.ok(rec['0'] === undefined,
'no "0" array index key in record: ' + inspect(rec['0']));
t.ok(rec['parent'] === undefined,
'no "parent" array index key in record: ' + inspect(rec['parent']));
log[lvl].call(log, b, 'bar');
var rec = catcher.records[catcher.records.length - 1];

View file

@ -31,27 +31,27 @@ outstr.end = function (c) {
var expect =
[
{
"name": "blammo",
"level": 30,
"msg": "bango { bang: 'boom', KABOOM: [Circular] }",
"v": 0
'name': 'blammo',
'level': 30,
'msg': 'bango { bang: \'boom\', KABOOM: [Circular] }',
'v': 0
},
{
"name": "blammo",
"level": 30,
"msg": "kaboom { bang: 'boom', KABOOM: [Circular] }",
"v": 0
'name': 'blammo',
'level': 30,
'msg': 'kaboom { bang: \'boom\', KABOOM: [Circular] }',
'v': 0
},
{
"name": "blammo",
"level": 30,
"bang": "boom",
"KABOOM": {
"bang": "boom",
"KABOOM": "[Circular]"
'name': 'blammo',
'level': 30,
'bang': 'boom',
'KABOOM': {
'bang': 'boom',
'KABOOM': '[Circular]'
},
"msg": "",
"v": 0
'msg': '',
'v': 0
}
];

View file

@ -47,15 +47,15 @@ test('basic dtrace', function (t) {
'bunyan$target:::log-*{printf("%s", copyinstr(arg0))}',
'-c', format('node %s/log-some.js', __dirname)];
var dtrace = spawn(argv[0], argv.slice(1));
//console.error("ARGV: %j", argv);
//console.error('ARGV: %j', argv);
var traces = [];
dtrace.stdout.on('data', function (data) {
//console.error("DTRACE STDOUT:", data.toString());
//console.error('DTRACE STDOUT:', data.toString());
traces.push(data.toString());
});
dtrace.stderr.on('data', function (data) {
console.error("DTRACE STDERR:", data.toString());
console.error('DTRACE STDERR:', data.toString());
});
dtrace.on('exit', function (code) {
t.notOk(code, 'dtrace exited cleanly');

View file

@ -10,4 +10,3 @@ var log = bunyan.createLogger({
});
log.debug({foo: 'bar'}, 'hi at debug')
log.trace('hi at trace')

View file

@ -52,7 +52,7 @@ test('req serializer', function (t) {
{'foo':'bar'}
];
for (var i = 0; i < bogusReqs.length; i++) {
log.info({req: bogusReqs[i]}, "hi");
log.info({req: bogusReqs[i]}, 'hi');
t.equal(records[i].req, bogusReqs[i]);
}
@ -110,7 +110,7 @@ test('res serializer', function (t) {
{'foo':'bar'}
];
for (var i = 0; i < bogusRess.length; i++) {
log.info({res: bogusRess[i]}, "hi");
log.info({res: bogusRess[i]}, 'hi');
t.equal(records[i].res, bogusRess[i]);
}
@ -166,7 +166,7 @@ test('err serializer', function (t) {
{'foo':'bar'}
];
for (var i = 0; i < bogusErrs.length; i++) {
log.info({err: bogusErrs[i]}, "hi");
log.info({err: bogusErrs[i]}, 'hi');
t.equal(records[i].err, bogusErrs[i]);
}