From 366e258ec7d43e2f67dbd476b082d7a251d24e5f Mon Sep 17 00:00:00 2001 From: Lucas Dohmen Date: Mon, 5 Aug 2013 16:55:51 +0200 Subject: [PATCH] Foxx: JSLint --- js/server/modules/org/arangodb/foxx.js | 2 +- .../modules/org/arangodb/foxx/application.js | 18 +++++++++++++----- .../org/arangodb/foxx/base_middleware.js | 5 +++-- .../org/arangodb/foxx/format_middleware.js | 2 +- js/server/modules/org/arangodb/foxx/model.js | 8 ++++++-- .../modules/org/arangodb/foxx/repository.js | 2 +- .../org/arangodb/foxx/template_middleware.js | 2 +- 7 files changed, 26 insertions(+), 13 deletions(-) diff --git a/js/server/modules/org/arangodb/foxx.js b/js/server/modules/org/arangodb/foxx.js index e1d04b7d77..b20719e926 100644 --- a/js/server/modules/org/arangodb/foxx.js +++ b/js/server/modules/org/arangodb/foxx.js @@ -1,4 +1,4 @@ -/*jslint indent: 2, nomen: true, maxlen: 120, sloppy: true, vars: true */ +/*jslint indent: 2, maxlen: 120 */ /*global module, require, exports */ //////////////////////////////////////////////////////////////////////////////// diff --git a/js/server/modules/org/arangodb/foxx/application.js b/js/server/modules/org/arangodb/foxx/application.js index 9b7d4d3289..b0dfae9f80 100644 --- a/js/server/modules/org/arangodb/foxx/application.js +++ b/js/server/modules/org/arangodb/foxx/application.js @@ -1,3 +1,4 @@ +/*jslint indent: 2, nomen: true, maxlen: 120 */ /*global module, require, exports */ //////////////////////////////////////////////////////////////////////////////// @@ -185,8 +186,14 @@ _.extend(Application.prototype, { //////////////////////////////////////////////////////////////////////////////// createRepository: function (name, opts) { - var model; - var Repo; + 'use strict'; + var model, + Repo, + prefix, + cname, + collection, + Model = require("org/arangodb/foxx/model").Model, + Repository = require("org/arangodb/foxx/repository").Repository; if (opts && opts.hasOwnProperty('model')) { model = this.applicationContext.appModule.require(opts.model).Model; @@ -208,15 +215,16 @@ _.extend(Application.prototype, { Repo = Repository; } - var prefix = this.applicationContext.collectionPrefix; - var cname; + prefix = this.applicationContext.collectionPrefix; if (prefix === "") { cname = name; } else { cname = prefix + "_" + name; } - var collection = db._collection(cname); + + collection = db._collection(cname); + if (!collection) { throw new Error("collection with name '" + cname + "' does not exist."); } diff --git a/js/server/modules/org/arangodb/foxx/base_middleware.js b/js/server/modules/org/arangodb/foxx/base_middleware.js index d5aa5cc88a..7c138fe5d1 100644 --- a/js/server/modules/org/arangodb/foxx/base_middleware.js +++ b/js/server/modules/org/arangodb/foxx/base_middleware.js @@ -1,4 +1,4 @@ -/*jslint indent: 2, nomen: true, maxlen: 120, sloppy: true, vars: true */ +/*jslint indent: 2, nomen: true, maxlen: 120 */ /*global module, require, exports */ //////////////////////////////////////////////////////////////////////////////// @@ -43,6 +43,7 @@ BaseMiddleware = function () { var middleware = function (request, response, options, next) { var responseFunctions, requestFunctions, + trace, _ = require("underscore"), console = require("console"), actions = require("org/arangodb/actions"); @@ -175,7 +176,7 @@ BaseMiddleware = function () { /// @brief trace //////////////////////////////////////////////////////////////////////////////// - var trace = options.isDevelopment; + trace = options.isDevelopment; if (!trace && options.hasOwnProperty("options")) { trace = options.options.trace; } diff --git a/js/server/modules/org/arangodb/foxx/format_middleware.js b/js/server/modules/org/arangodb/foxx/format_middleware.js index cb72c5aa15..b2bdcc285a 100644 --- a/js/server/modules/org/arangodb/foxx/format_middleware.js +++ b/js/server/modules/org/arangodb/foxx/format_middleware.js @@ -1,4 +1,4 @@ -/*jslint indent: 2, nomen: true, maxlen: 120, sloppy: true, vars: true */ +/*jslint indent: 2, nomen: true, maxlen: 120 */ /*global module, require, exports */ //////////////////////////////////////////////////////////////////////////////// diff --git a/js/server/modules/org/arangodb/foxx/model.js b/js/server/modules/org/arangodb/foxx/model.js index 9d2e7e075e..4e0d8f46b5 100644 --- a/js/server/modules/org/arangodb/foxx/model.js +++ b/js/server/modules/org/arangodb/foxx/model.js @@ -1,4 +1,4 @@ -/*jslint indent: 2, nomen: true, maxlen: 120, sloppy: true, vars: true */ +/*jslint indent: 2, nomen: true, maxlen: 120 */ /*global module, require, exports */ //////////////////////////////////////////////////////////////////////////////// @@ -55,7 +55,6 @@ var Model, Model = function (attributes) { 'use strict'; - this.attributes = attributes || {}; }; @@ -81,6 +80,7 @@ _.extend(Model.prototype, { //////////////////////////////////////////////////////////////////////////////// get: function (attributeName) { + 'use strict'; return this.attributes[attributeName]; }, @@ -104,6 +104,7 @@ _.extend(Model.prototype, { //////////////////////////////////////////////////////////////////////////////// set: function (attributeName, value) { + 'use strict'; this.attributes[attributeName] = value; }, @@ -128,6 +129,7 @@ _.extend(Model.prototype, { //////////////////////////////////////////////////////////////////////////////// has: function (attributeName) { + 'use strict'; return !(_.isUndefined(this.attributes[attributeName]) || _.isNull(this.attributes[attributeName])); }, @@ -142,6 +144,7 @@ _.extend(Model.prototype, { //////////////////////////////////////////////////////////////////////////////// forDB: function () { + 'use strict'; return this.attributes; }, @@ -155,6 +158,7 @@ _.extend(Model.prototype, { //////////////////////////////////////////////////////////////////////////////// forClient: function () { + 'use strict'; return this.attributes; } }); diff --git a/js/server/modules/org/arangodb/foxx/repository.js b/js/server/modules/org/arangodb/foxx/repository.js index 21c557a0b2..d7945fd936 100644 --- a/js/server/modules/org/arangodb/foxx/repository.js +++ b/js/server/modules/org/arangodb/foxx/repository.js @@ -1,4 +1,4 @@ -/*jslint indent: 2, nomen: true, maxlen: 120, sloppy: true, vars: true */ +/*jslint indent: 2, nomen: true, maxlen: 120 */ /*global module, require, exports */ //////////////////////////////////////////////////////////////////////////////// diff --git a/js/server/modules/org/arangodb/foxx/template_middleware.js b/js/server/modules/org/arangodb/foxx/template_middleware.js index 003563c258..59315116bb 100644 --- a/js/server/modules/org/arangodb/foxx/template_middleware.js +++ b/js/server/modules/org/arangodb/foxx/template_middleware.js @@ -1,4 +1,4 @@ -/*jslint indent: 2, nomen: true, maxlen: 120, sloppy: true, vars: true */ +/*jslint indent: 2, nomen: true, maxlen: 120 */ /*global module, require, exports */ ////////////////////////////////////////////////////////////////////////////////