Skip to content

Commit 06c5f19

Browse files
author
Ruben Bridgewater
committed
Add jshint and fix errors accordingly (including broken tests)
1 parent f7ac0e5 commit 06c5f19

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+290
-182
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules
22
.tern-port
33
.nyc_output
44
coverage
5+
npm-debug.log

.jshintrc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"eqeqeq": true, // Prohibits the use of == and != in favor of === and !==
3+
"noarg": true, // Prohibit use of `arguments.caller` and `arguments.callee`
4+
"undef": true, // Require all non-global variables be declared before they are used.
5+
"unused": "vars", // Warn unused variables, but not unused params
6+
"strict": true, // Require `use strict` pragma in every file.
7+
"nonbsp": true, // don't allow non utf-8 pages to break
8+
"forin": true, // don't allow not filtert for in loops
9+
"freeze": true, // prohibit overwriting prototypes of native objects
10+
"nonew": true, // prohibit use of constructors with new when not assigning to a variable
11+
"maxdepth": 6,
12+
"latedef": true,
13+
"maxparams": 5,
14+
15+
// Environment options
16+
"node": true, // Enable globals available when code is running inside of the NodeJS runtime environment.
17+
"mocha": true,
18+
19+
"overrides": {
20+
"examples/*.js": {
21+
"unused": false
22+
}
23+
}
24+
}

benches/re_sub_test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
'use strict';
22

3-
var client = require('../index').createClient()
4-
, client2 = require('../index').createClient()
5-
, assert = require('assert');
3+
var client = require('../index').createClient();
4+
var client2 = require('../index').createClient();
65

76
client.once('subscribe', function (channel, count) {
87
client.unsubscribe('x');

benches/stress/pubsub/pub.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
var freemem = require('os').freemem;
44
var profiler = require('v8-profiler');
55
var codec = require('../codec');
6-
76
var sent = 0;
7+
var exec;
88

99
var pub = require('redis').createClient(null, null, {
1010
//command_queue_high_water: 5,

benches/stress/pubsub/server.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ var codec = require('../codec');
66
var id = Math.random();
77
var recv = 0;
88

9-
var sub = require('redis').createClient()
9+
require('redis').createClient()
1010
.on('ready', function() {
1111
this.subscribe('timeline');
1212
})
1313
.on('message', function(channel, message) {
14-
var self = this;
1514
if (message) {
1615
message = codec.decode(message);
1716
++recv;

benches/stress/rpushblpop/pub.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ var codec = require('../codec');
66

77
var sent = 0;
88

9+
var exec;
10+
911
var pub = require('redis').createClient(null, null, {
1012
//command_queue_high_water: 5,
1113
//command_queue_low_water: 1

benches/stress/rpushblpop/server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ var id = Math.random();
77
var recv = 0;
88

99
var cmd = require('redis').createClient();
10-
var sub = require('redis').createClient()
10+
11+
require('redis').createClient()
1112
.on('ready', function() {
1213
this.emit('timeline');
1314
})

benches/stress/speed/speed.js

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,40 @@ var codec = {
1616

1717
var obj, l;
1818

19+
function run(obj, codec) {
20+
var t1 = Date.now();
21+
var n = 10000;
22+
for (var i = 0; i < n; ++i) {
23+
codec.decode(l = codec.encode(obj));
24+
}
25+
var t2 = Date.now();
26+
//console.log('DONE', n*1000/(t2-t1), 'codecs/sec, length=', l.length);
27+
return [n*1000/(t2-t1), l.length];
28+
}
29+
30+
function series(obj, cname, n) {
31+
var rate = 0;
32+
var len = 0;
33+
for (var i = 0; i < n; ++i) {
34+
var r = run(obj, codec[cname]);
35+
rate += r[0];
36+
len += r[1];
37+
}
38+
rate /= n;
39+
len /= n;
40+
console.log(cname + ' ' + rate + ' ' + len);
41+
return [rate, len];
42+
}
43+
44+
function forObj(obj) {
45+
var r = {
46+
JSON: series(obj, 'JSON', 20),
47+
msgpack: series(obj, 'msgpack', 20),
48+
bison: series(obj, 'bison', 20)
49+
};
50+
return r;
51+
}
52+
1953
var s = '0';
2054
for (var i = 0; i < 12; ++i) s += s;
2155

@@ -50,37 +84,3 @@ obj = {
5084
rand: []
5185
};
5286
forObj(obj);
53-
54-
function run(obj, codec) {
55-
var t1 = Date.now();
56-
var n = 10000;
57-
for (var i = 0; i < n; ++i) {
58-
codec.decode(l = codec.encode(obj));
59-
}
60-
var t2 = Date.now();
61-
//console.log('DONE', n*1000/(t2-t1), 'codecs/sec, length=', l.length);
62-
return [n*1000/(t2-t1), l.length];
63-
}
64-
65-
function series(obj, cname, n) {
66-
var rate = 0;
67-
var len = 0;
68-
for (var i = 0; i < n; ++i) {
69-
var r = run(obj, codec[cname]);
70-
rate += r[0];
71-
len += r[1];
72-
}
73-
rate /= n;
74-
len /= n;
75-
console.log(cname + ' ' + rate + ' ' + len);
76-
return [rate, len];
77-
}
78-
79-
function forObj(obj) {
80-
var r = {
81-
JSON: series(obj, 'JSON', 20),
82-
msgpack: series(obj, 'msgpack', 20),
83-
bison: series(obj, 'bison', 20)
84-
};
85-
return r;
86-
}

connection_breaker.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ server.listen(6479);
4242

4343
var redis = require('./');
4444

45-
var port = 6479;
46-
4745
var client = redis.createClient(6479, 'localhost');
4846

4947
function iter() {

diff_multi_bench_output.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
'use strict';
44

5-
var colors = require('colors'),
6-
fs = require('fs'),
7-
_ = require('underscore'),
5+
/* jshint -W079: Ignore redefinitions (before & after) */
6+
7+
var fs = require('fs'),
88
metrics = require('metrics'),
99

1010
// `node diff_multi_bench_output.js before.txt after.txt`
@@ -30,6 +30,28 @@ console.log('Comparing before,', before.green, '(', before_lines.length,
3030

3131
var total_ops = new metrics.Histogram.createUniformHistogram();
3232

33+
function is_whitespace(s) {
34+
return !!s.trim();
35+
}
36+
37+
function parseInt10(s) {
38+
return parseInt(s, 10);
39+
}
40+
41+
// green if greater than 0, red otherwise
42+
function humanize_diff(num, unit) {
43+
unit = unit || "";
44+
if (num > 0) {
45+
return ('+' + num + unit).green;
46+
}
47+
return ('' + num + unit).red;
48+
}
49+
50+
function command_name(words) {
51+
var line = words.join(' ');
52+
return line.substr(0, line.indexOf(','));
53+
}
54+
3355
before_lines.forEach(function(b, i) {
3456
var a = after_lines[i];
3557
if (!a || !b || !b.trim() || !a.trim()) {
@@ -60,33 +82,11 @@ before_lines.forEach(function(b, i) {
6082
pct = humanize_diff(pct, '%');
6183
console.log(
6284
// name of test
63-
command_name(a_words) === command_name(b_words)
64-
? command_name(a_words) + ':'
65-
: '404:',
85+
command_name(a_words) === command_name(b_words) ?
86+
command_name(a_words) + ':' :
87+
'404:',
6688
// results of test
6789
ops.join(' -> '), 'ops/sec (∆', delta, pct, ')');
6890
});
6991

7092
console.log('Mean difference in ops/sec:', humanize_diff(total_ops.mean().toPrecision(6)));
71-
72-
function is_whitespace(s) {
73-
return !!s.trim();
74-
}
75-
76-
function parseInt10(s) {
77-
return parseInt(s, 10);
78-
}
79-
80-
// green if greater than 0, red otherwise
81-
function humanize_diff(num, unit) {
82-
unit = unit || "";
83-
if (num > 0) {
84-
return ('+' + num + unit).green;
85-
}
86-
return ('' + num + unit).red;
87-
}
88-
89-
function command_name(words) {
90-
var line = words.join(' ');
91-
return line.substr(0, line.indexOf(','));
92-
}

0 commit comments

Comments
 (0)