ESlint no-plusplus

and no-empty, space-unary-ops
v1.18.x
Peter Jaszkowiak 8 years ago
parent d1101a7fb4
commit 3361a72725

@ -12,7 +12,12 @@
}], }],
"import/no-unresolved": "off", "import/no-unresolved": "off",
"import/no-extraneous-dependencies": "off", "import/no-extraneous-dependencies": "off",
"import/no-dynamic-require": "off",
"no-bitwise": "off",
"newline-per-chained-call": "off", "newline-per-chained-call": "off",
"no-console": "off",
"no-empty": ["error", { "allowEmptyCatch": true }],
// "linebreak-style": "off", // "linebreak-style": "off",
// "one-var": "off", // "one-var": "off",
// "no-undef": "off", // "no-undef": "off",
@ -84,7 +89,6 @@
"no-multi-spaces": "off", "no-multi-spaces": "off",
"quotes": "off", "quotes": "off",
"keyword-spacing": "off", "keyword-spacing": "off",
"no-plusplus": "off",
"no-mixed-operators": "off", "no-mixed-operators": "off",
"comma-spacing": "off", "comma-spacing": "off",
"global-require": "off", "global-require": "off",
@ -99,11 +103,9 @@
"space-in-parens": "off", "space-in-parens": "off",
"block-spacing": "off", "block-spacing": "off",
"quote-props": "off", "quote-props": "off",
"no-console": "off", // "space-unary-ops": "off",
"space-unary-ops": "off", // "no-plusplus": "off",
"import/no-dynamic-require": "off", // "no-empty": "off",
"no-bitwise": "off",
"no-empty": "off",
// "dot-notation": "off", // "dot-notation": "off",
// "func-call-spacing": "off", // "func-call-spacing": "off",
// "array-bracket-spacing": "off", // "array-bracket-spacing": "off",

@ -46,9 +46,9 @@ module.exports = function (grunt) {
updateWorker.kill('SIGKILL'); updateWorker.kill('SIGKILL');
} }
updateWorker = fork('app.js', updateArgs, { env: env }); updateWorker = fork('app.js', updateArgs, { env: env });
++running; running += 1;
updateWorker.on('exit', function () { updateWorker.on('exit', function () {
--running; running -= 1;
if (running === 0) { if (running === 0) {
worker = fork('app.js', args, { env: env }); worker = fork('app.js', args, { env: env });
worker.on('message', function () { worker.on('message', function () {

@ -155,7 +155,7 @@ function setup() {
var separator = ' '; var separator = ' ';
if (process.stdout.columns > 10) { if (process.stdout.columns > 10) {
for(var x = 0,cols = process.stdout.columns - 10; x < cols; x++) { for(var x = 0,cols = process.stdout.columns - 10; x < cols; x += 1) {
separator += '='; separator += '=';
} }
} }

@ -74,7 +74,7 @@ function saveDatabaseConfig(config, databaseConfig, callback) {
} }
var allQuestions = questions.redis.concat(questions.mongo); var allQuestions = questions.redis.concat(questions.mongo);
for (var x = 0; x < allQuestions.length; x++) { for (var x = 0; x < allQuestions.length; x += 1) {
delete config[allQuestions[x].name]; delete config[allQuestions[x].name];
} }

@ -52,7 +52,7 @@ Loader.addWorkerEvents = function (worker) {
worker.on('exit', function (code, signal) { worker.on('exit', function (code, signal) {
if (code !== 0) { if (code !== 0) {
if (Loader.timesStarted < numProcs * 3) { if (Loader.timesStarted < numProcs * 3) {
Loader.timesStarted++; Loader.timesStarted += 1;
if (Loader.crashTimer) { if (Loader.crashTimer) {
clearTimeout(Loader.crashTimer); clearTimeout(Loader.crashTimer);
} }
@ -93,7 +93,7 @@ Loader.start = function (callback) {
numProcs = getPorts().length; numProcs = getPorts().length;
console.log('Clustering enabled: Spinning up ' + numProcs + ' process(es).\n'); console.log('Clustering enabled: Spinning up ' + numProcs + ' process(es).\n');
for (var x = 0; x < numProcs; ++x) { for (var x = 0; x < numProcs; x += 1) {
forkWorker(x, x === 0); forkWorker(x, x === 0);
} }

@ -117,7 +117,7 @@ define('admin/extend/widgets', ['jqueryui'], function (jqueryui) {
location: location, location: location,
widgets: widgets, widgets: widgets,
}, function (err) { }, function (err) {
total--; total -= 1;
if (err) { if (err) {
app.alertError(err.message); app.alertError(err.message);
@ -209,13 +209,13 @@ define('admin/extend/widgets', ['jqueryui'], function (jqueryui) {
$.get(RELATIVE_PATH + '/api/admin/extend/widgets', function (data) { $.get(RELATIVE_PATH + '/api/admin/extend/widgets', function (data) {
var areas = data.areas; var areas = data.areas;
for(var i = 0; i < areas.length; ++i) { for(var i = 0; i < areas.length; i += 1) {
var area = areas[i]; var area = areas[i];
var widgetArea = $('#widgets .area[data-template="' + area.template + '"][data-location="' + area.location + '"]').find('.widget-area'); var widgetArea = $('#widgets .area[data-template="' + area.template + '"][data-location="' + area.location + '"]').find('.widget-area');
widgetArea.html(''); widgetArea.html('');
for (var k = 0; k < area.data.length; ++k) { for (var k = 0; k < area.data.length; k += 1) {
var widgetData = area.data[k]; var widgetData = area.data[k];
var widgetEl = $('.available-widgets [data-widget="' + widgetData.widget + '"]').clone(true).removeClass('hide'); var widgetEl = $('.available-widgets [data-widget="' + widgetData.widget + '"]').clone(true).removeClass('hide');

@ -387,7 +387,7 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s
graphs.topics.data.datasets[0].backgroundColor = []; graphs.topics.data.datasets[0].backgroundColor = [];
graphs.topics.data.datasets[0].hoverBackgroundColor = []; graphs.topics.data.datasets[0].hoverBackgroundColor = [];
for (var i = 0, ii = tids.length; i < ii; i++) { for (var i = 0, ii = tids.length; i < ii; i += 1) {
graphs.topics.data.labels.push(topics[tids[i]].title); graphs.topics.data.labels.push(topics[tids[i]].title);
graphs.topics.data.datasets[0].data.push(topics[tids[i]].value); graphs.topics.data.datasets[0].data.push(topics[tids[i]].value);
graphs.topics.data.datasets[0].backgroundColor.push(topicColors[i]); graphs.topics.data.datasets[0].backgroundColor.push(topicColors[i]);
@ -397,7 +397,7 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s
function buildTopicsLegend() { function buildTopicsLegend() {
var legend = $('#topics-legend').html(''); var legend = $('#topics-legend').html('');
for (var i = 0, ii = tids.length; i < ii; i++) { for (var i = 0, ii = tids.length; i < ii; i += 1) {
var topic = topics[tids[i]]; var topic = topics[tids[i]];
var label = topic.value === '0' ? topic.title : '<a title="' + topic.title + '"href="' + RELATIVE_PATH + '/topic/' + tids[i] + '" target="_blank"> ' + topic.title + '</a>'; var label = topic.value === '0' ? topic.title : '<a title="' + topic.title + '"href="' + RELATIVE_PATH + '/topic/' + tids[i] + '" target="_blank"> ' + topic.title + '</a>';

@ -135,7 +135,7 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
var list = parentCategory.toArray(); var list = parentCategory.toArray();
var len = list.length; var len = list.length;
for(i; i < len; ++i) { for(i; i < len; i += 1) {
modified[list[i]] = { modified[list[i]] = {
order: (i + 1), order: (i + 1),
}; };
@ -166,7 +166,7 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
if (category.name !== translated) { if (category.name !== translated) {
category.name = translated; category.name = translated;
} }
++count; count += 1;
if (count === parent.length) { if (count === parent.length) {
continueRender(); continueRender();
@ -187,7 +187,7 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
container.append(html); container.append(html);
// Handle and children categories in this level have // Handle and children categories in this level have
for(var x = 0,numCategories = categories.length; x < numCategories; x++) { for(var x = 0, numCategories = categories.length; x < numCategories; x += 1) {
renderList(categories[x].children, $('li[data-cid="' + categories[x].cid + '"]'), categories[x].cid); renderList(categories[x].children, $('li[data-cid="' + categories[x].cid + '"]'), categories[x].cid);
} }

@ -295,7 +295,7 @@ define('admin/manage/category', [
privs.push(el.getAttribute('data-privilege')); privs.push(el.getAttribute('data-privilege'));
} }
}); });
for(var x = 0,numPrivs = privs.length; x < numPrivs; x++) { for(var x = 0, numPrivs = privs.length; x < numPrivs; x += 1) {
var inputs = $('.privilege-table tr[data-group-name]:not([data-group-name="registered-users"],[data-group-name="guests"]) td[data-privilege="' + privs[x] + '"] input'); var inputs = $('.privilege-table tr[data-group-name]:not([data-group-name="registered-users"],[data-group-name="guests"]) td[data-privilege="' + privs[x] + '"] input');
inputs.each(function (idx, el) { inputs.each(function (idx, el) {
if (!el.checked) { if (!el.checked) {

@ -51,7 +51,7 @@ define('admin/manage/group', [
groupDetailsSearchResults.empty(); groupDetailsSearchResults.empty();
for (x = 0; x < numResults; x++) { for (x = 0; x < numResults; x += 1) {
foundUser = $('<li />'); foundUser = $('<li />');
foundUser foundUser
.attr({title: results.users[x].username, .attr({title: results.users[x].username,

@ -36,7 +36,7 @@ define('admin/settings', ['uploader'], function (uploader) {
app.flags._unsaved = true; app.flags._unsaved = true;
}); });
for (x = 0; x < numFields; x++) { for (x = 0; x < numFields; x += 1) {
field = fields.eq(x); field = fields.eq(x);
key = field.attr('data-field'); key = field.attr('data-field');
inputType = field.attr('type'); inputType = field.attr('type');

@ -196,7 +196,8 @@ $(document).ready(function () {
ajaxify.end = function (url, tpl_url) { ajaxify.end = function (url, tpl_url) {
function done() { function done() {
if (--count === 0) { count -= 1;
if (count === 0) {
$(window).trigger('action:ajaxify.end', {url: url, tpl_url: tpl_url, title: ajaxify.data.title}); $(window).trigger('action:ajaxify.end', {url: url, tpl_url: tpl_url, title: ajaxify.data.title});
} }
} }

@ -226,7 +226,7 @@ define('forum/category', [
} }
if (numTopics > 0) { if (numTopics > 0) {
for (var x = 0; x < numTopics; x++) { for (var x = 0; x < numTopics; x += 1) {
var pinned = $(topics[x]).hasClass('pinned'); var pinned = $(topics[x]).hasClass('pinned');
if (!pinned) { if (!pinned) {
topic.insertBefore(topics[x]); topic.insertBefore(topics[x]);

@ -180,7 +180,7 @@ define('forum/category/tools', [
} }
function isAny(method, tids) { function isAny(method, tids) {
for(var i = 0; i < tids.length; ++i) { for(var i = 0; i < tids.length; i += 1) {
if(method(tids[i])) { if(method(tids[i])) {
return true; return true;
} }
@ -189,7 +189,7 @@ define('forum/category/tools', [
} }
function areAll(method, tids) { function areAll(method, tids) {
for(var i = 0; i < tids.length; ++i) { for(var i = 0; i < tids.length; i += 1) {
if(!method(tids[i])) { if(!method(tids[i])) {
return false; return false;
} }

@ -46,13 +46,13 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function (infinit
return; return;
} }
++newTopicCount; newTopicCount += 1;
Recent.updateAlertText(); Recent.updateAlertText();
} }
function onNewPost(data) { function onNewPost(data) {
function showAlert() { function showAlert() {
++newPostCount; newPostCount += 1;
Recent.updateAlertText(); Recent.updateAlertText();
} }

@ -137,7 +137,7 @@ define('forum/search', ['search', 'autocomplete'], function (searchModule, autoc
result.html(result.html().replace(regex, '<strong>$1</strong>')); result.html(result.html().replace(regex, '<strong>$1</strong>'));
for (var i = 0, ii = nested.length; i < ii; i++) { for (var i = 0, ii = nested.length; i < ii; i += 1) {
result.html(result.html().replace('<!-- ' + i + ' -->', nested[i].html())); result.html(result.html().replace('<!-- ' + i + ' -->', nested[i].html()));
} }
}); });

@ -165,7 +165,7 @@ define('forum/topic/events', [
return true; return true;
} }
for (var i = 0; i < tags.length; ++i) { for (var i = 0; i < tags.length; i += 1) {
if (!$('.tags .tag-item[data-tag="' + tags[i].value + '"]').length) { if (!$('.tags .tag-item[data-tag="' + tags[i].value + '"]').length) {
return true; return true;
} }
@ -178,7 +178,7 @@ define('forum/topic/events', [
$(this).remove(); $(this).remove();
posts.showBottomPostBar(); posts.showBottomPostBar();
}); });
ajaxify.data.postcount --; ajaxify.data.postcount -= 1;
postTools.updatePostCount(ajaxify.data.postcount); postTools.updatePostCount(ajaxify.data.postcount);
require(['forum/topic/replies'], function (replies) { require(['forum/topic/replies'], function (replies) {
replies.onPostPurged(postData); replies.onPostPurged(postData);

@ -28,7 +28,7 @@ define('forum/topic/posts', [
updatePostCounts(data.posts); updatePostCounts(data.posts);
ajaxify.data.postcount ++; ajaxify.data.postcount += 1;
postTools.updatePostCount(ajaxify.data.postcount); postTools.updatePostCount(ajaxify.data.postcount);
if (config.usePagination) { if (config.usePagination) {
@ -54,7 +54,7 @@ define('forum/topic/posts', [
}; };
function updatePostCounts(posts) { function updatePostCounts(posts) {
for (var i = 0; i < posts.length; ++i) { for (var i = 0; i < posts.length; i += 1) {
var cmp = components.get('user/postcount', posts[i].uid); var cmp = components.get('user/postcount', posts[i].uid);
cmp.html(parseInt(cmp.attr('data-postcount'), 10) + 1); cmp.html(parseInt(cmp.attr('data-postcount'), 10) + 1);
utils.addCommasToNumbers(cmp); utils.addCommasToNumbers(cmp);

@ -118,7 +118,7 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', '
} }
function removeTids(tids) { function removeTids(tids) {
for(var i = 0; i < tids.length; ++i) { for(var i = 0; i < tids.length; i += 1) {
components.get('category/topic', 'tid', tids[i]).remove(); components.get('category/topic', 'tid', tids[i]).remove();
} }
} }

@ -125,7 +125,7 @@ define('notifications', ['sounds', 'translator', 'components'], function (sound,
}); });
translator.toggleTimeagoShorthand(); translator.toggleTimeagoShorthand();
for(var i = 0; i < notifs.length; ++i) { for(var i = 0; i < notifs.length; i += 1) {
notifs[i].timeago = $.timeago(new Date(parseInt(notifs[i].datetime, 10))); notifs[i].timeago = $.timeago(new Date(parseInt(notifs[i].datetime, 10)));
} }
translator.toggleTimeagoShorthand(); translator.toggleTimeagoShorthand();

@ -129,7 +129,7 @@ define('settings', function () {
if (!trim && empty) { if (!trim && empty) {
return array; return array;
} }
for (var i = 0; i < array.length; i++) { for (var i = 0; i < array.length; i += 1) {
var value = array[i]; var value = array[i];
if (trim) { if (trim) {
value = value === true ? 1 : value === false ? 0 : typeof value.trim === 'function' ? value.trim() : value; value = value === true ? 1 : value === false ? 0 : typeof value.trim === 'function' ? value.trim() : value;
@ -226,7 +226,7 @@ define('settings', function () {
if (hook != null) { if (hook != null) {
hook.call(Settings, field); hook.call(Settings, field);
} }
for (var i = 0; i < keyParts.length; i++) { for (var i = 0; i < keyParts.length; i += 1) {
var part = keyParts[i]; var part = keyParts[i];
if (part && value != null) { if (part && value != null) {
value = value[part]; value = value[part];
@ -254,7 +254,7 @@ define('settings', function () {
if (waitingJobs > 0) { if (waitingJobs > 0) {
waitingJobs -= amount; waitingJobs -= amount;
if (waitingJobs <= 0) { if (waitingJobs <= 0) {
for (var i = 0; i < onReady.length; i++) { for (var i = 0; i < onReady.length; i += 1) {
onReady[i](); onReady[i]();
} }
onReady = []; onReady = [];
@ -352,7 +352,7 @@ define('settings', function () {
if (typeof service.use === 'function') { if (typeof service.use === 'function') {
service.use.call(Settings); service.use.call(Settings);
} }
for (var i = 0; i < types.length; i++) { for (var i = 0; i < types.length; i += 1) {
var type = types[i].toLowerCase(); var type = types[i].toLowerCase();
if (Settings.plugins[type] == null) { if (Settings.plugins[type] == null) {
Settings.plugins[type] = service; Settings.plugins[type] = service;
@ -415,14 +415,14 @@ define('settings', function () {
if (notify == null) { if (notify == null) {
notify = true; notify = true;
} }
for (var i = 0; i < fields.length; i++) { for (var i = 0; i < fields.length; i += 1) {
var field = $(fields[i]); var field = $(fields[i]);
var value = helper.readValue(field); var value = helper.readValue(field);
var parentCfg = Settings.get(); var parentCfg = Settings.get();
var keyParts = field.data('key').split('.'); var keyParts = field.data('key').split('.');
var lastKey = keyParts[keyParts.length - 1]; var lastKey = keyParts[keyParts.length - 1];
if (keyParts.length > 1) { if (keyParts.length > 1) {
for (var j = 0; j < keyParts.length - 1; j++) { for (var j = 0; j < keyParts.length - 1; j += 1) {
var part = keyParts[j]; var part = keyParts[j];
if (part && parentCfg != null) { if (part && parentCfg != null) {
parentCfg = parentCfg[part]; parentCfg = parentCfg[part];
@ -534,7 +534,7 @@ define('settings', function () {
helper.registerReadyJobs(1); helper.registerReadyJobs(1);
require(DEFAULT_PLUGINS, function () { require(DEFAULT_PLUGINS, function () {
for (var i = 0; i < arguments.length; i++) { for (var i = 0; i < arguments.length; i += 1) {
Settings.registerPlugin(arguments[i]); Settings.registerPlugin(arguments[i]);
} }
helper.beforeReadyJobsDecreased(); helper.beforeReadyJobsDecreased();

@ -115,7 +115,7 @@ define('settings/array', function () {
if (!(value instanceof Array)) { if (!(value instanceof Array)) {
value = []; value = [];
} }
for (var i = 0; i < value.length; i++) { for (var i = 0; i < value.length; i += 1) {
addArrayChildElement(element, key, attributes, value[i], separator.clone(), function (el) { addArrayChildElement(element, key, attributes, value[i], separator.clone(), function (el) {
element.append(el); element.append(el);
}); });

@ -131,7 +131,7 @@ define('settings/key', function () {
var key = new Key(); var key = new Key();
var sep = /([^CtrlAShifMea#\d]+)(?:#|\d)/.exec(str); var sep = /([^CtrlAShifMea#\d]+)(?:#|\d)/.exec(str);
var parts = sep != null ? str.split(sep[1]) : [str]; var parts = sep != null ? str.split(sep[1]) : [str];
for (var i = 0; i < parts.length; i++) { for (var i = 0; i < parts.length; i += 1) {
var part = parts[i]; var part = parts[i];
switch (part) { switch (part) {
case 'C': case 'C':

@ -4,7 +4,7 @@ define('settings/select', function () {
var SettingsSelect; var SettingsSelect;
function addOptions(element, options) { function addOptions(element, options) {
for (var i = 0; i < options.length; i++) { for (var i = 0; i < options.length; i += 1) {
var optionData = options[i]; var optionData = options[i];
var value = optionData.text || optionData.value; var value = optionData.text || optionData.value;
delete optionData.text; delete optionData.text;

@ -70,7 +70,7 @@ define('topicSelect', ['components'], function (components) {
end = tmp; end = tmp;
} }
for(var i = start; i <= end; ++i) { for(var i = start; i <= end; i += 1) {
var topic = $('[component="category/topic"]').eq(i); var topic = $('[component="category/topic"]').eq(i);
toggleSelect(topic.find('[component="topic/select"]'), isSelected); toggleSelect(topic.find('[component="topic/select"]'), isSelected);
} }

@ -58,13 +58,15 @@
} }
results = results.concat(res); results = results.concat(res);
if (!--pending) { pending -= 1;
if (!pending) {
done(null, results); done(null, results);
} }
}); });
} else { } else {
results.push(file); results.push(file);
if (!--pending) { pending -= 1;
if (!pending) {
done(null, results); done(null, results);
} }
} }
@ -148,10 +150,10 @@
var result = {}; var result = {};
var obj; var obj;
var keys; var keys;
for (var i = 0; i < arguments.length; i++) { for (var i = 0; i < arguments.length; i += 1) {
obj = arguments[i] || {}; obj = arguments[i] || {};
keys = Object.keys(obj); keys = Object.keys(obj);
for (var j = 0; j < keys.length; j++) { for (var j = 0; j < keys.length; j += 1) {
result[keys[j]] = obj[keys[j]]; result[keys[j]] = obj[keys[j]];
} }
} }
@ -276,7 +278,7 @@
$el.appendTo($('body')); $el.appendTo($('body'));
for (var i = envs.length - 1; i >= 0; i--) { for (var i = envs.length - 1; i >= 0; i -= 1) {
var env = envs[i]; var env = envs[i];
$el.addClass('hidden-' + env); $el.addClass('hidden-' + env);
@ -298,7 +300,7 @@
var currentHour = new Date().getHours(); var currentHour = new Date().getHours();
var labels = []; var labels = [];
for (var i = currentHour, ii = currentHour - 24; i > ii; i--) { for (var i = currentHour, ii = currentHour - 24; i > ii; i -= 1) {
var hour = i < 0 ? 24 + i : i; var hour = i < 0 ? 24 + i : i;
labels.push(hour + ':00'); labels.push(hour + ':00');
} }
@ -312,7 +314,7 @@
var labels = []; var labels = [];
var tmpDate; var tmpDate;
for(var x = 29; x >= 0; x--) { for(var x = 29; x >= 0; x -= 1) {
tmpDate = new Date(currentDay - (1000 * 60 * 60 * 24 * x)); tmpDate = new Date(currentDay - (1000 * 60 * 60 * 24 * x));
labels.push(months[tmpDate.getMonth()] + ' ' + tmpDate.getDate()); labels.push(months[tmpDate.getMonth()] + ' ' + tmpDate.getDate());
} }

@ -36,12 +36,12 @@
cid: ajaxify.data.cid, cid: ajaxify.data.cid,
isMobile: utils.isMobile(), isMobile: utils.isMobile(),
}, function (renderedAreas) { }, function (renderedAreas) {
for (var x = 0; x < renderedAreas.length; ++x) { for (var x = 0; x < renderedAreas.length; x += 1) {
var renderedWidgets = renderedAreas[x].widgets; var renderedWidgets = renderedAreas[x].widgets;
var location = renderedAreas[x].location; var location = renderedAreas[x].location;
var html = ''; var html = '';
for (var i = 0; i < renderedWidgets.length; ++i) { for (var i = 0; i < renderedWidgets.length; i += 1) {
html += templates.parse(renderedWidgets[i].html, {}); html += templates.parse(renderedWidgets[i].html, {});
} }

@ -25,12 +25,12 @@ Analytics.increment = function (keys) {
keys.forEach(function (key) { keys.forEach(function (key) {
counters[key] = counters[key] || 0; counters[key] = counters[key] || 0;
++counters[key]; counters[key] += 1;
}); });
}; };
Analytics.pageView = function (payload) { Analytics.pageView = function (payload) {
++pageViews; pageViews += 1;
if (payload.ip) { if (payload.ip) {
db.sortedSetScore('ip:recent', payload.ip, function (err, score) { db.sortedSetScore('ip:recent', payload.ip, function (err, score) {
@ -38,12 +38,12 @@ Analytics.pageView = function (payload) {
return; return;
} }
if (!score) { if (!score) {
++uniqueIPCount; uniqueIPCount += 1;
} }
var today = new Date(); var today = new Date();
today.setHours(today.getHours(), 0, 0, 0); today.setHours(today.getHours(), 0, 0, 0);
if (!score || score < today.getTime()) { if (!score || score < today.getTime()) {
++uniquevisitors; uniquevisitors += 1;
db.sortedSetAdd('ip:recent', Date.now(), payload.ip); db.sortedSetAdd('ip:recent', Date.now(), payload.ip);
} }
}); });
@ -109,7 +109,7 @@ Analytics.getHourlyStatsForSet = function (set, hour, numHours, callback) {
hour = new Date(hour); hour = new Date(hour);
hour.setHours(hour.getHours(), 0, 0, 0); hour.setHours(hour.getHours(), 0, 0, 0);
for (var i = 0, ii = numHours; i < ii; i++) { for (var i = 0, ii = numHours; i < ii; i += 1) {
hoursArr.push(hour.getTime()); hoursArr.push(hour.getTime());
hour.setHours(hour.getHours() - 1, 0, 0, 0); hour.setHours(hour.getHours() - 1, 0, 0, 0);
} }
@ -142,7 +142,8 @@ Analytics.getDailyStatsForSet = function (set, day, numDays, callback) {
day.setHours(0, 0, 0, 0); day.setHours(0, 0, 0, 0);
async.whilst(function () { async.whilst(function () {
return numDays--; numDays -= 1;
return numDays + 1;
}, function (next) { }, function (next) {
Analytics.getHourlyStatsForSet(set, day.getTime() - (1000 * 60 * 60 * 24 * numDays), 24, function (err, day) { Analytics.getHourlyStatsForSet(set, day.getTime() - (1000 * 60 * 60 * 24 * numDays), 24, function (err, day) {
if (err) { if (err) {

@ -298,7 +298,7 @@ var privileges = require('./privileges');
var len = categories.length; var len = categories.length;
var category; var category;
for (i; i < len; ++i) { for (i; i < len; i += 1) {
category = categories[i]; category = categories[i];
if (!category.hasOwnProperty('parentCid') || category.parentCid === null) { if (!category.hasOwnProperty('parentCid') || category.parentCid === null) {
category.parentCid = 0; category.parentCid = 0;

@ -24,7 +24,7 @@ module.exports = function (Categories) {
return next(null, {topics: [], uid: data.uid}); return next(null, {topics: [], uid: data.uid});
} }
for (var i = 0; i < topics.length; ++i) { for (var i = 0; i < topics.length; i += 1) {
topics[i].index = data.start + i; topics[i].index = data.start + i;
} }

@ -43,7 +43,7 @@ module.exports = function (Categories) {
Categories.hasReadCategories = function (cids, uid, callback) { Categories.hasReadCategories = function (cids, uid, callback) {
var sets = []; var sets = [];
for (var i = 0, ii = cids.length; i < ii; i++) { for (var i = 0, ii = cids.length; i < ii; i += 1) {
sets.push('cid:' + cids[i] + ':read_by_uid'); sets.push('cid:' + cids[i] + ':read_by_uid');
} }

@ -39,7 +39,7 @@ pluginsController.get = function (req, res, next) {
}), }),
upgradeCount: payload.compatible.reduce(function (count, current) { upgradeCount: payload.compatible.reduce(function (count, current) {
if (current.installed && current.outdated) { if (current.installed && current.outdated) {
++count; count += 1;
} }
return count; return count;
}, 0), }, 0),

@ -149,7 +149,7 @@ topicsController.get = function (req, res, callback) {
}, },
function (topicData, next) { function (topicData, next) {
function findPost(index) { function findPost(index) {
for(var i = 0; i < topicData.posts.length; ++i) { for(var i = 0; i < topicData.posts.length; i += 1) {
if (parseInt(topicData.posts[i].index, 10) === parseInt(index, 10)) { if (parseInt(topicData.posts[i].index, 10) === parseInt(index, 10)) {
return topicData.posts[i]; return topicData.posts[i];
} }

@ -79,7 +79,7 @@ usersController.getOnlineUsers = function (req, res, next) {
if (!userData.isAdminOrGlobalMod) { if (!userData.isAdminOrGlobalMod) {
userData.users = userData.users.filter(function (user) { userData.users = userData.users.filter(function (user) {
if (user && user.status === 'offline') { if (user && user.status === 'offline') {
hiddenCount ++; hiddenCount += 1;
} }
return user && user.status !== 'offline'; return user && user.status !== 'offline';
}); });

@ -76,7 +76,7 @@
var ports = nconf.get('mongo:port').toString().split(','); var ports = nconf.get('mongo:port').toString().split(',');
var servers = []; var servers = [];
for (var i = 0; i < hosts.length; i++) { for (var i = 0; i < hosts.length; i += 1) {
servers.push(hosts[i] + ':' + ports[i]); servers.push(hosts[i] + ':' + ports[i]);
} }

@ -44,7 +44,7 @@ module.exports = function (db, module) {
var map = helpers.toMap(data); var map = helpers.toMap(data);
var returnData = []; var returnData = [];
for (var i = 0; i < keys.length; ++i) { for (var i = 0; i < keys.length; i += 1) {
returnData.push(map[keys[i]]); returnData.push(map[keys[i]]);
} }
@ -78,7 +78,7 @@ module.exports = function (db, module) {
_id: 0, _id: 0,
}; };
for(var i = 0; i < fields.length; ++i) { for(var i = 0; i < fields.length; i += 1) {
fields[i] = helpers.fieldToString(fields[i]); fields[i] = helpers.fieldToString(fields[i]);
_fields[fields[i]] = 1; _fields[fields[i]] = 1;
} }
@ -88,7 +88,7 @@ module.exports = function (db, module) {
} }
item = item || {}; item = item || {};
var result = {}; var result = {};
for(i = 0; i < fields.length; ++i) { for(i = 0; i < fields.length; i += 1) {
result[fields[i]] = item[fields[i]] !== undefined ? item[fields[i]] : null; result[fields[i]] = item[fields[i]] !== undefined ? item[fields[i]] : null;
} }
callback(null, result); callback(null, result);
@ -104,7 +104,7 @@ module.exports = function (db, module) {
_key: 1, _key: 1,
}; };
for(var i = 0; i < fields.length; ++i) { for(var i = 0; i < fields.length; i += 1) {
fields[i] = helpers.fieldToString(fields[i]); fields[i] = helpers.fieldToString(fields[i]);
_fields[fields[i]] = 1; _fields[fields[i]] = 1;
} }
@ -122,10 +122,10 @@ module.exports = function (db, module) {
var returnData = []; var returnData = [];
var item; var item;
for (var i = 0; i < keys.length; ++i) { for (var i = 0; i < keys.length; i += 1) {
item = map[keys[i]] || {}; item = map[keys[i]] || {};
for (var k = 0; k < fields.length; ++k) { for (var k = 0; k < fields.length; k += 1) {
if (item[fields[k]] === undefined) { if (item[fields[k]] === undefined) {
item[fields[k]] = null; item[fields[k]] = null;
} }

@ -4,7 +4,7 @@ var helpers = {};
helpers.toMap = function (data) { helpers.toMap = function (data) {
var map = {}; var map = {};
for (var i = 0; i < data.length; ++i) { for (var i = 0; i < data.length; i += 1) {
map[data[i]._key] = data[i]; map[data[i]._key] = data[i];
data[i]._key = undefined; data[i]._key = undefined;
} }

@ -46,7 +46,7 @@ module.exports = function (db, module) {
var bulk = db.collection('objects').initializeUnorderedBulkOp(); var bulk = db.collection('objects').initializeUnorderedBulkOp();
for(var i = 0; i < keys.length; ++i) { for(var i = 0; i < keys.length; i += 1) {
bulk.find({_key: keys[i]}).upsert().updateOne({ $addToSet: { bulk.find({_key: keys[i]}).upsert().updateOne({ $addToSet: {
members: { members: {
$each: value, $each: value,
@ -83,7 +83,7 @@ module.exports = function (db, module) {
var bulk = db.collection('objects').initializeUnorderedBulkOp(); var bulk = db.collection('objects').initializeUnorderedBulkOp();
for(var i = 0; i < keys.length; ++i) { for(var i = 0; i < keys.length; i += 1) {
bulk.find({_key: keys[i]}).updateOne({$pull: { bulk.find({_key: keys[i]}).updateOne({$pull: {
members: value, members: value,
}}); }});
@ -110,7 +110,7 @@ module.exports = function (db, module) {
return callback(null, []); return callback(null, []);
} }
for (var i = 0; i < values.length; ++i) { for (var i = 0; i < values.length; i += 1) {
values[i] = helpers.valueToString(values[i]); values[i] = helpers.valueToString(values[i]);
} }
@ -174,7 +174,7 @@ module.exports = function (db, module) {
}); });
var returnData = new Array(keys.length); var returnData = new Array(keys.length);
for(var i = 0; i < keys.length; ++i) { for(var i = 0; i < keys.length; i += 1) {
returnData[i] = sets[keys[i]] || []; returnData[i] = sets[keys[i]] || [];
} }
callback(null, returnData); callback(null, returnData);

@ -212,7 +212,7 @@ module.exports = function (db, module) {
return callback(null, []); return callback(null, []);
} }
var data = new Array(values.length); var data = new Array(values.length);
for (var i = 0; i < values.length; ++i) { for (var i = 0; i < values.length; i += 1) {
data[i] = {key: keys[i], value: values[i]}; data[i] = {key: keys[i], value: values[i]};
} }
@ -263,7 +263,7 @@ module.exports = function (db, module) {
var returnData = []; var returnData = [];
var item; var item;
for(var i = 0; i < keys.length; ++i) { for(var i = 0; i < keys.length; i += 1) {
item = map[keys[i]]; item = map[keys[i]];
returnData.push(item ? item.score : null); returnData.push(item ? item.score : null);
} }
@ -290,7 +290,7 @@ module.exports = function (db, module) {
var returnData = new Array(values.length); var returnData = new Array(values.length);
var score; var score;
for(var i = 0; i < values.length; ++i) { for(var i = 0; i < values.length; i += 1) {
score = map[values[i]]; score = map[values[i]];
returnData[i] = utils.isNumber(score) ? score : null; returnData[i] = utils.isNumber(score) ? score : null;
} }
@ -367,7 +367,7 @@ module.exports = function (db, module) {
}); });
var returnData = new Array(keys.length); var returnData = new Array(keys.length);
for(var i = 0; i < keys.length; ++i) { for(var i = 0; i < keys.length; i += 1) {
returnData[i] = sets[keys[i]] || []; returnData[i] = sets[keys[i]] || [];
} }
callback(null, returnData); callback(null, returnData);

@ -35,7 +35,7 @@ module.exports = function (db, module) {
var bulk = db.collection('objects').initializeUnorderedBulkOp(); var bulk = db.collection('objects').initializeUnorderedBulkOp();
for(var i = 0; i < scores.length; ++i) { for(var i = 0; i < scores.length; i += 1) {
bulk.find({_key: key, value: values[i]}).upsert().updateOne({$set: {score: parseFloat(scores[i])}}); bulk.find({_key: key, value: values[i]}).upsert().updateOne({$set: {score: parseFloat(scores[i])}});
} }
@ -53,7 +53,7 @@ module.exports = function (db, module) {
var bulk = db.collection('objects').initializeUnorderedBulkOp(); var bulk = db.collection('objects').initializeUnorderedBulkOp();
for(var i = 0; i < keys.length; ++i) { for(var i = 0; i < keys.length; i += 1) {
bulk.find({_key: keys[i], value: value}).upsert().updateOne({$set: {score: parseFloat(score)}}); bulk.find({_key: keys[i], value: value}).upsert().updateOne({$set: {score: parseFloat(score)}});
} }

@ -52,14 +52,14 @@ module.exports = function (redisClient, module) {
} }
var multi = redisClient.multi(); var multi = redisClient.multi();
for(var x = 0; x < keys.length; ++x) { for(var x = 0; x < keys.length; x += 1) {
multi.hmget.apply(multi, [keys[x]].concat(fields)); multi.hmget.apply(multi, [keys[x]].concat(fields));
} }
function makeObject(array) { function makeObject(array) {
var obj = {}; var obj = {};
for (var i = 0, ii = fields.length; i < ii; ++i) { for (var i = 0, ii = fields.length; i < ii; i += 1) {
obj[fields[i]] = array[i]; obj[fields[i]] = array[i];
} }
return obj; return obj;

@ -5,7 +5,7 @@ var helpers = {};
helpers.multiKeys = function (redisClient, command, keys, callback) { helpers.multiKeys = function (redisClient, command, keys, callback) {
callback = callback || function () {}; callback = callback || function () {};
var multi = redisClient.multi(); var multi = redisClient.multi();
for (var i = 0; i < keys.length; ++i) { for (var i = 0; i < keys.length; i += 1) {
multi[command](keys[i]); multi[command](keys[i]);
} }
multi.exec(callback); multi.exec(callback);
@ -14,7 +14,7 @@ helpers.multiKeys = function (redisClient, command, keys, callback) {
helpers.multiKeysValue = function (redisClient, command, keys, value, callback) { helpers.multiKeysValue = function (redisClient, command, keys, value, callback) {
callback = callback || function () {}; callback = callback || function () {};
var multi = redisClient.multi(); var multi = redisClient.multi();
for (var i = 0; i < keys.length; ++i) { for (var i = 0; i < keys.length; i += 1) {
multi[command](keys[i], value); multi[command](keys[i], value);
} }
multi.exec(callback); multi.exec(callback);
@ -23,14 +23,14 @@ helpers.multiKeysValue = function (redisClient, command, keys, value, callback)
helpers.multiKeyValues = function (redisClient, command, key, values, callback) { helpers.multiKeyValues = function (redisClient, command, key, values, callback) {
callback = callback || function () {}; callback = callback || function () {};
var multi = redisClient.multi(); var multi = redisClient.multi();
for (var i = 0; i < values.length; ++i) { for (var i = 0; i < values.length; i += 1) {
multi[command](key, values[i]); multi[command](key, values[i]);
} }
multi.exec(callback); multi.exec(callback);
}; };
helpers.resultsToBool = function (results) { helpers.resultsToBool = function (results) {
for (var i = 0; i < results.length; ++i) { for (var i = 0; i < results.length; i += 1) {
results[i] = results[i] === 1; results[i] = results[i] === 1;
} }
return results; return results;

@ -30,7 +30,7 @@ module.exports = function (redisClient, module) {
module.deleteAll = function (keys, callback) { module.deleteAll = function (keys, callback) {
callback = callback || function () {}; callback = callback || function () {};
var multi = redisClient.multi(); var multi = redisClient.multi();
for(var i = 0; i < keys.length; ++i) { for(var i = 0; i < keys.length; i += 1) {
multi.del(keys[i]); multi.del(keys[i]);
} }
multi.exec(function (err, res) { multi.exec(function (err, res) {

@ -94,7 +94,7 @@ module.exports = function (redisClient, module) {
return callback(null, []); return callback(null, []);
} }
var multi = redisClient.multi(); var multi = redisClient.multi();
for(var i = 0; i < keys.length; ++i) { for(var i = 0; i < keys.length; i += 1) {
multi.zcard(keys[i]); multi.zcard(keys[i]);
} }
multi.exec(callback); multi.exec(callback);
@ -106,7 +106,7 @@ module.exports = function (redisClient, module) {
module.sortedSetsRanks = function (keys, values, callback) { module.sortedSetsRanks = function (keys, values, callback) {
var multi = redisClient.multi(); var multi = redisClient.multi();
for(var i = 0; i < values.length; ++i) { for(var i = 0; i < values.length; i += 1) {
multi.zrank(keys[i], values[i]); multi.zrank(keys[i], values[i]);
} }
multi.exec(callback); multi.exec(callback);
@ -114,7 +114,7 @@ module.exports = function (redisClient, module) {
module.sortedSetRanks = function (key, values, callback) { module.sortedSetRanks = function (key, values, callback) {
var multi = redisClient.multi(); var multi = redisClient.multi();
for(var i = 0; i < values.length; ++i) { for(var i = 0; i < values.length; i += 1) {
multi.zrank(key, values[i]); multi.zrank(key, values[i]);
} }
multi.exec(callback); multi.exec(callback);
@ -164,7 +164,7 @@ module.exports = function (redisClient, module) {
module.getSortedSetsMembers = function (keys, callback) { module.getSortedSetsMembers = function (keys, callback) {
var multi = redisClient.multi(); var multi = redisClient.multi();
for (var i = 0; i < keys.length; ++i) { for (var i = 0; i < keys.length; i += 1) {
multi.zrange(keys[i], 0, -1); multi.zrange(keys[i], 0, -1);
} }
multi.exec(callback); multi.exec(callback);

@ -23,7 +23,7 @@ module.exports = function (redisClient, module) {
var args = [key]; var args = [key];
for(var i = 0; i < scores.length; ++i) { for(var i = 0; i < scores.length; i += 1) {
args.push(scores[i], values[i]); args.push(scores[i], values[i]);
} }
@ -36,7 +36,7 @@ module.exports = function (redisClient, module) {
callback = callback || function () {}; callback = callback || function () {};
var multi = redisClient.multi(); var multi = redisClient.multi();
for(var i = 0; i < keys.length; ++i) { for(var i = 0; i < keys.length; i += 1) {
multi.zadd(keys[i], score, value); multi.zadd(keys[i], score, value);
} }

@ -28,7 +28,7 @@ module.exports = function (redisClient, module) {
module.sortedSetsRemoveRangeByScore = function (keys, min, max, callback) { module.sortedSetsRemoveRangeByScore = function (keys, min, max, callback) {
callback = callback || function () {}; callback = callback || function () {};
var multi = redisClient.multi(); var multi = redisClient.multi();
for(var i = 0; i < keys.length; ++i) { for(var i = 0; i < keys.length; i += 1) {
multi.zremrangebyscore(keys[i], min, max); multi.zremrangebyscore(keys[i], min, max);
} }
multi.exec(function (err) { multi.exec(function (err) {

@ -34,8 +34,7 @@ var utils = require('../public/src/utils');
}; };
}, },
removeEphemeralGroups: function (groups) { removeEphemeralGroups: function (groups) {
var x = groups.length; for (var x = groups.length; x >= 0; x -= 1) {
while(x--) {
if (ephemeralGroups.indexOf(groups[x]) !== -1) { if (ephemeralGroups.indexOf(groups[x]) !== -1) {
groups.splice(x, 1); groups.splice(x, 1);
} }

@ -471,7 +471,7 @@ module.exports = function (Groups) {
}); });
var result = members.map(function (groupNames) { var result = members.map(function (groupNames) {
for (var i = 0; i < groupNames.length; ++i) { for (var i = 0; i < groupNames.length; i += 1) {
if (map[groupNames[i]]) { if (map[groupNames[i]]) {
return true; return true;
} }

@ -77,7 +77,7 @@ module.exports = function (Groups) {
}, },
function (users, next) { function (users, next) {
var uids = []; var uids = [];
for(var i = 0; i < users.length; ++i) { for(var i = 0; i < users.length; i += 1) {
var field = users[i][searchBy]; var field = users[i][searchBy];
if (field.toLowerCase().startsWith(query)) { if (field.toLowerCase().startsWith(query)) {
uids.push(users[i].uid); uids.push(users[i].uid);

@ -10,7 +10,7 @@ HotSwap.prepare = function (app) {
HotSwap.find = function (id) { HotSwap.find = function (id) {
if (stack) { if (stack) {
for(var x = 0,numEntries = stack.length; x < numEntries; x++) { for(var x = 0, numEntries = stack.length; x < numEntries; x += 1) {
if (stack[x].handle.hotswapId === id) { if (stack[x].handle.hotswapId === id) {
return x; return x;
} }

@ -331,7 +331,7 @@ Messaging.hasPrivateChat = function (uid, withUid, callback) {
roomId = roomIds[index]; roomId = roomIds[index];
next(null, roomId); next(null, roomId);
} else { } else {
++ index; index += 1;
next(); next();
} }
}); });

@ -13,7 +13,7 @@ ratelimit.isFlooding = function (socket) {
socket.elapsedTime = socket.elapsedTime || 0; socket.elapsedTime = socket.elapsedTime || 0;
socket.lastCallTime = socket.lastCallTime || Date.now(); socket.lastCallTime = socket.lastCallTime || Date.now();
++socket.callsPerSecond; socket.callsPerSecond += 1;
var now = Date.now(); var now = Date.now();
socket.elapsedTime += now - socket.lastCallTime; socket.elapsedTime += now - socket.lastCallTime;

@ -26,7 +26,7 @@ pagination.create = function (currentPage, pageCount, queryObj) {
if (startPage > pageCount - 5) { if (startPage > pageCount - 5) {
startPage -= 2 - (pageCount - currentPage); startPage -= 2 - (pageCount - currentPage);
} }
for(var i = 0; i < 5; ++i) { for(var i = 0; i < 5; i += 1) {
pagesToShow.push(startPage + i); pagesToShow.push(startPage + i);
} }
@ -45,7 +45,7 @@ pagination.create = function (currentPage, pageCount, queryObj) {
return {page: page, active: page === currentPage, qs: qs.stringify(queryObj)}; return {page: page, active: page === currentPage, qs: qs.stringify(queryObj)};
}); });
for (i = pages.length - 1; i > 0; --i) { for (i = pages.length - 1; i > 0; i -= 1) {
if (pages[i].page - 2 === pages[i - 1].page) { if (pages[i].page - 2 === pages[i - 1].page) {
pages.splice(i, 0, {page: pages[i].page - 1, active: false, qs: qs.stringify(queryObj)}); pages.splice(i, 0, {page: pages[i].page - 1, active: false, qs: qs.stringify(queryObj)});
} else if (pages[i].page - 1 !== pages[i - 1].page) { } else if (pages[i].page - 1 !== pages[i - 1].page) {

@ -107,7 +107,7 @@ var middleware;
if (Plugins.versionWarning.length && nconf.get('isPrimary') === 'true') { if (Plugins.versionWarning.length && nconf.get('isPrimary') === 'true') {
process.stdout.write('\n'); process.stdout.write('\n');
winston.warn('[plugins/load] The following plugins may not be compatible with your version of NodeBB. This may cause unintended behaviour or crashing. In the event of an unresponsive NodeBB caused by this plugin, run `./nodebb reset -p PLUGINNAME` to disable it.'); winston.warn('[plugins/load] The following plugins may not be compatible with your version of NodeBB. This may cause unintended behaviour or crashing. In the event of an unresponsive NodeBB caused by this plugin, run `./nodebb reset -p PLUGINNAME` to disable it.');
for(var x = 0,numPlugins = Plugins.versionWarning.length; x < numPlugins; x++) { for(var x = 0, numPlugins = Plugins.versionWarning.length; x < numPlugins; x += 1) {
process.stdout.write(' * '.yellow + Plugins.versionWarning[x] + '\n'); process.stdout.write(' * '.yellow + Plugins.versionWarning[x] + '\n');
} }
process.stdout.write('\n'); process.stdout.write('\n');
@ -252,7 +252,7 @@ var middleware;
var pluginMap = {}; var pluginMap = {};
var dependencies = require(path.join(nconf.get('base_dir'), 'package.json')).dependencies; var dependencies = require(path.join(nconf.get('base_dir'), 'package.json')).dependencies;
apiReturn = apiReturn || []; apiReturn = apiReturn || [];
for(var i = 0; i < apiReturn.length; ++i) { for(var i = 0; i < apiReturn.length; i += 1) {
apiReturn[i].id = apiReturn[i].name; apiReturn[i].id = apiReturn[i].name;
apiReturn[i].installed = false; apiReturn[i].installed = false;
apiReturn[i].active = false; apiReturn[i].active = false;

@ -44,7 +44,7 @@ var plugins = require('./plugins');
var keys = []; var keys = [];
for (var x = 0, numPids = pids.length; x < numPids; ++x) { for (var x = 0, numPids = pids.length; x < numPids; x += 1) {
keys.push('post:' + pids[x]); keys.push('post:' + pids[x]);
} }
@ -212,7 +212,7 @@ var plugins = require('./plugins');
db[method](sets, pids, next); db[method](sets, pids, next);
}, },
function (indices, next) { function (indices, next) {
for (var i = 0; i < indices.length; ++i) { for (var i = 0; i < indices.length; i += 1) {
indices[i] = utils.isNumber(indices[i]) ? parseInt(indices[i], 10) + 1 : 0; indices[i] = utils.isNumber(indices[i]) ? parseInt(indices[i], 10) + 1 : 0;
} }

@ -136,7 +136,7 @@ module.exports = function (Posts) {
function toObject(key, data) { function toObject(key, data) {
var obj = {}; var obj = {};
for(var i = 0; i < data.length; ++i) { for(var i = 0; i < data.length; i += 1) {
obj[data[i][key]] = data[i]; obj[data[i][key]] = data[i];
} }
return obj; return obj;

@ -84,7 +84,7 @@ module.exports = function (Posts) {
var upvoteSets = []; var upvoteSets = [];
var downvoteSets = []; var downvoteSets = [];
for (var i = 0; i < pids.length; ++i) { for (var i = 0; i < pids.length; i += 1) {
upvoteSets.push('pid:' + pids[i] + ':upvote'); upvoteSets.push('pid:' + pids[i] + ':upvote');
downvoteSets.push('pid:' + pids[i] + ':downvote'); downvoteSets.push('pid:' + pids[i] + ':downvote');
} }

@ -66,7 +66,7 @@ module.exports = function (privileges) {
memberData.forEach(function (member) { memberData.forEach(function (member) {
member.privileges = {}; member.privileges = {};
for(var x = 0,numPrivs = userPrivileges.length; x < numPrivs; x++) { for(var x = 0,numPrivs = userPrivileges.length; x < numPrivs; x += 1) {
member.privileges[userPrivileges[x]] = memberSets[x].indexOf(parseInt(member.uid, 10)) !== -1; member.privileges[userPrivileges[x]] = memberSets[x].indexOf(parseInt(member.uid, 10)) !== -1;
} }
}); });
@ -117,7 +117,7 @@ module.exports = function (privileges) {
var memberData = groupNames.map(function (member) { var memberData = groupNames.map(function (member) {
memberPrivs = {}; memberPrivs = {};
for(var x = 0,numPrivs = groupPrivileges.length; x < numPrivs; x++) { for(var x = 0,numPrivs = groupPrivileges.length; x < numPrivs; x += 1) {
memberPrivs[groupPrivileges[x]] = memberSets[x].indexOf(member) !== -1; memberPrivs[groupPrivileges[x]] = memberSets[x].indexOf(member) !== -1;
} }
return { return {

@ -33,7 +33,7 @@ function isUserAllowedToCids(privilege, uid, cids, callback) {
var userKeys = []; var userKeys = [];
var groupKeys = []; var groupKeys = [];
for (var i = 0; i < cids.length; ++i) { for (var i = 0; i < cids.length; i += 1) {
userKeys.push('cid:' + cids[i] + ':privileges:' + privilege); userKeys.push('cid:' + cids[i] + ':privileges:' + privilege);
groupKeys.push('cid:' + cids[i] + ':privileges:groups:' + privilege); groupKeys.push('cid:' + cids[i] + ':privileges:groups:' + privilege);
} }
@ -51,7 +51,7 @@ function isUserAllowedToCids(privilege, uid, cids, callback) {
} }
var result = []; var result = [];
for (var i = 0; i < cids.length; ++i) { for (var i = 0; i < cids.length; i += 1) {
result.push(results.hasUserPrivilege[i] || results.hasGroupPrivilege[i]); result.push(results.hasUserPrivilege[i] || results.hasGroupPrivilege[i]);
} }
@ -66,7 +66,7 @@ function isUserAllowedToPrivileges(privileges, uid, cid, callback) {
var userKeys = []; var userKeys = [];
var groupKeys = []; var groupKeys = [];
for (var i = 0; i < privileges.length; ++i) { for (var i = 0; i < privileges.length; i += 1) {
userKeys.push('cid:' + cid + ':privileges:' + privileges[i]); userKeys.push('cid:' + cid + ':privileges:' + privileges[i]);
groupKeys.push('cid:' + cid + ':privileges:groups:' + privileges[i]); groupKeys.push('cid:' + cid + ':privileges:groups:' + privileges[i]);
} }
@ -84,7 +84,7 @@ function isUserAllowedToPrivileges(privileges, uid, cid, callback) {
} }
var result = []; var result = [];
for (var i = 0; i < privileges.length; ++i) { for (var i = 0; i < privileges.length; i += 1) {
result.push(results.hasUserPrivilege[i] || results.hasGroupPrivilege[i]); result.push(results.hasUserPrivilege[i] || results.hasGroupPrivilege[i]);
} }
@ -107,7 +107,7 @@ helpers.isUsersAllowedTo = function (privilege, uids, cid, callback) {
} }
var result = []; var result = [];
for(var i = 0; i < uids.length; ++i) { for(var i = 0; i < uids.length; i += 1) {
result.push(results.hasUserPrivilege[i] || results.hasGroupPrivilege[i]); result.push(results.hasUserPrivilege[i] || results.hasGroupPrivilege[i]);
} }
@ -117,7 +117,7 @@ helpers.isUsersAllowedTo = function (privilege, uids, cid, callback) {
function isGuestAllowedToCids(privilege, cids, callback) { function isGuestAllowedToCids(privilege, cids, callback) {
var groupKeys = []; var groupKeys = [];
for (var i = 0; i < cids.length; ++i) { for (var i = 0; i < cids.length; i += 1) {
groupKeys.push('cid:' + cids[i] + ':privileges:groups:' + privilege); groupKeys.push('cid:' + cids[i] + ':privileges:groups:' + privilege);
} }
@ -126,7 +126,7 @@ function isGuestAllowedToCids(privilege, cids, callback) {
function isGuestAllowedToPrivileges(privileges, cid, callback) { function isGuestAllowedToPrivileges(privileges, cid, callback) {
var groupKeys = []; var groupKeys = [];
for (var i = 0; i < privileges.length; ++i) { for (var i = 0; i < privileges.length; i += 1) {
groupKeys.push('cid:' + cid + ':privileges:groups:' + privileges[i]); groupKeys.push('cid:' + cid + ':privileges:groups:' + privileges[i]);
} }

@ -40,7 +40,7 @@ module.exports = function (privileges) {
var privileges = []; var privileges = [];
for (var i = 0; i < pids.length; ++i) { for (var i = 0; i < pids.length; i += 1) {
var isAdminOrMod = results.isAdmin || results.isModerator[i]; var isAdminOrMod = results.isAdmin || results.isModerator[i];
var editable = isAdminOrMod || (results.isOwner[i] && results['posts:edit'][i]); var editable = isAdminOrMod || (results.isOwner[i] && results['posts:edit'][i]);

@ -98,7 +98,7 @@ module.exports = function (app, middleware, hotswapIds) {
var ensureLoggedIn = require('connect-ensure-login'); var ensureLoggedIn = require('connect-ensure-login');
if (Array.isArray(hotswapIds) && hotswapIds.length) { if (Array.isArray(hotswapIds) && hotswapIds.length) {
for(var idx,x = 0; x < hotswapIds.length; x++) { for(var idx,x = 0; x < hotswapIds.length; x += 1) {
idx = routers.push(express.Router()) - 1; idx = routers.push(express.Router()) - 1;
routers[idx].hotswapId = hotswapIds[x]; routers[idx].hotswapId = hotswapIds[x];
} }
@ -132,7 +132,7 @@ module.exports = function (app, middleware, hotswapIds) {
userRoutes(router, middleware, controllers); userRoutes(router, middleware, controllers);
groupRoutes(router, middleware, controllers); groupRoutes(router, middleware, controllers);
for(var x = 0; x < routers.length; x++) { for(var x = 0; x < routers.length; x += 1) {
app.use(relativePath, routers[x]); app.use(relativePath, routers[x]);
} }

@ -134,7 +134,7 @@ Settings.prototype.get = function (key, def) {
var obj = this.cfg._; var obj = this.cfg._;
var parts = (key || '').split('.'); var parts = (key || '').split('.');
var part; var part;
for (var i = 0; i < parts.length; i++) { for (var i = 0; i < parts.length; i += 1) {
part = parts[i]; part = parts[i];
if (part && obj != null) { if (part && obj != null) {
obj = obj[part]; obj = obj[part];
@ -143,7 +143,7 @@ Settings.prototype.get = function (key, def) {
if (obj === void 0) { if (obj === void 0) {
if (def === void 0) { if (def === void 0) {
def = this.defCfg; def = this.defCfg;
for (var j = 0; j < parts.length; j++) { for (var j = 0; j < parts.length; j += 1) {
part = parts[j]; part = parts[j];
if (part && def != null) { if (part && def != null) {
def = def[part]; def = def[part];
@ -197,7 +197,7 @@ Settings.prototype.set = function (key, val) {
} else { } else {
obj = this.cfg._; obj = this.cfg._;
parts = key.split('.'); parts = key.split('.');
for (var i = 0, _len = parts.length - 1; i < _len; i++) { for (var i = 0, _len = parts.length - 1; i < _len; i += 1) {
if (part = parts[i]) { if (part = parts[i]) {
if (!obj.hasOwnProperty(part)) { if (!obj.hasOwnProperty(part)) {
obj[part] = {}; obj[part] = {};

@ -38,7 +38,7 @@ sitemap.render = function (callback) {
numPages = Math.ceil(tids.length / numTopics); numPages = Math.ceil(tids.length / numTopics);
} }
for(var x = 1; x <= numPages; x++) { for(var x = 1; x <= numPages; x += 1) {
returnData.topics.push(x); returnData.topics.push(x);
} }

@ -123,7 +123,7 @@ SocketRooms.getOnlineUserCount = function (io) {
if (io) { if (io) {
for (var key in io.sockets.adapter.rooms) { for (var key in io.sockets.adapter.rooms) {
if (io.sockets.adapter.rooms.hasOwnProperty(key) && key.startsWith('uid_')) { if (io.sockets.adapter.rooms.hasOwnProperty(key) && key.startsWith('uid_')) {
++ count; count += 1;
} }
} }
} }

@ -22,7 +22,7 @@ User.makeAdmins = function (socket, uids, callback) {
return callback(err); return callback(err);
} }
for(var i = 0; i < userData.length; i++) { for(var i = 0; i < userData.length; i += 1) {
if (userData[i] && parseInt(userData[i].banned, 10) === 1) { if (userData[i] && parseInt(userData[i].banned, 10) === 1) {
return callback(new Error('[[error:cant-make-banned-users-admin]]')); return callback(new Error('[[error:cant-make-banned-users-admin]]'));
} }

@ -138,7 +138,7 @@ var social = require('./social');
var users = _.object(uids, results.users); var users = _.object(uids, results.users);
var categories = _.object(cids, results.categories); var categories = _.object(cids, results.categories);
for (var i = 0; i < topics.length; ++i) { for (var i = 0; i < topics.length; i += 1) {
if (topics[i]) { if (topics[i]) {
topics[i].category = categories[topics[i].cid]; topics[i].category = categories[topics[i].cid];
topics[i].user = users[topics[i].uid]; topics[i].user = users[topics[i].uid];
@ -224,9 +224,9 @@ var social = require('./social');
async.waterfall([ async.waterfall([
function (next) { function (next) {
if (stop > 0) { if (stop > 0) {
stop--; stop -= 1;
if (start > 0) { if (start > 0) {
start --; start -= 1;
} }
} }

@ -63,8 +63,8 @@ module.exports = function (Topics) {
var bookmark = data.bookmark; var bookmark = data.bookmark;
bookmark = bookmark < maxIndex ? bookmark : maxIndex; bookmark = bookmark < maxIndex ? bookmark : maxIndex;
for (var i = 0; i < postIndices.length && postIndices[i] < data.bookmark; ++i) { for (var i = 0; i < postIndices.length && postIndices[i] < data.bookmark; i += 1) {
--bookmark; bookmark -= 1;
} }
if (parseInt(bookmark, 10) !== parseInt(data.bookmark, 10)) { if (parseInt(bookmark, 10) !== parseInt(data.bookmark, 10)) {

@ -40,7 +40,7 @@ module.exports = function (Topics) {
Topics.getTopicsData = function (tids, callback) { Topics.getTopicsData = function (tids, callback) {
var keys = []; var keys = [];
for (var i = 0; i < tids.length; ++i) { for (var i = 0; i < tids.length; i += 1) {
keys.push('topic:' + tids[i]); keys.push('topic:' + tids[i]);
} }

@ -69,7 +69,7 @@ module.exports = function (Topics) {
userData: function (next) { userData: function (next) {
var uids = []; var uids = [];
for(var i = 0; i < postData.length; ++i) { for(var i = 0; i < postData.length; i += 1) {
if (postData[i] && uids.indexOf(postData[i].uid) === -1) { if (postData[i] && uids.indexOf(postData[i].uid) === -1) {
uids.push(postData[i].uid); uids.push(postData[i].uid);
} }
@ -90,7 +90,7 @@ module.exports = function (Topics) {
}, },
editors: function (next) { editors: function (next) {
var editors = []; var editors = [];
for(var i = 0; i < postData.length; ++i) { for(var i = 0; i < postData.length; i += 1) {
if (postData[i] && postData[i].editor && editors.indexOf(postData[i].editor) === -1) { if (postData[i] && postData[i].editor && editors.indexOf(postData[i].editor) === -1) {
editors.push(postData[i].editor); editors.push(postData[i].editor);
} }
@ -253,7 +253,7 @@ module.exports = function (Topics) {
if (!isDeleted) { if (!isDeleted) {
latestPid = pids[0]; latestPid = pids[0];
} }
++index; index += 1;
next(); next();
}); });
}); });

@ -366,7 +366,7 @@ module.exports = function (Topics) {
query = query.toLowerCase(); query = query.toLowerCase();
var matches = []; var matches = [];
for(var i = 0; i < tags.length; ++i) { for(var i = 0; i < tags.length; i += 1) {
if (tags[i].toLowerCase().startsWith(query)) { if (tags[i].toLowerCase().startsWith(query)) {
matches.push(tags[i]); matches.push(tags[i]);
if (matches.length > 19) { if (matches.length > 19) {

@ -241,14 +241,14 @@ Upgrade.upgrade = function (callback) {
async.waterfall([ async.waterfall([
async.apply(db.getObjectField, 'user:' + uid + ':settings', 'userLang'), async.apply(db.getObjectField, 'user:' + uid + ':settings', 'userLang'),
function (language, next) { function (language, next) {
++i; i += 1;
if (!language) { if (!language) {
return setImmediate(next); return setImmediate(next);
} }
newLanguage = language.replace('_', '-').replace('@', '-x-'); newLanguage = language.replace('_', '-').replace('@', '-x-');
if (newLanguage !== language) { if (newLanguage !== language) {
++j; j += 1;
user.setSetting(uid, 'userLang', newLanguage, next); user.setSetting(uid, 'userLang', newLanguage, next);
} else { } else {
setImmediate(next); setImmediate(next);

@ -171,7 +171,7 @@ var meta = require('./meta');
User.existsBySlug = function (userslug, callback) { User.existsBySlug = function (userslug, callback) {
User.getUidByUserslug(userslug, function (err, exists) { User.getUidByUserslug(userslug, function (err, exists) {
callback(err, !! exists); callback(err, !!exists);
}); });
}; };

@ -126,7 +126,7 @@ module.exports = function (User) {
user.status = User.getStatus(user); user.status = User.getStatus(user);
} }
for(var i = 0; i < fieldsToRemove.length; ++i) { for(var i = 0; i < fieldsToRemove.length; i += 1) {
user[fieldsToRemove[i]] = undefined; user[fieldsToRemove[i]] = undefined;
} }

@ -27,7 +27,7 @@ module.exports = function (User) {
winston.verbose('[user/jobs] Terminating job (' + jobId + ')'); winston.verbose('[user/jobs] Terminating job (' + jobId + ')');
jobs[jobId].stop(); jobs[jobId].stop();
delete jobs[jobId]; delete jobs[jobId];
++terminated; terminated += 1;
} }
} }
winston.verbose('[user/jobs] ' + terminated + ' jobs terminated'); winston.verbose('[user/jobs] ' + terminated + ' jobs terminated');
@ -37,25 +37,25 @@ module.exports = function (User) {
User.digest.execute('day'); User.digest.execute('day');
}, null, true); }, null, true);
winston.verbose('[user/jobs] Starting job (digest.daily)'); winston.verbose('[user/jobs] Starting job (digest.daily)');
++started; started += 1;
jobs['digest.weekly'] = new cronJob('0 ' + digestHour + ' * * 0', function () { jobs['digest.weekly'] = new cronJob('0 ' + digestHour + ' * * 0', function () {
winston.verbose('[user/jobs] Digest job (weekly) started.'); winston.verbose('[user/jobs] Digest job (weekly) started.');
User.digest.execute('week'); User.digest.execute('week');
}, null, true); }, null, true);
winston.verbose('[user/jobs] Starting job (digest.weekly)'); winston.verbose('[user/jobs] Starting job (digest.weekly)');
++started; started += 1;
jobs['digest.monthly'] = new cronJob('0 ' + digestHour + ' 1 * *', function () { jobs['digest.monthly'] = new cronJob('0 ' + digestHour + ' 1 * *', function () {
winston.verbose('[user/jobs] Digest job (monthly) started.'); winston.verbose('[user/jobs] Digest job (monthly) started.');
User.digest.execute('month'); User.digest.execute('month');
}, null, true); }, null, true);
winston.verbose('[user/jobs] Starting job (digest.monthly)'); winston.verbose('[user/jobs] Starting job (digest.monthly)');
++started; started += 1;
jobs['reset.clean'] = new cronJob('0 0 * * *', User.reset.clean, null, true); jobs['reset.clean'] = new cronJob('0 0 * * *', User.reset.clean, null, true);
winston.verbose('[user/jobs] Starting job (reset.clean)'); winston.verbose('[user/jobs] Starting job (reset.clean)');
++started; started += 1;
winston.verbose('[user/jobs] ' + started + ' jobs started'); winston.verbose('[user/jobs] ' + started + ' jobs started');

@ -146,7 +146,7 @@ var privileges = require('../privileges');
callback(err, mergeIds.reduce(function (count, cur, idx, arr) { callback(err, mergeIds.reduce(function (count, cur, idx, arr) {
if (cur === null || idx === arr.indexOf(cur)) { if (cur === null || idx === arr.indexOf(cur)) {
++count; count += 1;
} }
return count; return count;

@ -36,7 +36,7 @@ module.exports = function (User) {
return callback(err); return callback(err);
} }
for (var i = 0; i < settings.length; ++i) { for (var i = 0; i < settings.length; i += 1) {
settings[i] = settings[i] || {}; settings[i] = settings[i] || {};
settings[i].uid = uids[i]; settings[i].uid = uids[i];
} }

@ -60,7 +60,7 @@ admin.get = function (callback) {
areas: [], areas: [],
}); });
index++; index += 1;
} }
templates[list[area.template]].areas.push({ templates[list[area.template]].areas.push({

@ -30,7 +30,7 @@ describe('Plugins', function () {
it('should register and fire a filter hook', function (done) { it('should register and fire a filter hook', function (done) {
function filterMethod1(data, callback) { function filterMethod1(data, callback) {
data.foo ++; data.foo += 1;
callback(null, data); callback(null, data);
} }
function filterMethod2(data, callback) { function filterMethod2(data, callback) {

@ -366,7 +366,7 @@ describe('Post\'s', function () {
it('should error with too many tags', function (done) { it('should error with too many tags', function (done) {
var tags = []; var tags = [];
for(var i = 0; i < meta.config.maximumTagsPerTopic + 1; ++i) { for(var i = 0; i < meta.config.maximumTagsPerTopic + 1; i += 1) {
tags.push('tag' + i); tags.push('tag' + i);
} }
socketPosts.edit({uid: voterUid}, {pid: pid, content: 'edited post content', tags: tags}, function (err) { socketPosts.edit({uid: voterUid}, {pid: pid, content: 'edited post content', tags: tags}, function (err) {

@ -505,7 +505,7 @@ describe('Topic\'s', function () {
var topics = results.topics; var topics = results.topics;
var topic; var topic;
var i; var i;
for(i = 0; i < topics.length; ++i) { for(i = 0; i < topics.length; i += 1) {
if (parseInt(topics[i].tid, 10) === parseInt(newTid, 10)) { if (parseInt(topics[i].tid, 10) === parseInt(newTid, 10)) {
assert.equal(false, topics[i].unread, 'ignored topic was marked as unread in recent list'); assert.equal(false, topics[i].unread, 'ignored topic was marked as unread in recent list');
return done(); return done();

@ -151,10 +151,10 @@ describe('Utility Methods', function () {
var currentHour = new Date().getHours(); var currentHour = new Date().getHours();
var hours = utils.getHoursArray(); var hours = utils.getHoursArray();
var index = hours.length - 1; var index = hours.length - 1;
for (var i = currentHour, ii = currentHour - 24; i > ii; i--) { for (var i = currentHour, ii = currentHour - 24; i > ii; i -= 1) {
var hour = i < 0 ? 24 + i : i; var hour = i < 0 ? 24 + i : i;
assert.equal(hours[index], hour + ':00'); assert.equal(hours[index], hour + ':00');
-- index; index -= 1;
} }
done(); done();
}); });
@ -164,10 +164,10 @@ describe('Utility Methods', function () {
var days = utils.getDaysArray(); var days = utils.getDaysArray();
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
var index = 0; var index = 0;
for(var x = 29; x >= 0; x--) { for(var x = 29; x >= 0; x -= 1) {
var tmpDate = new Date(currentDay - (1000 * 60 * 60 * 24 * x)); var tmpDate = new Date(currentDay - (1000 * 60 * 60 * 24 * x));
assert.equal(months[tmpDate.getMonth()] + ' ' + tmpDate.getDate(), days[index]); assert.equal(months[tmpDate.getMonth()] + ' ' + tmpDate.getDate(), days[index]);
++ index; index += 1;
} }
done(); done();
}); });

Loading…
Cancel
Save