From 6e0acbda504cbc55b0c8d82bd2a005964253d393 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Wed, 13 May 2015 12:23:27 +0200 Subject: [PATCH] jshint fixes --- app/models/bin_encoder.js | 33 +++++++++++++++++++++++++-------- app/models/cartodb_request.js | 4 +++- app/models/log4js_rollbar.js | 4 +++- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/app/models/bin_encoder.js b/app/models/bin_encoder.js index 38d909b1..0f8c693f 100644 --- a/app/models/bin_encoder.js +++ b/app/models/bin_encoder.js @@ -1,6 +1,8 @@ function ArrayBufferSer(type, data, options) { - if(type === undefined) throw "ArrayBufferSer should be created with a type"; + if(type === undefined) { + throw "ArrayBufferSer should be created with a type"; + } this.options = options || {}; this._initFunctions(); this.headerSize = 8; @@ -14,13 +16,14 @@ function ArrayBufferSer(type, data, options) { var w = this.writeFn[type]; + var i; if(!this.options.delta) { - for(var i = 0; i < data.length; ++i) { + for(i = 0; i < data.length; ++i) { this[w](data[i]); } } else { this[w](data[0]); - for(var i = 1; i < data.length; ++i) { + for(i = 1; i < data.length; ++i) { this[w](data[i] - data[i - 1]); } } @@ -66,7 +69,7 @@ ArrayBufferSer.prototype = { var s = this.sizes[type]; if(s) { var r = off % s; - return r == 0 ? 0 : s - r; + return r === 0 ? 0 : s - r; } return 0; }, @@ -78,7 +81,7 @@ ArrayBufferSer.prototype = { return s*t.length; } s = 0; - if(this.type == ArrayBufferSer.STRING) { + if(this.type === ArrayBufferSer.STRING) { // calculate size with padding t.forEach(function(arr) { var pad = self._paddingFor(offset, ArrayBufferSer.MAX_PADDING); @@ -108,16 +111,30 @@ ArrayBufferSer.prototype = { return this.headerSize + this._sizeFor(this.headerSize, this.data); }, - writeFn: ['', 'writeInt8', 'writeUInt8','writeUInt8Clamp', 'writeInt16LE', 'writeUInt16LE', 'writeUInt32LE', 'writeUInt32LE', 'writeFloatLE', 'writeDoubleLE', 'writeString', 'writteBuffer'], + writeFn: [ + '', + 'writeInt8', + 'writeUInt8', + 'writeUInt8Clamp', + 'writeInt16LE', + 'writeUInt16LE', + 'writeUInt32LE', + 'writeUInt32LE', + 'writeFloatLE', + 'writeDoubleLE', + 'writeString', + 'writteBuffer' + ], _initFunctions: function() { var self = this; this.writeFn.forEach(function(fn) { - if(self[fn] === undefined) + if(self[fn] === undefined) { self[fn] = function(d) { self.buffer[fn](d, self.offset); self.offset += self.sizes[self.type]; - } + }; + } }); }, diff --git a/app/models/cartodb_request.js b/app/models/cartodb_request.js index fb4765ee..dc3a0316 100644 --- a/app/models/cartodb_request.js +++ b/app/models/cartodb_request.js @@ -30,7 +30,9 @@ function userByHostName(host) { } if (mat.length !== 2) { - console.error("ERROR: pattern '" + re_userFromHost + "' gave unexpected matches against '" + host + "': " + mat); + console.error( + "ERROR: pattern '" + re_userFromHost + "' gave unexpected matches against '" + host + "': " + mat + ); return; } return mat[1]; diff --git a/app/models/log4js_rollbar.js b/app/models/log4js_rollbar.js index 08ccc13d..c26e1eb6 100644 --- a/app/models/log4js_rollbar.js +++ b/app/models/log4js_rollbar.js @@ -34,7 +34,9 @@ For logger.trace('one','two','three'): // // We only log error and higher errors // - if ( loggingEvent.level.level < 40000 ) return; + if ( loggingEvent.level.level < 40000 ) { + return; + } rollbar.reportMessage(loggingEvent.data); };