Permalink
Browse files

Merge pull request #85 from coderunr/linted-patch

Some general code clean-ups
  • Loading branch information...
2 parents e61f0ae + 72bea66 commit 1c8812b390e2cbbe88d58921f943af9023e049fc @fzaninotto committed Jan 15, 2013
View
6 app.js
@@ -17,13 +17,13 @@ var Ping = require('./models/ping');
var mongoose = require('./bootstrap');
// monitor
-
+var m;
if (config.autoStartMonitor) {
m = monitor.createMonitor(config.monitor);
m.start();
}
-a = analyzer.createAnalyzer(config.analyzer);
+var a = analyzer.createAnalyzer(config.analyzer);
a.start();
// web front
@@ -96,7 +96,7 @@ io.sockets.on('connection', function(socket) {
fs.exists('./plugins/index.js', function(exists) {
if (exists) {
require('./plugins').init(app, io, config, mongoose);
- };
+ }
});
var port = process.env.PORT || config.server.port;
View
2 app/api/app.js
@@ -36,7 +36,7 @@ var refreshUpCount = function(callback) {
upCount = count;
callback();
});
-}
+};
Check.on('afterInsert', function() { upCount = undefined; });
Check.on('afterRemove', function() { upCount = undefined; });
View
2 app/api/routes/check.js
@@ -48,7 +48,7 @@ module.exports = function(app) {
req.check = check;
next();
});
- }
+ };
app.get('/checks/:id', loadCheck, function(req, res, next) {
res.json(req.check);
View
6 app/api/routes/ping.js
@@ -62,13 +62,13 @@ module.exports = function(app) {
Check.findById(req.body.checkId, function(err1, check) {
if (err1) {
return res.send(err1.message, 500);
- };
+ }
if (!check) {
return rest.send('Error: No existing check with id ' + req.body.checkId, 403);
- };
+ }
if (!check.needsPoll) {
return res.send('Error: This check was already polled. No ping was created', 403);
- };
+ }
var status = req.body.status === 'true';
Ping.createForCheck(status, req.body.timestamp, req.body.time, check, req.body.name, req.body.error, function(err2, ping) {
if (err2) {
View
2 app/api/routes/tag.js
@@ -30,7 +30,7 @@ module.exports = function(app) {
req.tag = tag;
next();
});
- }
+ };
app.get('/tags/:name', loadTag, function(req, res, next) {
res.json(req.tag);
View
2 app/dashboard/app.js
@@ -33,7 +33,7 @@ app.configure(function(){
} else {
return '';
}
- }
+ };
res.locals.moment = moment;
next();
});
View
4 bootstrap.js
@@ -1,6 +1,6 @@
var mongoose = require('mongoose');
var config = require('config');
-var semver = require('semver')
+var semver = require('semver');
// configure mongodb
mongoose.connect(config.mongodb.connectionString || 'mongodb://' + config.mongodb.user + ':' + config.mongodb.password + '@' + config.mongodb.server +'/' + config.mongodb.database);
@@ -28,7 +28,7 @@ mongoose.connection.on('open', function (err) {
if (!semver.satisfies(data.version, '>=2.1.0')) {
console.error('Error: Uptime requires MongoDB v2.1 minimum. The current MongoDB server uses only '+ data.version);
process.exit(1);
- };
+ }
});
});
View
22 fixtures/computeStats.js
@@ -13,14 +13,14 @@ var emptyStats = function(callback) {
if (!checks.length) return callback(new Error('No check in database, please use the populate script first'));
async.forEach(checks, function(check, cb) { check.removeStats(cb); }, callback);
});
-}
+};
var updateUptime = function(callback) {
console.log('Updating uptime');
Check.find({}, function(err, checks) {
async.forEach(checks, function(check, cb) { check.updateUptime(cb); }, callback);
});
-}
+};
var updateHourlyQosSinceTheFirstPing = function(callback) {
Ping
@@ -29,7 +29,7 @@ var updateHourlyQosSinceTheFirstPing = function(callback) {
.findOne(function(err, ping) {
var date = Date.now() + 60 * 60 * 1000;
var oldestDate = ping.timestamp.valueOf();
- nbDates = 0;
+ var nbDates = 0;
async.whilst(
function() { date -= 60 * 60 * 1000; return date > oldestDate; },
function(cb) {
@@ -43,7 +43,7 @@ var updateHourlyQosSinceTheFirstPing = function(callback) {
callback
);
});
-}
+};
var updateDailyQosSinceTheFirstPing = function(callback) {
Ping
@@ -62,7 +62,7 @@ var updateDailyQosSinceTheFirstPing = function(callback) {
callback
);
});
-}
+};
var updateMonthlyQosSinceTheFirstPing = function(callback) {
Ping
@@ -71,7 +71,7 @@ var updateMonthlyQosSinceTheFirstPing = function(callback) {
.findOne(function(err, ping) {
var date = Date.now() + 28 * 24 * 60 * 60 * 1000;
var oldestDate = ping.timestamp.valueOf();
- nbDates = 0;
+ var nbDates = 0;
async.whilst(
function() { date -= 28 * 24 * 60 * 60 * 1000; return date > oldestDate; },
function(cb) {
@@ -83,7 +83,7 @@ var updateMonthlyQosSinceTheFirstPing = function(callback) {
callback
);
});
-}
+};
var updateYearlyQosSinceTheFirstPing = function(callback) {
Ping
@@ -92,7 +92,7 @@ var updateYearlyQosSinceTheFirstPing = function(callback) {
.findOne(function(err, ping) {
var date = Date.now() + 365 * 24 * 60 * 60 * 1000;
var oldestDate = ping.timestamp.valueOf();
- nbDates = 0;
+ var nbDates = 0;
async.whilst(
function() { date -= 365 * 24 * 60 * 60 * 1000; return date > oldestDate; },
function(cb) {
@@ -104,17 +104,17 @@ var updateYearlyQosSinceTheFirstPing = function(callback) {
callback
);
});
-}
+};
var updateLastDayQos = function(callback) {
console.log('Updating last day Qos for all checks');
QosAggregator.updateLast24HoursQos(callback);
-}
+};
var ensureTagsHaveFirstTestedDate = function(callback) {
console.log('Updating tags for firstTested date');
Tag.ensureTagsHaveFirstTestedDate(callback);
-}
+};
async.series([emptyStats, updateUptime, updateHourlyQosSinceTheFirstPing, updateDailyQosSinceTheFirstPing, updateMonthlyQosSinceTheFirstPing, updateYearlyQosSinceTheFirstPing, updateLastDayQos, ensureTagsHaveFirstTestedDate], function(err) {
if (err) {
View
2 fixtures/fixEvents.js
@@ -30,4 +30,4 @@ Event.find({ message: { $exists: false }}).each(function(err, event) {
if (!event) process.exit();
event.message = event.isGoDown ? 'down' : 'up';
event.save();
-})
+});
View
10 fixtures/populate.js
@@ -12,7 +12,7 @@ var removeChecks = function(callback) {
function(cb) { CheckEvent.collection.remove(cb); },
function(cb) { Check.collection.remove(cb); },
], callback);
-}
+};
var createFixtureChecks = function(callback) {
async.parallel([
@@ -22,7 +22,7 @@ var createFixtureChecks = function(callback) {
function(cb) { createDummyCheck(80, 'My Unstable Site', ['average', 'all'], cb); },
function(cb) { createDummyCheck(70, 'The lousy site I built for Al', ['low', 'all'], cb); },
], callback);
-}
+};
var createDummyCheck = function(quality, name, tags, callback) {
console.log('Creating check "' + name + '"');
@@ -34,7 +34,7 @@ var createDummyCheck = function(quality, name, tags, callback) {
tags: tags || ['all']
});
check.save(callback);
-}
+};
var createFixturePings = function(callback) {
Check.find({}, function(err, checks) {
@@ -58,13 +58,13 @@ var createFixturePings = function(callback) {
nbPings++;
if (nbPings % 288 == 0) {
console.log(new Date(date) + ' Created pings for check "' + check.name + '"');
- };
+ }
},
callme
);
}, callback);
});
-}
+};
async.series([removeChecks, createFixtureChecks, createFixturePings], function(err) {
if (err) {
View
4 lib/monitor.js
@@ -104,7 +104,7 @@ Monitor.prototype.pollCheck = function(check, callback) {
// change lastTested date right away to avoid polling twice if the target doesn't answer in timely fashion
this.declarePoll(check, function(err) { });
var Poller = require('./pollers/' + (check.type || 'http'));
- p = new Poller(check.url, this.config.timeout, function(err, time) {
+ var p = new Poller(check.url, this.config.timeout, function(err, time) {
self.createPing(check, err, Date.now(), time, callback);
});
if ('setUserAgent' in p) {
@@ -142,7 +142,7 @@ Monitor.prototype.createPing = function(check, error, timestamp, time, callback)
options.headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': postData.length
- }
+ };
var self = this;
var req = http.request(options, function(res) {
if (res.statusCode != 200) {
View
2 lib/pollers/http.js
@@ -40,7 +40,7 @@ HttpPoller.prototype.initialize = function() {
HttpPoller.prototype.setUserAgent = function(userAgent) {
if (typeof this.target.headers == 'undefined') {
this.target.headers = {};
- };
+ }
this.target.headers['User-Agent'] = userAgent;
};
View
2 lib/pollers/https.js
@@ -39,7 +39,7 @@ HttpsPoller.prototype.initialize = function() {
HttpsPoller.prototype.setUserAgent = function(userAgent) {
if (typeof this.target.headers == 'undefined') {
this.target.headers = {};
- };
+ }
this.target.headers['User-Agent'] = userAgent;
};
View
4 lib/qosAggregator.js
@@ -325,7 +325,7 @@ QosAggregator.prototype.createCheckDailyStats = function(documents, callback) {
count: document.count,
responsiveness: document.responsiveness,
responseTime: document.responseTime,
- }
+ };
var intervalBuilder = new IntervalBuilder();
intervalBuilder.addTarget(document._id);
intervalBuilder.build(document.start, document.end, function(err, outages, downtime) {
@@ -381,7 +381,7 @@ QosAggregator.prototype.createTagDailyStats = function(documents, callback) {
count: document.count,
responsiveness: document.responsiveness,
responseTime: document.responseTime,
- }
+ };
var intervalBuilder = new IntervalBuilder();
Check.findForTag(document._id, function(err, checks) {
if (err) return next(err);
View
2 models/check.js
@@ -223,7 +223,7 @@ Check.methods.getStatsForPeriod = function(period, begin, end, callback) {
outages: stat.outages || [],
end: stat.end ? stat.end.valueOf() : (Date.parse(stat.timestamp) + periodPrefs['duration'])
});
- };
+ }
}).on('close', function() {
callback(null, stats);
});
View
2 models/checkEvent.js
@@ -59,7 +59,7 @@ CheckEvent.statics.aggregateEventsByDay = function(events, callback) {
};
CheckEvent.statics.cleanup = function(maxAge, callback) {
- oldestDateToKeep = new Date(Date.now() - (maxAge || 3 * 31 * 24 * 60 * 60 * 1000));
+ var oldestDateToKeep = new Date(Date.now() - (maxAge || 3 * 31 * 24 * 60 * 60 * 1000));
this.find({ timestamp: { $lt: oldestDateToKeep } }).remove(callback);
};
View
4 models/migrations/upgrade2to3.js
@@ -85,7 +85,7 @@ var getOldestDate = function(callback) {
var updateMonthlyQos = function(start, callback) {
var date = Date.now() + 28 * 24 * 60 * 60 * 1000;
- nbDates = 0;
+ var nbDates = 0;
async.whilst(
function() { date -= 28 * 24 * 60 * 60 * 1000; return date > start; },
function(cb) {
@@ -100,7 +100,7 @@ var updateMonthlyQos = function(start, callback) {
var updateYearlyQos = function(start, callback) {
var date = Date.now() + 365 * 24 * 60 * 60 * 1000;
- nbDates = 0;
+ var nbDates = 0;
async.whilst(
function() { date -= 365 * 24 * 60 * 60 * 1000; return date > start; },
function(cb) {
View
4 models/ping.js
@@ -38,7 +38,7 @@ Ping.statics.createForCheck = function(status, timestamp, time, check, monitorNa
if (!status) {
ping.downtime = check.interval || 60000;
ping.error = error;
- };
+ }
ping.save(function(err1) {
if (err1) return callback(err1);
check.setLastTest(status, timestamp, error);
@@ -50,7 +50,7 @@ Ping.statics.createForCheck = function(status, timestamp, time, check, monitorNa
};
Ping.statics.cleanup = function(maxAge, callback) {
- oldestDateToKeep = new Date(Date.now() - (maxAge || 3 * 31 * 24 * 60 * 60 * 1000));
+ var oldestDateToKeep = new Date(Date.now() - (maxAge || 3 * 31 * 24 * 60 * 60 * 1000));
this.find({ timestamp: { $lt: new Date(oldestDateToKeep) } }).remove(callback);
};
View
4 models/tag.js
@@ -134,7 +134,7 @@ Tag.methods.getChecksForPeriod = function(period, date, callback) {
var ids = [];
res.forEach(function(doc) {
ids.push(doc._id);
- })
+ });
var query = { check: { $in: ids }, timestamp: { $gte: begin, $lte: end } };
var stream = self.db.model(periodPrefs['model']).find(query).populate('check').stream();
stream
@@ -157,7 +157,7 @@ Tag.methods.getChecksForPeriod = function(period, date, callback) {
checkNames.sort();
checkNames.forEach(function(checkName) {
orderedStats.push(stats[checkName]);
- })
+ });
callback(null, orderedStats);
});
});

0 comments on commit 1c8812b

Please sign in to comment.