Skip to content

Commit

Permalink
Fixes linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dukeofsussex committed Nov 21, 2016
1 parent ae3e8e2 commit f6b7112
Show file tree
Hide file tree
Showing 77 changed files with 203 additions and 218 deletions.
2 changes: 1 addition & 1 deletion include/dao/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ module.exports = function CacheModule(pb){
* @param {Function} cb Callback function
*/
CacheFactory.shutdown = function(cb) {
cb = cb || utils.cb;
cb = cb || util.cb;

if (CLIENT !== null) {
try {
Expand Down
6 changes: 3 additions & 3 deletions include/dao/dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ module.exports = function DAOModule(pb) {
DAO.updateChangeHistory(item);
if (item._id) {
batch.find(DAO.getIdWhere(item._id)).updateOne({ $set: item });
delete item._id;;
delete item._id;
}
else {
batch.insert(item);
Expand Down Expand Up @@ -720,7 +720,7 @@ module.exports = function DAOModule(pb) {
}
db.listCollections(filter, options).toArray(function(err, results) {
if (util.isError(err)) {
return cb(err)
return cb(err);
}
cb(err, results);
});
Expand Down Expand Up @@ -990,4 +990,4 @@ module.exports = function DAOModule(pb) {

//exports
return DAO;
}
};
6 changes: 3 additions & 3 deletions include/dao/db_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module.exports = function DBManagerModule(pb) {
* @class DBManager
* @constructor
*/
function DBManager(){
function DBManager() {

/**
* Reference to the system instance of System
Expand Down Expand Up @@ -364,7 +364,7 @@ module.exports = function DBManagerModule(pb) {
//constructor specific logic
//register for shutdown
system.registerShutdownHook('DBManager', this.shutdown);
};
}

/**
* The protocol prefix for connecting to a mongo cluster
Expand Down Expand Up @@ -407,7 +407,7 @@ module.exports = function DBManagerModule(pb) {
str += ',';
}
str += hostAndPort;
};
}
return pb.UrlService.urlJoin(str, config.db.name) + options;
};

Expand Down
2 changes: 1 addition & 1 deletion include/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ module.exports = function EmailServiceModule(pb) {
throw err;
}
else if (!emailSettings) {
var err = new Error('No Email settings available. Go to the admin settings and put in SMTP settings');
err = new Error('No Email settings available. Go to the admin settings and put in SMTP settings');
pb.log.error(err.stack);
return cb(err);
}
Expand Down
2 changes: 1 addition & 1 deletion include/error/errors_over_time.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = function ErrorsOverTimeModule(/*pb*/) {
* @type {String}
*/
this.prefix = prefix;
};
}

/**
* Adds an error into the calculation to determine if too many errors have
Expand Down
4 changes: 2 additions & 2 deletions include/error/formatters/error_formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ module.exports = function(pb) {
//we failed so make sure don't do that again...
failedControllerPaths[paths[i]];
}
};
}
var cInstance = new ErrorController();
var context = {
pathVars: {},
Expand Down Expand Up @@ -176,7 +176,7 @@ module.exports = function(pb) {
ErrorFormatters.xml = function(params, cb) {

var xmlObj = function(key, obj) {
var xml = '<'+HtmlEncoder.htmlEncode(key)+'>'
var xml = '<' + HtmlEncoder.htmlEncode(key) + '>';
util.forEach(obj, function(val, key) {

if (util.isArray(val)) {
Expand Down
2 changes: 1 addition & 1 deletion include/error/pb_error.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = function PBErrorModule(pb) {
this.httpStatus = httpStatus ? httpStatus : 500;
this.localizationKey = null;
this.source = null;
};
}

//setup inheritance
util.inherits(PBError, Error);
Expand Down
2 changes: 1 addition & 1 deletion include/http/request_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var async = require('async');
var domain = require('domain');
var Cookies = require('cookies');
var util = require('../util.js');
var _ = require('lodash');
var _ = require('lodash');

module.exports = function RequestHandlerModule(pb) {

Expand Down
16 changes: 8 additions & 8 deletions include/model/create_document.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module.exports = function DocumentCreatorModule(pb) {
DocumentCreator.emailFormatting(post);
DocumentCreator.usernameFormatting(post);
DocumentCreator.accessFormatting(post);
post['object_type'] = object_type;
post.object_type = object_type;
return post;
};

Expand Down Expand Up @@ -100,8 +100,8 @@ module.exports = function DocumentCreatorModule(pb) {
* @param {Object} post Key value pair object
*/
DocumentCreator.emailFormatting = function(post){
if(util.isString(post['email'])) {
post['email'] = post['email'].toLowerCase();
if(util.isString(post.email)) {
post.email = post.email.toLowerCase();
}
};

Expand All @@ -112,8 +112,8 @@ module.exports = function DocumentCreatorModule(pb) {
* @param {Object} post Key value pair object
*/
DocumentCreator.usernameFormatting = function(post){
if(util.isString(post['username'])) {
post['username'] = post['username'].toLowerCase();
if(util.isString(post.username)) {
post.username = post.username.toLowerCase();
}
};

Expand All @@ -124,8 +124,8 @@ module.exports = function DocumentCreatorModule(pb) {
* @param {Object} post Key value pair object
*/
DocumentCreator.accessFormatting = function(post){
if(post['admin']) {
post['admin'] = parseInt(post['admin']);
if(post.admin) {
post.admin = parseInt(post.admin);
}
};

Expand Down Expand Up @@ -163,7 +163,7 @@ module.exports = function DocumentCreatorModule(pb) {
}

nullIfEmptyItems.forEach(function(propertyName) {
if (!post[propertyName] || post[propertyName].length == 0) {
if (!post[propertyName] || post[propertyName].length === 0) {
post[propertyName] = null;
}
});
Expand Down
22 changes: 11 additions & 11 deletions include/requirements.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,24 +232,24 @@ module.exports = function PB(config) {
//media renderers
pb.media = {
renderers: {
BaseMediaRenderer: require(path.join(config.docRoot, '/include/service/media/renderers/base_media_renderer.js'))(pb),
BaseMediaRenderer: require(path.join(config.docRoot, '/include/service/media/renderers/base_media_renderer.js'))(pb)
},

providers: {
FsMediaProvider: require(path.join(config.docRoot, '/include/service/media/fs_media_provider.js'))(pb),
MongoMediaProvider: require(path.join(config.docRoot, '/include/service/media/mongo_media_provider.js'))(pb)
}
};
pb.media.renderers.ImageMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/image_media_renderer.js'))(pb),
pb.media.renderers.VideoMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/video_media_renderer.js'))(pb),
pb.media.renderers.YouTubeMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/youtube_media_renderer.js'))(pb),
pb.media.renderers.DailyMotionMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/daily_motion_media_renderer.js'))(pb),
pb.media.renderers.VimeoMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/vimeo_media_renderer.js'))(pb),
pb.media.renderers.VineMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/vine_media_renderer.js'))(pb),
pb.media.renderers.InstagramMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/instagram_media_renderer.js'))(pb),
pb.media.renderers.SlideShareMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/slideshare_media_renderer.js'))(pb),
pb.media.renderers.TrinketMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/trinket_media_renderer.js'))(pb),
pb.media.renderers.StorifyMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/storify_media_renderer.js'))(pb),
pb.media.renderers.ImageMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/image_media_renderer.js'))(pb);
pb.media.renderers.VideoMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/video_media_renderer.js'))(pb);
pb.media.renderers.YouTubeMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/youtube_media_renderer.js'))(pb);
pb.media.renderers.DailyMotionMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/daily_motion_media_renderer.js'))(pb);
pb.media.renderers.VimeoMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/vimeo_media_renderer.js'))(pb);
pb.media.renderers.VineMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/vine_media_renderer.js'))(pb);
pb.media.renderers.InstagramMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/instagram_media_renderer.js'))(pb);
pb.media.renderers.SlideShareMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/slideshare_media_renderer.js'))(pb);
pb.media.renderers.TrinketMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/trinket_media_renderer.js'))(pb);
pb.media.renderers.StorifyMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/storify_media_renderer.js'))(pb);
pb.media.renderers.KickStarterMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/kickstarter_media_renderer.js'))(pb);
pb.media.renderers.PdfMediaRenderer = require(path.join(config.docRoot, '/include/service/media/renderers/pdf_media_renderer.js'))(pb);

Expand Down
10 changes: 5 additions & 5 deletions include/service/cache_entity_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ module.exports = function CacheEntityServiceModule(pb) {
}

//site specific value doesn't exist in cache
if (result == null) {
if (result === null) {

if (self.site === GLOBAL_SITE || self.onlyThisSite) {
return cb(null, null);
Expand All @@ -90,7 +90,7 @@ module.exports = function CacheEntityServiceModule(pb) {
}

//value doesn't exist in cache
if (result == null) {
if (result === null) {
return cb(null, null);
}

Expand All @@ -107,7 +107,7 @@ module.exports = function CacheEntityServiceModule(pb) {

CacheEntityService.prototype.getRightFieldFromValue = function(result, valueField) {
var val = result;
if (valueField != null){
if (valueField !== null){
var rawVal = JSON.parse(result);
val = rawVal[valueField];
}
Expand Down Expand Up @@ -139,7 +139,7 @@ module.exports = function CacheEntityServiceModule(pb) {

//value doesn't exist in cache
var val = null;
if (self.valueField == null) {
if (self.valueField === null) {
val = value;

if (util.isObject(val)) {
Expand All @@ -148,7 +148,7 @@ module.exports = function CacheEntityServiceModule(pb) {
}
else{
var rawVal = null;
if (result == null) {
if (result === null) {
rawVal = {
object_type: this.objType
};
Expand Down
4 changes: 2 additions & 2 deletions include/service/db_entity_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module.exports = function DbEntityServiceModule(pb) {
}

//get setting
var val = self.valueField == null ? entity : entity[self.valueField];
var val = self.valueField === null ? entity : entity[self.valueField];

//callback with the result
cb(null, val);
Expand Down Expand Up @@ -114,7 +114,7 @@ module.exports = function DbEntityServiceModule(pb) {

//value doesn't exist in cache
var val = null;
if (self.valueField == null) {
if (self.valueField === null) {
val = value;
}
else{
Expand Down
64 changes: 32 additions & 32 deletions include/service/entities/theme_service.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
/*
Copyright (C) 2016 PencilBlue, LLC
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
Copyright (C) 2016 PencilBlue, LLC
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
'use strict';

function ThemeService(useMemory, useCache) {

var objType = 'theme';
var services = [];
var objType = 'theme';
var services = [];

var options = {
objType: objType,
timeout: pb.config.plugins.caching.memory_timeout
};
var options = {
objType: objType,
timeout: pb.config.plugins.caching.memory_timeout
};

//add in-memory service
if (useMemory){
services.push(new pb.MemoryEntityService(options));
}
//add in-memory service
if (useMemory) {
services.push(new pb.MemoryEntityService(options));
}

//add cache service
if (useCache) {
services.push(new pb.CacheEntityService(options));
}
//add cache service
if (useCache) {
services.push(new pb.CacheEntityService(options));
}

//always add JSON
services.push(new pb.JSONFSEntityService(objType));
this.service = new pb.ReadOnlySimpleLayeredService(services, 'ThemeService');
//always add JSON
services.push(new pb.JSONFSEntityService(objType));
this.service = new pb.ReadOnlySimpleLayeredService(services, 'ThemeService');
}

//exports
Expand Down
2 changes: 1 addition & 1 deletion include/service/jobs/cluster_job_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ module.exports = function ClusterJobRunnerModule(pb) {
}
callback(null, true);
});
}
};
};

//exports
Expand Down
2 changes: 1 addition & 1 deletion include/service/jobs/plugins/plugin_job_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ module.exports = function PluginJobRunnerModule(pb) {
return;
}

var firstErr = undefined;
var firstErr;
var success = true;
for (var i = 0; i < results.length; i++) {
if (!results[i]) {
Expand Down
4 changes: 2 additions & 2 deletions include/service/json_fs_entity_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module.exports = function JSONFSEntityServiceModule(pb) {
catch(e) {
var error = util.format("%s: Failed to parse JSON from file: %s", this.type, key);
pb.log.error(error);
cb(new PBError(error).setSource(e));
cb(new pb.PBError(error).setSource(e)); // PBError class necessary?
}
};
JSONFSEntityService.super_.prototype.render.apply([this, key, handler]);
Expand All @@ -74,7 +74,7 @@ module.exports = function JSONFSEntityServiceModule(pb) {
*/
JSONFSEntityService.prototype.set = function(key, value, cb) {
if (!util.isObject(value) && !util.isArray(value)) {
cb(new PBError(this.type+": Value must be an array or object: "+util.inspect(value)), null);
cb(new pb.PBError(this.type+": Value must be an array or object: "+util.inspect(value)), null); // PBError class necessary?
}

try {
Expand Down
2 changes: 1 addition & 1 deletion include/service/locks/providers/cache_lock_provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = function(pb) {
CacheLockProvider.prototype.acquire = function(name, options, cb) {
if (util.isFunction(options)) {
cb = options;
options = {}
options = {};
}

//try and acquire the lock
Expand Down
2 changes: 1 addition & 1 deletion include/service/locks/providers/db_lock_provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module.exports = function(pb) {
DbLockProvider.prototype.acquire = function(name, options, cb) {
if (util.isFunction(options)) {
cb = options;
options = {}
options = {};
}

//calculate the lock expiration
Expand Down
Loading

0 comments on commit f6b7112

Please sign in to comment.