From 604358ecc4cb3ffeeec765b1e876726e5015f360 Mon Sep 17 00:00:00 2001 From: Peter Jaszkowiak Date: Sat, 18 Feb 2017 01:52:56 -0700 Subject: [PATCH] ESlint keyword-spacing, no-multi-spaces --- .eslintrc | 4 ++-- app.js | 2 +- install/web.js | 2 +- loader.js | 2 +- minifier.js | 4 ++-- public/src/admin/admin.js | 2 +- public/src/admin/advanced/logs.js | 2 +- public/src/admin/appearance/themes.js | 2 +- public/src/admin/extend/widgets.js | 6 ++--- public/src/admin/general/dashboard.js | 6 ++--- public/src/admin/general/homepage.js | 2 +- public/src/admin/manage/categories.js | 8 +++---- public/src/admin/manage/category.js | 4 ++-- public/src/admin/manage/flags.js | 2 +- public/src/admin/manage/group.js | 2 +- public/src/admin/manage/groups.js | 2 +- public/src/admin/manage/users.js | 4 ++-- public/src/admin/settings.js | 2 +- public/src/app.js | 2 +- public/src/client/categories.js | 2 +- public/src/client/category.js | 4 ++-- public/src/client/category/tools.js | 8 +++---- public/src/client/chats.js | 2 +- public/src/client/groups/details.js | 2 +- public/src/client/reset.js | 2 +- public/src/client/tag.js | 2 +- public/src/client/topic/events.js | 4 ++-- public/src/client/unread.js | 12 +++++----- public/src/client/users.js | 2 +- public/src/modules/alerts.js | 6 ++--- public/src/modules/helpers.js | 6 ++--- public/src/modules/notifications.js | 2 +- public/src/modules/pictureCropper.js | 4 ++-- public/src/modules/postSelect.js | 2 +- public/src/modules/search.js | 4 ++-- public/src/modules/settings.js | 2 +- public/src/modules/topicSelect.js | 4 ++-- public/src/overrides.js | 8 +++---- public/src/sockets.js | 2 +- public/src/utils.js | 18 +++++++-------- src/analytics.js | 2 +- src/controllers/admin/groups.js | 2 +- src/controllers/admin/info.js | 2 +- src/controllers/admin/uploads.js | 2 +- src/controllers/tags.js | 2 +- src/controllers/topics.js | 2 +- src/database/mongo/hash.js | 10 ++++---- src/database/mongo/helpers.js | 6 ++--- src/database/mongo/list.js | 4 ++-- src/database/mongo/sets.js | 14 +++++------ src/database/mongo/sorted.js | 8 +++---- src/database/mongo/sorted/add.js | 4 ++-- src/database/mongo/sorted/intersect.js | 2 +- src/database/mongo/sorted/union.js | 2 +- src/database/redis/hash.js | 2 +- src/database/redis/main.js | 2 +- src/database/redis/sorted.js | 10 ++++---- src/database/redis/sorted/add.js | 4 ++-- src/database/redis/sorted/intersect.js | 2 +- src/database/redis/sorted/remove.js | 2 +- src/database/redis/sorted/union.js | 2 +- src/events.js | 2 +- src/file.js | 2 +- src/groups/search.js | 4 ++-- src/groups/update.js | 2 +- src/hotswap.js | 2 +- src/install.js | 2 +- src/logger.js | 32 +++++++++++++------------- src/meta/build.js | 2 +- src/meta/dependencies.js | 2 +- src/meta/js.js | 4 ++-- src/meta/templates.js | 2 +- src/meta/themes.js | 2 +- src/middleware/index.js | 2 +- src/middleware/user.js | 2 +- src/notifications.js | 2 +- src/pagination.js | 2 +- src/password.js | 2 +- src/plugins.js | 4 ++-- src/plugins/hooks.js | 2 +- src/plugins/load.js | 4 ++-- src/posts/flags.js | 10 ++++---- src/posts/parse.js | 2 +- src/posts/summary.js | 2 +- src/posts/tools.js | 2 +- src/privileges/categories.js | 4 ++-- src/privileges/helpers.js | 2 +- src/pubsub.js | 2 +- src/routes/api.js | 2 +- src/routes/index.js | 4 ++-- src/sitemap.js | 2 +- src/socket.io/admin/user.js | 6 ++--- src/socket.io/categories.js | 2 +- src/socket.io/groups.js | 2 +- src/socket.io/posts/votes.js | 2 +- src/socket.io/topics/infinitescroll.js | 2 +- src/socket.io/user/picture.js | 2 +- src/start.js | 2 +- src/topics/posts.js | 4 ++-- src/topics/recent.js | 2 +- src/topics/tags.js | 2 +- src/topics/teaser.js | 2 +- src/topics/tools.js | 2 +- src/upgrade.js | 6 ++--- src/user/create.js | 2 +- src/user/data.js | 2 +- src/user/delete.js | 2 +- src/user/jobs.js | 2 +- src/user/notifications.js | 2 +- src/user/profile.js | 2 +- src/user/search.js | 4 ++-- src/widgets/index.js | 4 ++-- test/mocks/databasemock.js | 2 +- test/posts.js | 2 +- test/topics.js | 2 +- test/utils.js | 4 ++-- 116 files changed, 210 insertions(+), 210 deletions(-) diff --git a/.eslintrc b/.eslintrc index 30c2dddcff..023667f42e 100644 --- a/.eslintrc +++ b/.eslintrc @@ -97,9 +97,9 @@ "consistent-return": "off", "strict": "off", // "comma-dangle": "off", - "no-multi-spaces": "off", + // "no-multi-spaces": "off", "quotes": "off", - "keyword-spacing": "off", + // "keyword-spacing": "off", // "no-mixed-operators": "off", // "comma-spacing": "off", // "no-trailing-spaces": "off", diff --git a/app.js b/app.js index 5a88f999b1..3cdd03b50c 100644 --- a/app.js +++ b/app.js @@ -155,7 +155,7 @@ function setup() { var separator = ' '; if (process.stdout.columns > 10) { - for(var x = 0, cols = process.stdout.columns - 10; x < cols; x += 1) { + for (var x = 0, cols = process.stdout.columns - 10; x < cols; x += 1) { separator += '='; } } diff --git a/install/web.js b/install/web.js index 86dbd18013..1d5a755785 100644 --- a/install/web.js +++ b/install/web.js @@ -138,7 +138,7 @@ function compileLess(callback) { } less.render(style.toString(), function (err, css) { - if(err) { + if (err) { return winston.error('Unable to compile LESS: ', err); } diff --git a/loader.js b/loader.js index a8e1bf712e..9141ead0f8 100644 --- a/loader.js +++ b/loader.js @@ -106,7 +106,7 @@ function forkWorker(index, isPrimary) { var ports = getPorts(); var args = []; - if(!ports[index]) { + if (!ports[index]) { return console.log('[cluster] invalid port for worker : ' + index + ' ports: ' + ports.length); } diff --git a/minifier.js b/minifier.js index 8504312d22..77b0151e02 100644 --- a/minifier.js +++ b/minifier.js @@ -33,7 +33,7 @@ Minifier.js.minify = function (scripts, minify, callback) { }; process.on('message', function (payload) { - switch(payload.action) { + switch (payload.action) { case 'js': Minifier.js.minify(payload.scripts, payload.minify, function (minified/* , sourceMap*/) { process.send({ @@ -56,7 +56,7 @@ function minifyScripts(scripts, callback) { }); callback(minified.code/* , minified.map*/); - } catch(err) { + } catch (err) { process.send({ type: 'error', message: err.message, diff --git a/public/src/admin/admin.js b/public/src/admin/admin.js index 45211d9934..36fbb692f6 100644 --- a/public/src/admin/admin.js +++ b/public/src/admin/admin.js @@ -33,7 +33,7 @@ $(document).ready(function () { setupKeybindings(); - if(!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { + if (!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { require(['admin/modules/search'], function (search) { search.init(); }); diff --git a/public/src/admin/advanced/logs.js b/public/src/admin/advanced/logs.js index 054e1af77d..478544b271 100644 --- a/public/src/admin/advanced/logs.js +++ b/public/src/admin/advanced/logs.js @@ -14,7 +14,7 @@ define('admin/advanced/logs', function () { var btnEl = $(this); var action = btnEl.attr('data-action'); - switch(action) { + switch (action) { case 'reload': socket.emit('admin.logs.get', function (err, logs) { if (!err) { diff --git a/public/src/admin/appearance/themes.js b/public/src/admin/appearance/themes.js index d8f96c1c65..434deb4cd2 100644 --- a/public/src/admin/appearance/themes.js +++ b/public/src/admin/appearance/themes.js @@ -64,7 +64,7 @@ define('admin/appearance/themes', ['translator'], function (translator) { }); socket.emit('admin.themes.getInstalled', function (err, themes) { - if(err) { + if (err) { return app.alertError(err.message); } diff --git a/public/src/admin/extend/widgets.js b/public/src/admin/extend/widgets.js index 0b9707a5a5..6923b0437d 100644 --- a/public/src/admin/extend/widgets.js +++ b/public/src/admin/extend/widgets.js @@ -93,13 +93,13 @@ define('admin/extend/widgets', ['jqueryui'], function (jqueryui) { if (data.hasOwnProperty(d)) { if (data[d].name) { if (widgetData[data[d].name]) { - if(!Array.isArray(widgetData[data[d].name])) { + if (!Array.isArray(widgetData[data[d].name])) { widgetData[data[d].name] = [ widgetData[data[d].name], ]; } widgetData[data[d].name].push(data[d].value); - }else{ + } else { widgetData[data[d].name] = data[d].value; } } @@ -209,7 +209,7 @@ define('admin/extend/widgets', ['jqueryui'], function (jqueryui) { $.get(RELATIVE_PATH + '/api/admin/extend/widgets', function (data) { var areas = data.areas; - for(var i = 0; i < areas.length; i += 1) { + for (var i = 0; i < areas.length; i += 1) { var area = areas[i]; var widgetArea = $('#widgets .area[data-template="' + area.template + '"][data-location="' + area.location + '"]').find('.widget-area'); diff --git a/public/src/admin/general/dashboard.js b/public/src/admin/general/dashboard.js index 1c10cc4df4..e01964b253 100644 --- a/public/src/admin/general/dashboard.js +++ b/public/src/admin/general/dashboard.js @@ -143,12 +143,12 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s var r = (num >> 16) + amt; if (r > 255) r = 255; - else if (r < 0) r = 0; + else if (r < 0) r = 0; var b = ((num >> 8) & 0x00FF) + amt; if (b > 255) b = 255; - else if (b < 0) b = 0; + else if (b < 0) b = 0; var g = (num & 0x0000FF) + amt; @@ -291,7 +291,7 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s $('[data-action="updateGraph"]').on('click', function () { var until; - switch($(this).attr('data-until')) { + switch ($(this).attr('data-until')) { case 'last-month': var lastMonth = new Date(); lastMonth.setDate(lastMonth.getDate() - 30); diff --git a/public/src/admin/general/homepage.js b/public/src/admin/general/homepage.js index 7116422048..00626680b8 100644 --- a/public/src/admin/general/homepage.js +++ b/public/src/admin/general/homepage.js @@ -6,7 +6,7 @@ define('admin/general/homepage', ['admin/settings'], function (Settings) { function toggleCustomRoute() { if ($('[data-field="homePageRoute"]').val()) { $('#homePageCustom').hide(); - }else{ + } else { $('#homePageCustom').show(); } } diff --git a/public/src/admin/manage/categories.js b/public/src/admin/manage/categories.js index c19a316060..0e443c14e1 100644 --- a/public/src/admin/manage/categories.js +++ b/public/src/admin/manage/categories.js @@ -8,7 +8,7 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri Categories.init = function () { socket.emit('admin.categories.getAll', function (error, payload) { - if(error) { + if (error) { return app.alertError(error.message); } @@ -128,14 +128,14 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri var isCategoryUpdate = (newCategoryId != -1); // Update needed? - if((e.newIndex != undefined && e.oldIndex != e.newIndex) || isCategoryUpdate) { + if ((e.newIndex != undefined && e.oldIndex != e.newIndex) || isCategoryUpdate) { var parentCategory = isCategoryUpdate ? sortables[newCategoryId] : sortables[e.from.dataset.cid]; var modified = {}; var i = 0; var list = parentCategory.toArray(); var len = list.length; - for(i; i < len; i += 1) { + for (i; i < len; i += 1) { modified[list[i]] = { order: (i + 1), }; @@ -187,7 +187,7 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri container.append(html); // Handle and children categories in this level have - for(var x = 0, numCategories = categories.length; x < numCategories; x += 1) { + for (var x = 0, numCategories = categories.length; x < numCategories; x += 1) { renderList(categories[x].children, $('li[data-cid="' + categories[x].cid + '"]'), categories[x].cid); } diff --git a/public/src/admin/manage/category.js b/public/src/admin/manage/category.js index bf6f140f41..d6e47a6807 100644 --- a/public/src/admin/manage/category.js +++ b/public/src/admin/manage/category.js @@ -29,7 +29,7 @@ define('admin/manage/category', [ function save(e) { e.preventDefault(); - if(Object.keys(modified_categories).length) { + if (Object.keys(modified_categories).length) { socket.emit('admin.categories.update', modified_categories, function (err, results) { if (err) { return app.alertError(err.message); @@ -295,7 +295,7 @@ define('admin/manage/category', [ privs.push(el.getAttribute('data-privilege')); } }); - for(var x = 0, numPrivs = privs.length; x < numPrivs; x += 1) { + 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'); inputs.each(function (idx, el) { if (!el.checked) { diff --git a/public/src/admin/manage/flags.js b/public/src/admin/manage/flags.js index 77a8bb8e0d..09b68ed560 100644 --- a/public/src/admin/manage/flags.js +++ b/public/src/admin/manage/flags.js @@ -147,7 +147,7 @@ define('admin/manage/flags', [ el = $(el); if (source[pid]) { - for(var prop in source[pid]) { + for (var prop in source[pid]) { if (source[pid].hasOwnProperty(prop)) { el.find('[name="' + prop + '"]').val(source[pid][prop]); } diff --git a/public/src/admin/manage/group.js b/public/src/admin/manage/group.js index 93b73ac527..703c126171 100644 --- a/public/src/admin/manage/group.js +++ b/public/src/admin/manage/group.js @@ -113,7 +113,7 @@ define('admin/manage/group', [ var uid = userRow.attr('data-uid'); var action = btnEl.attr('data-action'); - switch(action) { + switch (action) { case 'toggleOwnership': socket.emit('groups.' + (isOwner ? 'rescind' : 'grant'), { toUid: uid, diff --git a/public/src/admin/manage/groups.js b/public/src/admin/manage/groups.js index 718437eb50..9f86c6a74d 100644 --- a/public/src/admin/manage/groups.js +++ b/public/src/admin/manage/groups.js @@ -63,7 +63,7 @@ define('admin/manage/groups', ['translator'], function (translator) { socket.emit('groups.delete', { groupName: groupName, }, function (err, data) { - if(err) { + if (err) { return app.alertError(err.message); } diff --git a/public/src/admin/manage/users.js b/public/src/admin/manage/users.js index 34cd2476cd..e59cf28d5b 100644 --- a/public/src/admin/manage/users.js +++ b/public/src/admin/manage/users.js @@ -301,7 +301,7 @@ define('admin/manage/users', ['translator'], function (translator) { }; socket.emit('admin.user.createUser', user, function (err) { - if(err) { + if (err) { return errorEl.translateHtml('[[admin/manage/users:alerts.error-x, ' + err.message + ']]').removeClass('hide'); } @@ -322,7 +322,7 @@ define('admin/manage/users', ['translator'], function (translator) { } var $this = $(this); - var type = $this.attr('data-search-type'); + var type = $this.attr('data-search-type'); timeoutId = setTimeout(function () { $('.fa-spinner').removeClass('hidden'); diff --git a/public/src/admin/settings.js b/public/src/admin/settings.js index f38fac8bc5..041de4a40f 100644 --- a/public/src/admin/settings.js +++ b/public/src/admin/settings.js @@ -182,7 +182,7 @@ define('admin/settings', ['uploader'], function (uploader) { return callback(err); } - for(var field in data) { + for (var field in data) { if (data.hasOwnProperty(field)) { app.config[field] = data[field]; } diff --git a/public/src/app.js b/public/src/app.js index a1667eb0a7..792abfa76a 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -516,7 +516,7 @@ app.cacheBuster = null; $('[component="header/usercontrol"] [data-status]').off('click').on('click', function (e) { var status = $(this).attr('data-status'); socket.emit('user.setStatus', status, function (err) { - if(err) { + if (err) { return app.alertError(err.message); } $('[data-uid="' + app.user.uid + '"] [component="user/status"], [component="header/profilelink"] [component="user/status"]') diff --git a/public/src/client/categories.js b/public/src/client/categories.js index 57b77c3af3..40f93b0dc6 100644 --- a/public/src/client/categories.js +++ b/public/src/client/categories.js @@ -39,7 +39,7 @@ define('forum/categories', ['components', 'translator'], function (components, t parseAndTranslate([post], function (html) { html.hide(); - if(recentPosts.length === 0) { + if (recentPosts.length === 0) { html.appendTo(category); } else { html.insertBefore(recentPosts.first()); diff --git a/public/src/client/category.js b/public/src/client/category.js index aa46eb1405..21ebcda265 100644 --- a/public/src/client/category.js +++ b/public/src/client/category.js @@ -232,7 +232,7 @@ define('forum/category', [ topic.insertBefore(topics[x]); break; } - if(x === numTopics - 1) { + if (x === numTopics - 1) { topic.insertAfter(topics[x]); } } @@ -253,7 +253,7 @@ define('forum/category', [ function updateTopicCount() { socket.emit('categories.getTopicCount', ajaxify.data.cid, function (err, topicCount) { - if(err) { + if (err) { return app.alertError(err.message); } navigator.setCount(topicCount); diff --git a/public/src/client/category/tools.js b/public/src/client/category/tools.js index d376025b53..36955d25ff 100644 --- a/public/src/client/category/tools.js +++ b/public/src/client/category/tools.js @@ -180,8 +180,8 @@ define('forum/category/tools', [ } function isAny(method, tids) { - for(var i = 0; i < tids.length; i += 1) { - if(method(tids[i])) { + for (var i = 0; i < tids.length; i += 1) { + if (method(tids[i])) { return true; } } @@ -189,8 +189,8 @@ define('forum/category/tools', [ } function areAll(method, tids) { - for(var i = 0; i < tids.length; i += 1) { - if(!method(tids[i])) { + for (var i = 0; i < tids.length; i += 1) { + if (!method(tids[i])) { return false; } } diff --git a/public/src/client/chats.js b/public/src/client/chats.js index 82a4354c39..81b72f198b 100644 --- a/public/src/client/chats.js +++ b/public/src/client/chats.js @@ -98,7 +98,7 @@ define('forum/chats', [ return; } loading = true; - var start = parseInt($('.chat-content').children('[data-index]').first().attr('data-index'), 10) + 1; + var start = parseInt($('.chat-content').children('[data-index]').first().attr('data-index'), 10) + 1; socket.emit('modules.chats.getMessages', {roomId: roomId, uid: uid, start: start}, function (err, data) { if (err) { return app.alertError(err.message); diff --git a/public/src/client/groups/details.js b/public/src/client/groups/details.js index c4f8be092f..9e8191a20f 100644 --- a/public/src/client/groups/details.js +++ b/public/src/client/groups/details.js @@ -59,7 +59,7 @@ define('forum/groups/details', [ var uid = userRow.attr('data-uid'); var action = btnEl.attr('data-action'); - switch(action) { + switch (action) { case 'toggleOwnership': socket.emit('groups.' + (isOwner ? 'rescind' : 'grant'), { toUid: uid, diff --git a/public/src/client/reset.js b/public/src/client/reset.js index 84915b597c..ea8e1143f6 100644 --- a/public/src/client/reset.js +++ b/public/src/client/reset.js @@ -12,7 +12,7 @@ define('forum/reset', function () { $('#reset').on('click', function () { if (inputEl.val() && inputEl.val().indexOf('@') !== -1) { socket.emit('user.reset.send', inputEl.val(), function (err) { - if(err) { + if (err) { return app.alertError(err.message); } diff --git a/public/src/client/tag.js b/public/src/client/tag.js index 08774a0e36..2b74c17193 100644 --- a/public/src/client/tag.js +++ b/public/src/client/tag.js @@ -20,7 +20,7 @@ define('forum/tag', ['forum/recent', 'forum/infinitescroll'], function (recent, } function loadMoreTopics(direction) { - if(direction < 0 || !$('[component="category"]').length) { + if (direction < 0 || !$('[component="category"]').length) { return; } diff --git a/public/src/client/topic/events.js b/public/src/client/topic/events.js index 0f5b58c311..d88a0dee54 100644 --- a/public/src/client/topic/events.js +++ b/public/src/client/topic/events.js @@ -48,7 +48,7 @@ define('forum/topic/events', [ Events.init = function () { Events.removeListeners(); - for(var eventName in events) { + for (var eventName in events) { if (events.hasOwnProperty(eventName)) { socket.on(eventName, events[eventName]); } @@ -56,7 +56,7 @@ define('forum/topic/events', [ }; Events.removeListeners = function () { - for(var eventName in events) { + for (var eventName in events) { if (events.hasOwnProperty(eventName)) { socket.removeListener(eventName, events[eventName]); } diff --git a/public/src/client/unread.js b/public/src/client/unread.js index 73b392ab3e..18140185ef 100644 --- a/public/src/client/unread.js +++ b/public/src/client/unread.js @@ -23,11 +23,11 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', ' $('#markSelectedRead').on('click', function () { var tids = topicSelect.getSelectedTids(); - if(!tids.length) { + if (!tids.length) { return; } socket.emit('topics.markAsRead', tids, function (err) { - if(err) { + if (err) { return app.alertError(err.message); } @@ -37,7 +37,7 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', ' $('#markAllRead').on('click', function () { socket.emit('topics.markAllRead', function (err) { - if(err) { + if (err) { return app.alertError(err.message); } @@ -62,7 +62,7 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', ' var tids = getCategoryTids(cid); socket.emit('topics.markCategoryTopicsRead', cid, function (err) { - if(err) { + if (err) { return app.alertError(err.message); } @@ -85,7 +85,7 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', ' } function loadMoreTopics(direction) { - if(direction < 0 || !$('[component="category"]').length) { + if (direction < 0 || !$('[component="category"]').length) { return; } var params = utils.params(); @@ -118,7 +118,7 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', ' } function removeTids(tids) { - for(var i = 0; i < tids.length; i += 1) { + for (var i = 0; i < tids.length; i += 1) { components.get('category/topic', 'tid', tids[i]).remove(); } } diff --git a/public/src/client/users.js b/public/src/client/users.js index 5c6f23bc7b..0074af2e8f 100644 --- a/public/src/client/users.js +++ b/public/src/client/users.js @@ -65,7 +65,7 @@ define('forum/users', ['translator'], function (translator) { query.onlineOnly = true; } if (activeSection === 'banned') { - query.bannedOnly = true; + query.bannedOnly = true; } if (activeSection === 'flagged') { query.flaggedOnly = true; diff --git a/public/src/modules/alerts.js b/public/src/modules/alerts.js index 6c5595d889..3e55ce1ff1 100644 --- a/public/src/modules/alerts.js +++ b/public/src/modules/alerts.js @@ -30,7 +30,7 @@ define('alerts', ['translator', 'components'], function (translator, components) components.get('toaster/tray').prepend(alert); - if(typeof params.closefn === 'function') { + if (typeof params.closefn === 'function') { alert.find('button').on('click', function () { params.closefn(); fadeOut(alert); @@ -46,7 +46,7 @@ define('alerts', ['translator', 'components'], function (translator, components) alert .addClass('pointer') .on('click', function (e) { - if(!$(e.target).is('.close')) { + if (!$(e.target).is('.close')) { params.clickfn(); } fadeOut(alert); @@ -82,7 +82,7 @@ define('alerts', ['translator', 'components'], function (translator, components) alert .addClass('pointer') .on('click', function (e) { - if(!$(e.target).is('.close')) { + if (!$(e.target).is('.close')) { params.clickfn(); } fadeOut(alert); diff --git a/public/src/modules/helpers.js b/public/src/modules/helpers.js index fb56e904f6..6f2d92fea6 100644 --- a/public/src/modules/helpers.js +++ b/public/src/modules/helpers.js @@ -170,7 +170,7 @@ helpers.spawnPrivilegeStates = function (member, privileges) { var states = []; - for(var priv in privileges) { + for (var priv in privileges) { if (privileges.hasOwnProperty(priv)) { states.push({ name: priv, @@ -214,7 +214,7 @@ helpers.userAgentIcons = function (data) { var icons = ''; - switch(data.platform) { + switch (data.platform) { case 'Linux': icons += ''; break; @@ -239,7 +239,7 @@ break; } - switch(data.browser) { + switch (data.browser) { case 'Chrome': icons += ''; break; diff --git a/public/src/modules/notifications.js b/public/src/modules/notifications.js index e8a6e0a97b..4bd786bb19 100644 --- a/public/src/modules/notifications.js +++ b/public/src/modules/notifications.js @@ -125,7 +125,7 @@ define('notifications', ['sounds', 'translator', 'components'], function (sound, }); translator.toggleTimeagoShorthand(); - for(var i = 0; i < notifs.length; i += 1) { + for (var i = 0; i < notifs.length; i += 1) { notifs[i].timeago = $.timeago(new Date(parseInt(notifs[i].datetime, 10))); } translator.toggleTimeagoShorthand(); diff --git a/public/src/modules/pictureCropper.js b/public/src/modules/pictureCropper.js index e70676b021..c558775c51 100644 --- a/public/src/modules/pictureCropper.js +++ b/public/src/modules/pictureCropper.js @@ -114,8 +114,8 @@ define('pictureCropper', ['translator', 'cropper'], function (translator, croppe return showAlert('error', '[[uploads:select-file-to-upload]]'); } - var file = fileInput[0].files[0]; - var reader = new FileReader(); + var file = fileInput[0].files[0]; + var reader = new FileReader(); var imageUrl; var imageType = file.type; diff --git a/public/src/modules/postSelect.js b/public/src/modules/postSelect.js index 21629786a7..c9c7aba08d 100644 --- a/public/src/modules/postSelect.js +++ b/public/src/modules/postSelect.js @@ -24,7 +24,7 @@ define('postSelect', ['components'], function (components) { if (newPid) { var index = PostSelect.pids.indexOf(newPid); - if(index === -1) { + if (index === -1) { PostSelect.pids.push(newPid); post.toggleClass('bg-success', true); } else { diff --git a/public/src/modules/search.js b/public/src/modules/search.js index f17baab285..e4e64288b2 100644 --- a/public/src/modules/search.js +++ b/public/src/modules/search.js @@ -18,7 +18,7 @@ define('search', ['navigator', 'translator'], function (nav, translator) { try { term = encodeURIComponent(term); - } catch(e) { + } catch (e) { return app.alertError('[[error:invalid-search-term]]'); } @@ -81,7 +81,7 @@ define('search', ['navigator', 'translator'], function (nav, translator) { Search.getSearchPreferences = function () { try { return JSON.parse(localStorage.getItem('search-preferences') || '{}'); - } catch(e) { + } catch (e) { return {}; } }; diff --git a/public/src/modules/settings.js b/public/src/modules/settings.js index cb733b970a..510fa8e822 100644 --- a/public/src/modules/settings.js +++ b/public/src/modules/settings.js @@ -459,7 +459,7 @@ define('settings', function () { } // Parse all values. If they are json, return json - for(var key in values) { + for (var key in values) { if (values.hasOwnProperty(key)) { try { values[key] = JSON.parse(values[key]); diff --git a/public/src/modules/topicSelect.js b/public/src/modules/topicSelect.js index 90949a140e..46d3a9ffe7 100644 --- a/public/src/modules/topicSelect.js +++ b/public/src/modules/topicSelect.js @@ -52,7 +52,7 @@ define('topicSelect', ['components'], function (components) { function selectRange(clickedTid) { - if(!lastSelected) { + if (!lastSelected) { lastSelected = $('[component="category/topic"]').first().find('[component="topic/select"]'); } @@ -70,7 +70,7 @@ define('topicSelect', ['components'], function (components) { end = tmp; } - for(var i = start; i <= end; i += 1) { + for (var i = start; i <= end; i += 1) { var topic = $('[component="category/topic"]').eq(i); toggleSelect(topic.find('[component="topic/select"]'), isSelected); } diff --git a/public/src/overrides.js b/public/src/overrides.js index 9bc95d68c6..899b2d194d 100644 --- a/public/src/overrides.js +++ b/public/src/overrides.js @@ -10,9 +10,9 @@ if ('undefined' !== typeof window) { $.fn.getCursorPosition = function () { var el = $(this).get(0); var pos = 0; - if('selectionStart' in el) { + if ('selectionStart' in el) { pos = el.selectionStart; - } else if('selection' in document) { + } else if ('selection' in document) { el.focus(); var Sel = document.selection.createRange(); var SelLength = document.selection.createRange().text.length; @@ -23,7 +23,7 @@ if ('undefined' !== typeof window) { }; $.fn.selectRange = function (start, end) { - if(!end) { + if (!end) { end = start; } return this.each(function () { @@ -95,7 +95,7 @@ if ('undefined' !== typeof window) { return el.namespace === 'bs.data-api.dropdown' && el.selector === undefined; }); - if(_clearMenus.length) { + if (_clearMenus.length) { _clearMenus = _clearMenus[0].handler; } diff --git a/public/src/sockets.js b/public/src/sockets.js index 80463cce0a..bc33dc9bbf 100644 --- a/public/src/sockets.js +++ b/public/src/sockets.js @@ -71,7 +71,7 @@ app.isConnected = false; var url_parts = window.location.pathname.slice(config.relative_path.length).split('/').slice(1); var room; - switch(url_parts[0]) { + switch (url_parts[0]) { case 'user': room = 'user/' + (ajaxify.data ? ajaxify.data.theirid : 0); break; diff --git a/public/src/utils.js b/public/src/utils.js index c80d530b13..3a0ba8fb2d 100644 --- a/public/src/utils.js +++ b/public/src/utils.js @@ -91,7 +91,7 @@ return ''; } str = str.replace(utils.trimRegex, ''); - if(utils.isLatin.test(str)) { + if (utils.isLatin.test(str)) { str = str.replace(utils.invalidLatinChars, '-'); } else { str = XRegExp.replace(str, utils.invalidUnicodeChars, '-'); @@ -211,12 +211,12 @@ makeNumberHumanReadable: function (num) { var n = parseInt(num, 10); - if(!n) { + if (!n) { return num; } if (n > 999999) { return (n / 1000000).toFixed(1) + 'm'; - } else if(n > 999) { + } else if (n > 999) { return (n / 1000).toFixed(1) + 'k'; } return n; @@ -314,7 +314,7 @@ var labels = []; var tmpDate; - for(var x = 29; x >= 0; x -= 1) { + for (var x = 29; x >= 0; x -= 1) { tmpDate = new Date(currentDay - (1000 * 60 * 60 * 24 * x)); labels.push(months[tmpDate.getMonth()] + ' ' + tmpDate.getDate()); } @@ -417,15 +417,15 @@ // get example: utils.props(A, 'a.b.c.foo.bar') // returns undefined without throwing a TypeError // credits to github.com/gkindel props: function (obj, props, value) { - if(obj === undefined) { + if (obj === undefined) { obj = window; } - if(props == null) { + if (props == null) { return undefined; } var i = props.indexOf('.'); - if(i == -1) { - if(value !== undefined) { + if (i == -1) { + if (value !== undefined) { obj[props] = value; } return obj[props]; @@ -433,7 +433,7 @@ var prop = props.slice(0, i); var newProps = props.slice(i + 1); - if(props !== undefined && !(obj[prop] instanceof Object)) { + if (props !== undefined && !(obj[prop] instanceof Object)) { obj[prop] = {}; } diff --git a/src/analytics.js b/src/analytics.js index 30708d5a22..d0c4dd5b25 100644 --- a/src/analytics.js +++ b/src/analytics.js @@ -86,7 +86,7 @@ Analytics.writeData = function (callback) { } if (Object.keys(counters).length > 0) { - for(var key in counters) { + for (var key in counters) { if (counters.hasOwnProperty(key)) { dbQueue.push(async.apply(db.sortedSetIncrBy, 'analytics:' + key, counters[key], today.getTime())); delete counters[key]; diff --git a/src/controllers/admin/groups.js b/src/controllers/admin/groups.js index ce2fdaba97..dbd0787818 100644 --- a/src/controllers/admin/groups.js +++ b/src/controllers/admin/groups.js @@ -28,7 +28,7 @@ groupsController.list = function (req, res, next) { pageCount = Math.ceil(groupNames.length / groupsPerPage); var start = (page - 1) * groupsPerPage; - var stop = start + groupsPerPage - 1; + var stop = start + groupsPerPage - 1; groupNames = groupNames.slice(start, stop + 1); groups.getGroupsData(groupNames, next); diff --git a/src/controllers/admin/info.js b/src/controllers/admin/info.js index 89160fb21f..3517472eba 100644 --- a/src/controllers/admin/info.js +++ b/src/controllers/admin/info.js @@ -79,7 +79,7 @@ function getNodeInfo(callback) { } function getGitInfo(callback) { - function get(cmd, callback) { + function get(cmd, callback) { exec(cmd, function (err, stdout) { if (err) { winston.error(err); diff --git a/src/controllers/admin/uploads.js b/src/controllers/admin/uploads.js index 3ed6f9b6f4..bce0d982d6 100644 --- a/src/controllers/admin/uploads.js +++ b/src/controllers/admin/uploads.js @@ -29,7 +29,7 @@ uploadsController.uploadCategoryPicture = function (req, res, next) { } if (validateUpload(req, res, next, uploadedFile, allowedImageTypes)) { - var filename = 'category-' + params.cid + path.extname(uploadedFile.name); + var filename = 'category-' + params.cid + path.extname(uploadedFile.name); uploadImage(filename, 'category', uploadedFile, req, res, next); } }; diff --git a/src/controllers/tags.js b/src/controllers/tags.js index 1be03d603e..3e364b38d1 100644 --- a/src/controllers/tags.js +++ b/src/controllers/tags.js @@ -8,7 +8,7 @@ var validator = require('validator'); var user = require('../user'); var topics = require('../topics'); var pagination = require('../pagination'); -var helpers = require('./helpers'); +var helpers = require('./helpers'); var tagsController = {}; diff --git a/src/controllers/topics.js b/src/controllers/topics.js index 12082fa32e..967747dba4 100644 --- a/src/controllers/topics.js +++ b/src/controllers/topics.js @@ -149,7 +149,7 @@ topicsController.get = function (req, res, callback) { }, function (topicData, next) { function findPost(index) { - for(var i = 0; i < topicData.posts.length; i += 1) { + for (var i = 0; i < topicData.posts.length; i += 1) { if (parseInt(topicData.posts[i].index, 10) === parseInt(index, 10)) { return topicData.posts[i]; } diff --git a/src/database/mongo/hash.js b/src/database/mongo/hash.js index c59d53c513..a82fb294b2 100644 --- a/src/database/mongo/hash.js +++ b/src/database/mongo/hash.js @@ -78,7 +78,7 @@ module.exports = function (db, module) { _id: 0, }; - for(var i = 0; i < fields.length; i += 1) { + for (var i = 0; i < fields.length; i += 1) { fields[i] = helpers.fieldToString(fields[i]); _fields[fields[i]] = 1; } @@ -88,7 +88,7 @@ module.exports = function (db, module) { } item = item || {}; var result = {}; - for(i = 0; i < fields.length; i += 1) { + for (i = 0; i < fields.length; i += 1) { result[fields[i]] = item[fields[i]] !== undefined ? item[fields[i]] : null; } callback(null, result); @@ -104,7 +104,7 @@ module.exports = function (db, module) { _key: 1, }; - for(var i = 0; i < fields.length; i += 1) { + for (var i = 0; i < fields.length; i += 1) { fields[i] = helpers.fieldToString(fields[i]); _fields[fields[i]] = 1; } @@ -145,12 +145,12 @@ module.exports = function (db, module) { module.getObjectValues = function (key, callback) { module.getObject(key, function (err, data) { - if(err) { + if (err) { return callback(err); } var values = []; - for(var key in data) { + for (var key in data) { if (data && data.hasOwnProperty(key)) { values.push(data[key]); } diff --git a/src/database/mongo/helpers.js b/src/database/mongo/helpers.js index 75ca83edbd..beda1b506b 100644 --- a/src/database/mongo/helpers.js +++ b/src/database/mongo/helpers.js @@ -12,11 +12,11 @@ helpers.toMap = function (data) { }; helpers.fieldToString = function (field) { - if(field === null || field === undefined) { + if (field === null || field === undefined) { return field; } - if(typeof field !== 'string') { + if (typeof field !== 'string') { field = field.toString(); } // if there is a '.' in the field name it inserts subdocument in mongo, replace '.'s with \uff0E @@ -25,7 +25,7 @@ helpers.fieldToString = function (field) { }; helpers.valueToString = function (value) { - if(value === null || value === undefined) { + if (value === null || value === undefined) { return value; } diff --git a/src/database/mongo/list.js b/src/database/mongo/list.js index 250d1951ca..02871e78fd 100644 --- a/src/database/mongo/list.js +++ b/src/database/mongo/list.js @@ -55,7 +55,7 @@ module.exports = function (db, module) { }; module.listRemoveAll = function (key, value, callback) { - callback = callback || helpers.noop; + callback = callback || helpers.noop; if (!key) { return callback(); } @@ -88,7 +88,7 @@ module.exports = function (db, module) { } db.collection('objects').findOne({_key: key}, { array: 1}, function (err, data) { - if(err || !(data && data.array)) { + if (err || !(data && data.array)) { return callback(err, []); } diff --git a/src/database/mongo/sets.js b/src/database/mongo/sets.js index b10682e8d5..f3df45647a 100644 --- a/src/database/mongo/sets.js +++ b/src/database/mongo/sets.js @@ -5,7 +5,7 @@ module.exports = function (db, module) { module.setAdd = function (key, value, callback) { callback = callback || helpers.noop; - if(!Array.isArray(value)) { + if (!Array.isArray(value)) { value = [value]; } @@ -36,7 +36,7 @@ module.exports = function (db, module) { return callback(); } - if(!Array.isArray(value)) { + if (!Array.isArray(value)) { value = [value]; } @@ -46,7 +46,7 @@ module.exports = function (db, module) { var bulk = db.collection('objects').initializeUnorderedBulkOp(); - for(var i = 0; i < keys.length; i += 1) { + for (var i = 0; i < keys.length; i += 1) { bulk.find({_key: keys[i]}).upsert().updateOne({ $addToSet: { members: { $each: value, @@ -61,7 +61,7 @@ module.exports = function (db, module) { module.setRemove = function (key, value, callback) { callback = callback || helpers.noop; - if(!Array.isArray(value)) { + if (!Array.isArray(value)) { value = [value]; } @@ -83,7 +83,7 @@ module.exports = function (db, module) { var bulk = db.collection('objects').initializeUnorderedBulkOp(); - for(var i = 0; i < keys.length; i += 1) { + for (var i = 0; i < keys.length; i += 1) { bulk.find({_key: keys[i]}).updateOne({$pull: { members: value, }}); @@ -174,7 +174,7 @@ module.exports = function (db, module) { }); var returnData = new Array(keys.length); - for(var i = 0; i < keys.length; i += 1) { + for (var i = 0; i < keys.length; i += 1) { returnData[i] = sets[keys[i]] || []; } callback(null, returnData); @@ -206,7 +206,7 @@ module.exports = function (db, module) { module.setRemoveRandom = function (key, callback) { callback = callback || function () {}; db.collection('objects').findOne({_key: key}, function (err, data) { - if(err || !data) { + if (err || !data) { return callback(err); } diff --git a/src/database/mongo/sorted.js b/src/database/mongo/sorted.js index fb7815be68..b8522a323f 100644 --- a/src/database/mongo/sorted.js +++ b/src/database/mongo/sorted.js @@ -198,7 +198,7 @@ module.exports = function (db, module) { } value = helpers.valueToString(value); method(key, 0, -1, function (err, result) { - if(err) { + if (err) { return callback(err); } @@ -263,7 +263,7 @@ module.exports = function (db, module) { var returnData = []; var item; - for(var i = 0; i < keys.length; i += 1) { + for (var i = 0; i < keys.length; i += 1) { item = map[keys[i]]; returnData.push(item ? item.score : null); } @@ -290,7 +290,7 @@ module.exports = function (db, module) { var returnData = new Array(values.length); var score; - for(var i = 0; i < values.length; i += 1) { + for (var i = 0; i < values.length; i += 1) { score = map[values[i]]; returnData[i] = utils.isNumber(score) ? score : null; } @@ -367,7 +367,7 @@ module.exports = function (db, module) { }); var returnData = new Array(keys.length); - for(var i = 0; i < keys.length; i += 1) { + for (var i = 0; i < keys.length; i += 1) { returnData[i] = sets[keys[i]] || []; } callback(null, returnData); diff --git a/src/database/mongo/sorted/add.js b/src/database/mongo/sorted/add.js index 9172003a09..1342586478 100644 --- a/src/database/mongo/sorted/add.js +++ b/src/database/mongo/sorted/add.js @@ -35,7 +35,7 @@ module.exports = function (db, module) { var bulk = db.collection('objects').initializeUnorderedBulkOp(); - for(var i = 0; i < scores.length; i += 1) { + for (var i = 0; i < scores.length; i += 1) { 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(); - for(var i = 0; i < keys.length; i += 1) { + for (var i = 0; i < keys.length; i += 1) { bulk.find({_key: keys[i], value: value}).upsert().updateOne({$set: {score: parseFloat(score)}}); } diff --git a/src/database/mongo/sorted/intersect.js b/src/database/mongo/sorted/intersect.js index 4a58b6d72e..989ccefd71 100644 --- a/src/database/mongo/sorted/intersect.js +++ b/src/database/mongo/sorted/intersect.js @@ -11,7 +11,7 @@ module.exports = function (db, module) { { $match: { _key: {$in: keys}} }, { $group: { _id: {value: '$value'}, count: {$sum: 1}} }, { $match: { count: keys.length} }, - { $group: { _id: null, count: { $sum: 1 } } }, + { $group: { _id: null, count: { $sum: 1 } } }, ]; db.collection('objects').aggregate(pipeline, function (err, data) { diff --git a/src/database/mongo/sorted/union.js b/src/database/mongo/sorted/union.js index 74eb452fe0..e150bb6831 100644 --- a/src/database/mongo/sorted/union.js +++ b/src/database/mongo/sorted/union.js @@ -10,7 +10,7 @@ module.exports = function (db, module) { var pipeline = [ { $match: { _key: {$in: keys} } }, { $group: { _id: {value: '$value' } } }, - { $group: { _id: null, count: { $sum: 1 } } }, + { $group: { _id: null, count: { $sum: 1 } } }, ]; var project = { _id: 0, count: '$count' }; diff --git a/src/database/redis/hash.js b/src/database/redis/hash.js index 1f0b30a03e..cdc364e47e 100644 --- a/src/database/redis/hash.js +++ b/src/database/redis/hash.js @@ -52,7 +52,7 @@ module.exports = function (redisClient, module) { } var multi = redisClient.multi(); - for(var x = 0; x < keys.length; x += 1) { + for (var x = 0; x < keys.length; x += 1) { multi.hmget.apply(multi, [keys[x]].concat(fields)); } diff --git a/src/database/redis/main.js b/src/database/redis/main.js index 2bc31a38e5..431b234b47 100644 --- a/src/database/redis/main.js +++ b/src/database/redis/main.js @@ -30,7 +30,7 @@ module.exports = function (redisClient, module) { module.deleteAll = function (keys, callback) { callback = callback || function () {}; var multi = redisClient.multi(); - for(var i = 0; i < keys.length; i += 1) { + for (var i = 0; i < keys.length; i += 1) { multi.del(keys[i]); } multi.exec(function (err, res) { diff --git a/src/database/redis/sorted.js b/src/database/redis/sorted.js index 26d6f45b34..8276476571 100644 --- a/src/database/redis/sorted.js +++ b/src/database/redis/sorted.js @@ -45,7 +45,7 @@ module.exports = function (redisClient, module) { return callback(null, data); } var objects = []; - for(var i = 0; i < data.length; i += 2) { + for (var i = 0; i < data.length; i += 2) { objects.push({value: data[i], score: parseFloat(data[i + 1])}); } callback(null, objects); @@ -74,7 +74,7 @@ module.exports = function (redisClient, module) { return callback(err); } var objects = []; - for(var i = 0; i < data.length; i += 2) { + for (var i = 0; i < data.length; i += 2) { objects.push({value: data[i], score: parseFloat(data[i + 1])}); } callback(null, objects); @@ -94,7 +94,7 @@ module.exports = function (redisClient, module) { return callback(null, []); } var multi = redisClient.multi(); - for(var i = 0; i < keys.length; i += 1) { + for (var i = 0; i < keys.length; i += 1) { multi.zcard(keys[i]); } multi.exec(callback); @@ -106,7 +106,7 @@ module.exports = function (redisClient, module) { module.sortedSetsRanks = function (keys, values, callback) { var multi = redisClient.multi(); - for(var i = 0; i < values.length; i += 1) { + for (var i = 0; i < values.length; i += 1) { multi.zrank(keys[i], values[i]); } multi.exec(callback); @@ -114,7 +114,7 @@ module.exports = function (redisClient, module) { module.sortedSetRanks = function (key, values, callback) { var multi = redisClient.multi(); - for(var i = 0; i < values.length; i += 1) { + for (var i = 0; i < values.length; i += 1) { multi.zrank(key, values[i]); } multi.exec(callback); diff --git a/src/database/redis/sorted/add.js b/src/database/redis/sorted/add.js index 024d71c7c7..fcccffa213 100644 --- a/src/database/redis/sorted/add.js +++ b/src/database/redis/sorted/add.js @@ -23,7 +23,7 @@ module.exports = function (redisClient, module) { var args = [key]; - for(var i = 0; i < scores.length; i += 1) { + for (var i = 0; i < scores.length; i += 1) { args.push(scores[i], values[i]); } @@ -36,7 +36,7 @@ module.exports = function (redisClient, module) { callback = callback || function () {}; var multi = redisClient.multi(); - for(var i = 0; i < keys.length; i += 1) { + for (var i = 0; i < keys.length; i += 1) { multi.zadd(keys[i], score, value); } diff --git a/src/database/redis/sorted/intersect.js b/src/database/redis/sorted/intersect.js index a4e3c131b4..a42556cd7e 100644 --- a/src/database/redis/sorted/intersect.js +++ b/src/database/redis/sorted/intersect.js @@ -70,7 +70,7 @@ module.exports = function (redisClient, module) { } results = results[1] || []; var objects = []; - for(var i = 0; i < results.length; i += 2) { + for (var i = 0; i < results.length; i += 2) { objects.push({value: results[i], score: parseFloat(results[i + 1])}); } callback(null, objects); diff --git a/src/database/redis/sorted/remove.js b/src/database/redis/sorted/remove.js index 51e889cecb..8619e0be34 100644 --- a/src/database/redis/sorted/remove.js +++ b/src/database/redis/sorted/remove.js @@ -28,7 +28,7 @@ module.exports = function (redisClient, module) { module.sortedSetsRemoveRangeByScore = function (keys, min, max, callback) { callback = callback || function () {}; var multi = redisClient.multi(); - for(var i = 0; i < keys.length; i += 1) { + for (var i = 0; i < keys.length; i += 1) { multi.zremrangebyscore(keys[i], min, max); } multi.exec(function (err) { diff --git a/src/database/redis/sorted/union.js b/src/database/redis/sorted/union.js index 677b086259..ab8584858c 100644 --- a/src/database/redis/sorted/union.js +++ b/src/database/redis/sorted/union.js @@ -51,7 +51,7 @@ module.exports = function (redisClient, module) { } results = results[1] || []; var objects = []; - for(var i = 0; i < results.length; i += 2) { + for (var i = 0; i < results.length; i += 2) { objects.push({value: results[i], score: parseFloat(results[i + 1])}); } callback(null, objects); diff --git a/src/events.js b/src/events.js index 832daf7170..79ee5a0b8d 100644 --- a/src/events.js +++ b/src/events.js @@ -4,7 +4,7 @@ var async = require('async'); var validator = require('validator'); -var db = require('./database'); +var db = require('./database'); var batch = require('./batch'); var user = require('./user'); var utils = require('../public/src/utils'); diff --git a/src/file.js b/src/file.js index b9ecee378e..b056e64ac5 100644 --- a/src/file.js +++ b/src/file.js @@ -100,7 +100,7 @@ file.existsSync = function (path) { var exists = false; try { exists = fs.statSync(path); - } catch(err) { + } catch (err) { exists = false; } diff --git a/src/groups/search.js b/src/groups/search.js index 0b7f672d0c..865d0619ca 100644 --- a/src/groups/search.js +++ b/src/groups/search.js @@ -38,7 +38,7 @@ module.exports = function (Groups) { }; Groups.sort = function (strategy, groups, next) { - switch(strategy) { + switch (strategy) { case 'count': groups = groups.sort(function (a, b) { return a.slug > b.slug; @@ -77,7 +77,7 @@ module.exports = function (Groups) { }, function (users, next) { var uids = []; - for(var i = 0; i < users.length; i += 1) { + for (var i = 0; i < users.length; i += 1) { var field = users[i][searchBy]; if (field.toLowerCase().startsWith(query)) { uids.push(users[i].uid); diff --git a/src/groups/update.js b/src/groups/update.js index 49d722692b..c5fe6f5749 100644 --- a/src/groups/update.js +++ b/src/groups/update.js @@ -131,7 +131,7 @@ module.exports = function (Groups) { }, function (currentValue, next) { var currentlyPrivate = parseInt(currentValue.private, 10) === 1; - if (!currentlyPrivate || currentlyPrivate === isPrivate) { + if (!currentlyPrivate || currentlyPrivate === isPrivate) { return callback(); } db.getSetMembers('group:' + groupName + ':pending', next); diff --git a/src/hotswap.js b/src/hotswap.js index b25d854201..6ef0f943eb 100644 --- a/src/hotswap.js +++ b/src/hotswap.js @@ -10,7 +10,7 @@ HotSwap.prepare = function (app) { HotSwap.find = function (id) { if (stack) { - for(var x = 0, numEntries = stack.length; x < numEntries; x += 1) { + for (var x = 0, numEntries = stack.length; x < numEntries; x += 1) { if (stack[x].handle.hotswapId === id) { return x; } diff --git a/src/install.js b/src/install.js index 4935261c5a..5d93d04764 100644 --- a/src/install.js +++ b/src/install.js @@ -153,7 +153,7 @@ function completeConfigSetup(config, next) { // Add CI object if (install.ciVals) { config.test_database = {}; - for(var prop in install.ciVals) { + for (var prop in install.ciVals) { if (install.ciVals.hasOwnProperty(prop)) { config.test_database[prop] = install.ciVals[prop]; } diff --git a/src/logger.js b/src/logger.js index ef908c5883..f90744afad 100644 --- a/src/logger.js +++ b/src/logger.js @@ -59,9 +59,9 @@ var opts = { * If logging is currently enabled, create a stream. * Otherwise, close the current stream */ - if(meta.config.loggerStatus > 0 || meta.config.loggerIOStatus) { + if (meta.config.loggerStatus > 0 || meta.config.loggerIOStatus) { var stream = Logger.open(value); - if(stream) { + if (stream) { opts.streams.log.f = stream; } else { opts.streams.log.f = process.stdout; @@ -74,11 +74,11 @@ var opts = { Logger.open = function (value) { /* Open the streams to log to: either a path or stdout */ var stream; - if(value) { - if(file.existsSync(value)) { + if (value) { + if (file.existsSync(value)) { var stats = fs.statSync(value); - if(stats) { - if(stats.isDirectory()) { + if (stats) { + if (stats.isDirectory()) { stream = fs.createWriteStream(path.join(value, 'nodebb.log'), {flags: 'a'}); } else { stream = fs.createWriteStream(value, {flags: 'a'}); @@ -89,7 +89,7 @@ var opts = { } - if(stream) { + if (stream) { stream.on('error', function (err) { winston.error(err.message); }); @@ -101,7 +101,7 @@ var opts = { }; Logger.close = function (stream) { - if(stream.f !== process.stdout && stream.f) { + if (stream.f !== process.stdout && stream.f) { stream.end(); } stream.f = null; @@ -117,7 +117,7 @@ var opts = { }; Logger.express_open = function () { - if(opts.express.set !== 1) { + if (opts.express.set !== 1) { opts.express.set = 1; opts.express.app.use(Logger.expressLogger); } @@ -133,7 +133,7 @@ var opts = { * * This hijack allows us to turn logger on/off dynamically within express */ - if(meta.config.loggerStatus > 0) { + if (meta.config.loggerStatus > 0) { return opts.express.ofn(req, res, next); } else { return next(); @@ -148,7 +148,7 @@ var opts = { */ try { return 'io: ' + _uid + ' ' + _type + ' ' + util.inspect(Array.prototype.slice.call(_args)) + '\n'; - } catch(err) { + } catch (err) { winston.info("Logger.prepare_io_string: Failed", err); return "error"; } @@ -165,11 +165,11 @@ var opts = { for (var sid in clients) { if (clients.hasOwnProperty(sid)) { var client = clients[sid]; - if(client.oEmit && client.oEmit !== client.emit) { + if (client.oEmit && client.oEmit !== client.emit) { client.emit = client.oEmit; } - if(client.$oEmit && client.$oEmit !== client.$emit) { + if (client.$oEmit && client.$oEmit !== client.$emit) { client.$emit = client.$oEmit; } } @@ -186,7 +186,7 @@ var opts = { } var clients = socket.io.sockets.sockets; - for(var sid in clients) { + for (var sid in clients) { if (clients.hasOwnProperty(sid)) { Logger.io_one(clients[sid], clients[sid].uid); } @@ -199,13 +199,13 @@ var opts = { */ function override(method, name, errorMsg) { return function () { - if(opts.streams.log.f) { + if (opts.streams.log.f) { opts.streams.log.f.write(Logger.prepare_io_string(name, uid, arguments)); } try { method.apply(socket, arguments); - } catch(err) { + } catch (err) { winston.info(errorMsg, err); } }; diff --git a/src/meta/build.js b/src/meta/build.js index 56aa624ffb..cf07b15c9d 100644 --- a/src/meta/build.js +++ b/src/meta/build.js @@ -83,7 +83,7 @@ exports.buildTargets = function (targets, callback) { function (next) { async.eachSeries(targets, function (target, next) { var startTime; - switch(target) { + switch (target) { case 'js': setImmediate(next); break; diff --git a/src/meta/dependencies.js b/src/meta/dependencies.js index 9c68cc7727..fff0308e83 100644 --- a/src/meta/dependencies.js +++ b/src/meta/dependencies.js @@ -31,7 +31,7 @@ module.exports = function (Meta) { try { pkgData = JSON.parse(pkgData); - } catch(e) { + } catch (e) { process.stdout.write('[' + 'missing'.red + '] ' + module.bold + ' is a required dependency but could not be found\n'); depsMissing = true; return next(true); diff --git a/src/meta/js.js b/src/meta/js.js index 722d6bdba0..ba00c8fc18 100644 --- a/src/meta/js.js +++ b/src/meta/js.js @@ -150,7 +150,7 @@ module.exports = function (Meta) { }); minifier.on('message', function (message) { - switch(message.type) { + switch (message.type) { case 'end': Meta.js.target[target].cache = message.minified; Meta.js.target[target].map = message.sourceMap; @@ -226,7 +226,7 @@ module.exports = function (Meta) { * Check if the parent process is running with the debug option --debug (or --debug-brk) */ var forkProcessParams = {}; - if(global.v8debug || parseInt(process.execArgv.indexOf('--debug'), 10) !== -1) { + if (global.v8debug || parseInt(process.execArgv.indexOf('--debug'), 10) !== -1) { /** * use the line below if you want to debug minifier.js script too (or even --debug-brk option, but * you'll have to setup your debugger and connect to the forked process) diff --git a/src/meta/templates.js b/src/meta/templates.js index c30db7f3b7..44740fc787 100644 --- a/src/meta/templates.js +++ b/src/meta/templates.js @@ -120,7 +120,7 @@ function compile(callback) { var matches = null; var regex = /[ \t]*[ \t]*/; - while((matches = file.match(regex)) !== null) { + while ((matches = file.match(regex)) !== null) { var partial = "/" + matches[1]; if (paths[partial] && relativePath !== partial) { diff --git a/src/meta/themes.js b/src/meta/themes.js index 9dfc9f376b..e5359232fb 100644 --- a/src/meta/themes.js +++ b/src/meta/themes.js @@ -78,7 +78,7 @@ module.exports = function (Meta) { 'theme:src': '', }; - switch(data.type) { + switch (data.type) { case 'local': async.waterfall([ async.apply(Meta.configs.get, 'theme:id'), diff --git a/src/middleware/index.js b/src/middleware/index.js index fd1c816a80..21208cf9a6 100644 --- a/src/middleware/index.js +++ b/src/middleware/index.js @@ -190,7 +190,7 @@ middleware.processTimeagoLocales = function (req, res, next) { try { exists = fs.accessSync(localPath, fs.F_OK | fs.R_OK); - } catch(e) { + } catch (e) { exists = false; } diff --git a/src/middleware/user.js b/src/middleware/user.js index cdfbe1e548..4c02702802 100644 --- a/src/middleware/user.js +++ b/src/middleware/user.js @@ -1,7 +1,7 @@ 'use strict'; var async = require('async'); -var nconf = require('nconf'); +var nconf = require('nconf'); var meta = require('../meta'); var user = require('../user'); diff --git a/src/notifications.js b/src/notifications.js index 74453e5046..6f20999229 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -460,7 +460,7 @@ var utils = require('../public/src/utils'); return notifications; } - switch(mergeId) { + switch (mergeId) { // intentional fall-through case 'notifications:upvoted_your_post_in': case 'notifications:user_started_following_you': diff --git a/src/pagination.js b/src/pagination.js index 4e0d5d012b..7480756d1d 100644 --- a/src/pagination.js +++ b/src/pagination.js @@ -26,7 +26,7 @@ pagination.create = function (currentPage, pageCount, queryObj) { if (startPage > pageCount - 5) { startPage -= 2 - (pageCount - currentPage); } - for(var i = 0; i < 5; i += 1) { + for (var i = 0; i < 5; i += 1) { pagesToShow.push(startPage + i); } diff --git a/src/password.js b/src/password.js index 2744cbefba..54547abef3 100644 --- a/src/password.js +++ b/src/password.js @@ -13,7 +13,7 @@ function forkChild(message, callback) { var forkProcessParams = {}; - if(global.v8debug || parseInt(process.execArgv.indexOf('--debug'), 10) !== -1) { + if (global.v8debug || parseInt(process.execArgv.indexOf('--debug'), 10) !== -1) { forkProcessParams = {execArgv: ['--debug=' + (5859), '--nolazy']}; } var child = fork('./bcrypt', [], forkProcessParams); diff --git a/src/plugins.js b/src/plugins.js index f6b27f8ec7..3ef50f2c57 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -107,7 +107,7 @@ var middleware; if (Plugins.versionWarning.length && nconf.get('isPrimary') === 'true') { 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.'); - for(var x = 0, numPlugins = Plugins.versionWarning.length; x < numPlugins; x += 1) { + for (var x = 0, numPlugins = Plugins.versionWarning.length; x < numPlugins; x += 1) { process.stdout.write(' * '.yellow + Plugins.versionWarning[x] + '\n'); } process.stdout.write('\n'); @@ -252,7 +252,7 @@ var middleware; var pluginMap = {}; var dependencies = require(path.join(nconf.get('base_dir'), 'package.json')).dependencies; apiReturn = apiReturn || []; - for(var i = 0; i < apiReturn.length; i += 1) { + for (var i = 0; i < apiReturn.length; i += 1) { apiReturn[i].id = apiReturn[i].name; apiReturn[i].installed = false; apiReturn[i].active = false; diff --git a/src/plugins/hooks.js b/src/plugins/hooks.js index 979cf90994..dc2093bf95 100644 --- a/src/plugins/hooks.js +++ b/src/plugins/hooks.js @@ -160,7 +160,7 @@ module.exports = function (Plugins) { next.apply(null, arguments); } }); - } catch(err) { + } catch (err) { winston.error('[plugins] Error executing \'' + hook + '\' in plugin \'' + hookObj.id + '\''); winston.error(err); clearTimeout(timeoutId); diff --git a/src/plugins/load.js b/src/plugins/load.js index 4147260d9a..56f3ff563f 100644 --- a/src/plugins/load.js +++ b/src/plugins/load.js @@ -140,7 +140,7 @@ module.exports = function (Plugins) { } else { callback(); } - } catch(err) { + } catch (err) { winston.error(err.stack); winston.warn('[plugins] Unable to parse library for: ' + pluginData.id); callback(); @@ -301,7 +301,7 @@ module.exports = function (Plugins) { pluginData.repository = packageData.repository; pluginData.nbbpm = packageData.nbbpm; pluginData.path = pluginPath; - } catch(err) { + } catch (err) { var pluginDir = pluginPath.split(path.sep); pluginDir = pluginDir[pluginDir.length - 1]; diff --git a/src/posts/flags.js b/src/posts/flags.js index a1d40a6729..744f64227f 100644 --- a/src/posts/flags.js +++ b/src/posts/flags.js @@ -240,14 +240,14 @@ module.exports = function (Posts) { function (posts, next) { // Parse out flag data into its own object inside each post hash async.map(posts, function (postObj, next) { - for(var prop in postObj) { + for (var prop in postObj) { postObj.flagData = postObj.flagData || {}; if (postObj.hasOwnProperty(prop) && prop.startsWith('flag:')) { postObj.flagData[prop.slice(5)] = postObj[prop]; if (prop === 'flag:state') { - switch(postObj[prop]) { + switch (postObj[prop]) { case 'open': postObj.flagData.labelClass = 'info'; break; @@ -296,14 +296,14 @@ module.exports = function (Posts) { } // Track new additions - for(prop in flagObj) { + for (prop in flagObj) { if (flagObj.hasOwnProperty(prop) && !postData.hasOwnProperty('flag:' + prop) && flagObj[prop].length) { changes.push(prop); } } // Track changed items - for(prop in postData) { + for (prop in postData) { if ( postData.hasOwnProperty(prop) && prop.startsWith('flag:') && flagObj.hasOwnProperty(prop.slice(5)) && @@ -324,7 +324,7 @@ module.exports = function (Posts) { var history = JSON.parse(postData['flag:history'] || '[]'); changes.forEach(function (property) { - switch(property) { + switch (property) { case 'assignee': // intentional fall-through case 'state': history.unshift({ diff --git a/src/posts/parse.js b/src/posts/parse.js index 7497dc6781..f78a5debf1 100644 --- a/src/posts/parse.js +++ b/src/posts/parse.js @@ -68,7 +68,7 @@ module.exports = function (Posts) { content = content.slice(0, current.index + 6) + absolute + content.slice(current.index + 6 + current[1].length); } - } catch(err) { + } catch (err) { winston.verbose(err.messsage); } } diff --git a/src/posts/summary.js b/src/posts/summary.js index 74b53a05a2..79d091012e 100644 --- a/src/posts/summary.js +++ b/src/posts/summary.js @@ -136,7 +136,7 @@ module.exports = function (Posts) { function toObject(key, data) { var obj = {}; - for(var i = 0; i < data.length; i += 1) { + for (var i = 0; i < data.length; i += 1) { obj[data[i][key]] = data[i]; } return obj; diff --git a/src/posts/tools.js b/src/posts/tools.js index ab47632931..a93a19ef3c 100644 --- a/src/posts/tools.js +++ b/src/posts/tools.js @@ -30,7 +30,7 @@ module.exports = function (Posts) { function (deleted, next) { if (parseInt(deleted, 10) === 1 && isDelete) { return next(new Error('[[error:post-already-deleted]]')); - } else if(parseInt(deleted, 10) !== 1 && !isDelete) { + } else if (parseInt(deleted, 10) !== 1 && !isDelete) { return next(new Error('[[error:post-already-restored]]')); } diff --git a/src/privileges/categories.js b/src/privileges/categories.js index 3b3649ddf9..ff3e2ed3ec 100644 --- a/src/privileges/categories.js +++ b/src/privileges/categories.js @@ -66,7 +66,7 @@ module.exports = function (privileges) { memberData.forEach(function (member) { member.privileges = {}; - for(var x = 0, numPrivs = userPrivileges.length; x < numPrivs; x += 1) { + for (var x = 0, numPrivs = userPrivileges.length; x < numPrivs; x += 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) { memberPrivs = {}; - for(var x = 0, numPrivs = groupPrivileges.length; x < numPrivs; x += 1) { + for (var x = 0, numPrivs = groupPrivileges.length; x < numPrivs; x += 1) { memberPrivs[groupPrivileges[x]] = memberSets[x].indexOf(member) !== -1; } return { diff --git a/src/privileges/helpers.js b/src/privileges/helpers.js index 0939d2eeb5..bf3f45751e 100644 --- a/src/privileges/helpers.js +++ b/src/privileges/helpers.js @@ -107,7 +107,7 @@ helpers.isUsersAllowedTo = function (privilege, uids, cid, callback) { } var result = []; - for(var i = 0; i < uids.length; i += 1) { + for (var i = 0; i < uids.length; i += 1) { result.push(results.hasUserPrivilege[i] || results.hasGroupPrivilege[i]); } diff --git a/src/pubsub.js b/src/pubsub.js index f5c6c2f0ed..157cb7da98 100644 --- a/src/pubsub.js +++ b/src/pubsub.js @@ -26,7 +26,7 @@ var PubSub = function () { try { var msg = JSON.parse(message); self.emit(msg.event, msg.data); - } catch(err) { + } catch (err) { winston.error(err.stack); } }); diff --git a/src/routes/api.js b/src/routes/api.js index 98c884c237..c8c11c099e 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -4,7 +4,7 @@ var express = require('express'); var uploadsController = require('../controllers/uploads'); -module.exports = function (app, middleware, controllers) { +module.exports = function (app, middleware, controllers) { var router = express.Router(); app.use('/api', router); diff --git a/src/routes/index.js b/src/routes/index.js index 4d3eef927e..5e92851ef9 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -98,7 +98,7 @@ module.exports = function (app, middleware, hotswapIds) { var ensureLoggedIn = require('connect-ensure-login'); if (Array.isArray(hotswapIds) && hotswapIds.length) { - for(var idx, x = 0; x < hotswapIds.length; x += 1) { + for (var idx, x = 0; x < hotswapIds.length; x += 1) { idx = routers.push(express.Router()) - 1; routers[idx].hotswapId = hotswapIds[x]; } @@ -132,7 +132,7 @@ module.exports = function (app, middleware, hotswapIds) { userRoutes(router, middleware, controllers); groupRoutes(router, middleware, controllers); - for(var x = 0; x < routers.length; x += 1) { + for (var x = 0; x < routers.length; x += 1) { app.use(relativePath, routers[x]); } diff --git a/src/sitemap.js b/src/sitemap.js index 0fc0e9b478..4663c2df9f 100644 --- a/src/sitemap.js +++ b/src/sitemap.js @@ -38,7 +38,7 @@ sitemap.render = function (callback) { numPages = Math.ceil(tids.length / numTopics); } - for(var x = 1; x <= numPages; x += 1) { + for (var x = 1; x <= numPages; x += 1) { returnData.topics.push(x); } diff --git a/src/socket.io/admin/user.js b/src/socket.io/admin/user.js index 733f162425..f2dd3a6483 100644 --- a/src/socket.io/admin/user.js +++ b/src/socket.io/admin/user.js @@ -13,7 +13,7 @@ var plugins = require('../../plugins'); var User = {}; User.makeAdmins = function (socket, uids, callback) { - if(!Array.isArray(uids)) { + if (!Array.isArray(uids)) { return callback(new Error('[[error:invalid-data]]')); } @@ -22,7 +22,7 @@ User.makeAdmins = function (socket, uids, callback) { return callback(err); } - for(var i = 0; i < userData.length; i += 1) { + for (var i = 0; i < userData.length; i += 1) { if (userData[i] && parseInt(userData[i].banned, 10) === 1) { return callback(new Error('[[error:cant-make-banned-users-admin]]')); } @@ -35,7 +35,7 @@ User.makeAdmins = function (socket, uids, callback) { }; User.removeAdmins = function (socket, uids, callback) { - if(!Array.isArray(uids)) { + if (!Array.isArray(uids)) { return callback(new Error('[[error:invalid-data]]')); } diff --git a/src/socket.io/categories.js b/src/socket.io/categories.js index ff95fc9f7f..2c0ef102b4 100644 --- a/src/socket.io/categories.js +++ b/src/socket.io/categories.js @@ -44,7 +44,7 @@ SocketCategories.getWatchedCategories = function (socket, data, callback) { if (err) { return callback(err); } - var watchedCategories = results.categories.filter(function (category) { + var watchedCategories = results.categories.filter(function (category) { return category && results.ignoredCids.indexOf(category.cid.toString()) === -1; }); diff --git a/src/socket.io/groups.js b/src/socket.io/groups.js index 556739c1df..5689b75538 100644 --- a/src/socket.io/groups.js +++ b/src/socket.io/groups.js @@ -241,7 +241,7 @@ SocketGroups.search = function (socket, data, callback) { }; SocketGroups.loadMore = function (socket, data, callback) { - if (!data.sort || !utils.isNumber(data.after) || parseInt(data.after, 10) < 0) { + if (!data.sort || !utils.isNumber(data.after) || parseInt(data.after, 10) < 0) { return callback(); } diff --git a/src/socket.io/posts/votes.js b/src/socket.io/posts/votes.js index e5668789f2..c131155c87 100644 --- a/src/socket.io/posts/votes.js +++ b/src/socket.io/posts/votes.js @@ -62,7 +62,7 @@ module.exports = function (SocketPosts) { return callback(err, []); } - async.map(data, function (uids, next) { + async.map(data, function (uids, next) { var otherCount = 0; if (uids.length > 6) { otherCount = uids.length - 5; diff --git a/src/socket.io/topics/infinitescroll.js b/src/socket.io/topics/infinitescroll.js index 9b694550ff..e3d4239f33 100644 --- a/src/socket.io/topics/infinitescroll.js +++ b/src/socket.io/topics/infinitescroll.js @@ -11,7 +11,7 @@ var social = require('../../social'); module.exports = function (SocketTopics) { SocketTopics.loadMore = function (socket, data, callback) { - if (!data || !data.tid || !utils.isNumber(data.after) || parseInt(data.after, 10) < 0) { + if (!data || !data.tid || !utils.isNumber(data.after) || parseInt(data.after, 10) < 0) { return callback(new Error('[[error:invalid-data]]')); } var userPrivileges; diff --git a/src/socket.io/user/picture.js b/src/socket.io/user/picture.js index 56c4c4c1c9..a47623c24b 100644 --- a/src/socket.io/user/picture.js +++ b/src/socket.io/user/picture.js @@ -26,7 +26,7 @@ module.exports = function (SocketUser) { user.isAdminOrGlobalModOrSelf(socket.uid, data.uid, next); }, function (next) { - switch(type) { + switch (type) { case 'default': next(null, ''); break; diff --git a/src/start.js b/src/start.js index 68378d331c..489f114f53 100644 --- a/src/start.js +++ b/src/start.js @@ -56,7 +56,7 @@ start.start = function () { }, ], function (err) { if (err) { - switch(err.message) { + switch (err.message) { case 'schema-out-of-date': winston.warn('Your NodeBB schema is out-of-date. Please run the following command to bring your dataset up to spec:'); winston.warn(' ./nodebb upgrade'); diff --git a/src/topics/posts.js b/src/topics/posts.js index 39b3d5a049..5bcebf38ca 100644 --- a/src/topics/posts.js +++ b/src/topics/posts.js @@ -69,7 +69,7 @@ module.exports = function (Topics) { userData: function (next) { var uids = []; - for(var i = 0; i < postData.length; i += 1) { + for (var i = 0; i < postData.length; i += 1) { if (postData[i] && uids.indexOf(postData[i].uid) === -1) { uids.push(postData[i].uid); } @@ -90,7 +90,7 @@ module.exports = function (Topics) { }, editors: function (next) { var editors = []; - for(var i = 0; i < postData.length; i += 1) { + for (var i = 0; i < postData.length; i += 1) { if (postData[i] && postData[i].editor && editors.indexOf(postData[i].editor) === -1) { editors.push(postData[i].editor); } diff --git a/src/topics/recent.js b/src/topics/recent.js index 8defa37585..3d4f298369 100644 --- a/src/topics/recent.js +++ b/src/topics/recent.js @@ -7,7 +7,7 @@ var db = require('../database'); var plugins = require('../plugins'); var privileges = require('../privileges'); var user = require('../user'); -var categories = require('../categories'); +var categories = require('../categories'); module.exports = function (Topics) { var terms = { diff --git a/src/topics/tags.js b/src/topics/tags.js index 99f6c49a44..69d0de3332 100644 --- a/src/topics/tags.js +++ b/src/topics/tags.js @@ -366,7 +366,7 @@ module.exports = function (Topics) { query = query.toLowerCase(); var matches = []; - for(var i = 0; i < tags.length; i += 1) { + for (var i = 0; i < tags.length; i += 1) { if (tags[i].toLowerCase().startsWith(query)) { matches.push(tags[i]); if (matches.length > 19) { diff --git a/src/topics/teaser.js b/src/topics/teaser.js index 264c5c77a6..c8526a981d 100644 --- a/src/topics/teaser.js +++ b/src/topics/teaser.js @@ -30,7 +30,7 @@ module.exports = function (Topics) { delete topic.teaserPid; } - switch(meta.config.teaserPost) { + switch (meta.config.teaserPost) { case 'first': teaserPids.push(topic.mainPid); break; diff --git a/src/topics/tools.js b/src/topics/tools.js index da29498ec4..aa877e7de7 100644 --- a/src/topics/tools.js +++ b/src/topics/tools.js @@ -46,7 +46,7 @@ module.exports = function (Topics) { if (parseInt(topicData.deleted, 10) === 1 && isDelete) { return callback(new Error('[[error:topic-already-deleted]]')); - } else if(parseInt(topicData.deleted, 10) !== 1 && !isDelete) { + } else if (parseInt(topicData.deleted, 10) !== 1 && !isDelete) { return callback(new Error('[[error:topic-already-restored]]')); } diff --git a/src/upgrade.js b/src/upgrade.js index 01ca6a264f..99ac96842d 100644 --- a/src/upgrade.js +++ b/src/upgrade.js @@ -52,7 +52,7 @@ Upgrade.upgrade = function (callback) { return next(err); } - if(!value) { + if (!value) { db.set('schemaDate', latestSchema, function () { next(); }); @@ -317,13 +317,13 @@ Upgrade.upgrade = function (callback) { // IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 24!!! ], function (err) { if (!err) { - if(updatesMade) { + if (updatesMade) { winston.info('[upgrade] Schema update complete!'); } else { winston.info('[upgrade] Schema already up to date!'); } } else { - switch(err.message) { + switch (err.message) { case 'upgrade-not-possible': winston.error('[upgrade] NodeBB upgrade could not complete, as your database schema is too far out of date.'); winston.error('[upgrade] Please ensure that you did not skip any minor version upgrades.'); diff --git a/src/user/create.js b/src/user/create.js index ebd3a56d15..4bd6ddcaa4 100644 --- a/src/user/create.js +++ b/src/user/create.js @@ -18,7 +18,7 @@ module.exports = function (User) { } User.isDataValid(data, function (err) { - if (err) { + if (err) { return callback(err); } var timestamp = data.timestamp || Date.now(); diff --git a/src/user/data.js b/src/user/data.js index b49d038a3a..a303080e9c 100644 --- a/src/user/data.js +++ b/src/user/data.js @@ -126,7 +126,7 @@ module.exports = function (User) { user.status = User.getStatus(user); } - for(var i = 0; i < fieldsToRemove.length; i += 1) { + for (var i = 0; i < fieldsToRemove.length; i += 1) { user[fieldsToRemove[i]] = undefined; } diff --git a/src/user/delete.js b/src/user/delete.js index bc0ae912c6..ba3b56695d 100644 --- a/src/user/delete.js +++ b/src/user/delete.js @@ -57,7 +57,7 @@ module.exports = function (User) { } User.getUserFields(uid, ['username', 'userslug', 'fullname', 'email'], next); }, - function (_userData, next) { + function (_userData, next) { userData = _userData; plugins.fireHook('static:user.delete', {uid: uid}, next); }, diff --git a/src/user/jobs.js b/src/user/jobs.js index 63e6ef8b4b..591dba16fd 100644 --- a/src/user/jobs.js +++ b/src/user/jobs.js @@ -22,7 +22,7 @@ module.exports = function (User) { } // Terminate any active cron jobs - for(var jobId in jobs) { + for (var jobId in jobs) { if (jobs.hasOwnProperty(jobId)) { winston.verbose('[user/jobs] Terminating job (' + jobId + ')'); jobs[jobId].stop(); diff --git a/src/user/notifications.js b/src/user/notifications.js index 61dfc50f50..cc8d8b6ec1 100644 --- a/src/user/notifications.js +++ b/src/user/notifications.js @@ -64,7 +64,7 @@ var privileges = require('../privileges'); async.waterfall([ async.apply(db.getSortedSetRevRange, set, start, stop), function (nids, next) { - if(!Array.isArray(nids) || !nids.length) { + if (!Array.isArray(nids) || !nids.length) { return callback(null, []); } diff --git a/src/user/profile.js b/src/user/profile.js index 90df742d8e..1987bf1ae4 100644 --- a/src/user/profile.js +++ b/src/user/profile.js @@ -170,7 +170,7 @@ module.exports = function (User) { db.sortedSetAdd('email:uid', uid, newEmail.toLowerCase(), next); }, function (next) { - db.sortedSetAdd('email:sorted', 0, newEmail.toLowerCase() + ':' + uid, next); + db.sortedSetAdd('email:sorted', 0, newEmail.toLowerCase() + ':' + uid, next); }, function (next) { db.sortedSetAdd('user:' + uid + ':emails', Date.now(), newEmail + ':' + Date.now(), next); diff --git a/src/user/search.js b/src/user/search.js index 95e5b6ed29..a567b73ed6 100644 --- a/src/user/search.js +++ b/src/user/search.js @@ -135,9 +135,9 @@ module.exports = function (User) { }); } else { userData.sort(function (u1, u2) { - if(u1[sortBy] < u2[sortBy]) { + if (u1[sortBy] < u2[sortBy]) { return -1; - } else if(u1[sortBy] > u2[sortBy]) { + } else if (u1[sortBy] > u2[sortBy]) { return 1; } return 0; diff --git a/src/widgets/index.js b/src/widgets/index.js index 5d46b42416..247700ea21 100644 --- a/src/widgets/index.js +++ b/src/widgets/index.js @@ -89,7 +89,7 @@ widgets.getAreas = function (templates, locations, callback) { if (data && data[index] && data[index][location]) { try { returnData[template][location] = JSON.parse(data[index][location]); - } catch(err) { + } catch (err) { winston.error('can not parse widget data. template: ' + template + ' location: ' + location); returnData[template][location] = []; } @@ -113,7 +113,7 @@ widgets.getArea = function (template, location, callback) { } try { result = JSON.parse(result); - } catch(err) { + } catch (err) { return callback(err); } diff --git a/test/mocks/databasemock.js b/test/mocks/databasemock.js index 39b88a5c5a..dd4424c959 100644 --- a/test/mocks/databasemock.js +++ b/test/mocks/databasemock.js @@ -9,7 +9,7 @@ var async = require('async'); var winston = require('winston'); - var path = require('path'); + var path = require('path'); var nconf = require('nconf'); var url = require('url'); var errorText; diff --git a/test/posts.js b/test/posts.js index db8fa6a787..5b0687ca5e 100644 --- a/test/posts.js +++ b/test/posts.js @@ -366,7 +366,7 @@ describe('Post\'s', function () { it('should error with too many tags', function (done) { var tags = []; - for(var i = 0; i < meta.config.maximumTagsPerTopic + 1; i += 1) { + for (var i = 0; i < meta.config.maximumTagsPerTopic + 1; i += 1) { tags.push('tag' + i); } socketPosts.edit({uid: voterUid}, {pid: pid, content: 'edited post content', tags: tags}, function (err) { diff --git a/test/topics.js b/test/topics.js index 77ef54f5b7..91577cfa3d 100644 --- a/test/topics.js +++ b/test/topics.js @@ -505,7 +505,7 @@ describe('Topic\'s', function () { var topics = results.topics; var topic; var i; - for(i = 0; i < topics.length; i += 1) { + for (i = 0; i < topics.length; i += 1) { if (parseInt(topics[i].tid, 10) === parseInt(newTid, 10)) { assert.equal(false, topics[i].unread, 'ignored topic was marked as unread in recent list'); return done(); diff --git a/test/utils.js b/test/utils.js index 023051d4c2..96ccdce201 100644 --- a/test/utils.js +++ b/test/utils.js @@ -164,9 +164,9 @@ describe('Utility Methods', function () { var days = utils.getDaysArray(); var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; var index = 0; - for(var x = 29; x >= 0; x -= 1) { + for (var x = 29; x >= 0; x -= 1) { 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 += 1; } done();