Browse Source

Merge pull request #147 from RiveraGroup/feature/mongo_2.6.5_jshint_query

Feature/mongo 2.6.5 jshint query
Chris Sexton 11 years ago
parent
commit
7133149eb0
5 changed files with 58 additions and 57 deletions
  1. 1 0
      .jshintrc
  2. 10 10
      lib/query/ArrayRunner.js
  3. 13 13
      lib/query/DocumentSourceRunner.js
  4. 29 29
      lib/query/Runner.js
  5. 5 5
      lib/query/index.js

+ 1 - 0
.jshintrc

@@ -23,6 +23,7 @@
 	"maxlen": 140,
 
 	"boss": true,
+	"expr": true,
 	"globalstrict": true,
 
 	"node": true,

+ 10 - 10
lib/query/ArrayRunner.js

@@ -1,6 +1,6 @@
 "use strict";
 
-var Runner = require('./Runner');
+var Runner = require("./Runner");
 
 /**
  * This class is an array runner used to run a pipeline against a static array of data
@@ -8,16 +8,16 @@ var Runner = require('./Runner');
  **/
 var klass = module.exports = function ArrayRunner(array){
 	base.call(this);
-	
-	if (!array || array.constructor !== Array ) throw new Error('Array runner requires an array');
+
+	if (!array || array.constructor !== Array ) throw new Error("Array runner requires an array");
 	this._array = array;
 	this._position = 0;
 	this._state = Runner.RunnerState.RUNNER_ADVANCED;
-}, base = Runner, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+}, base = Runner, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}}); //jshint ignore:line
 
 /**
  * Get the next result from the array.
- * 
+ *
  * @method getNext
  * @param [callback] {Function}
  */
@@ -35,13 +35,13 @@ proto.getNext = function getNext(callback) {
 		err = ex;
 		this._state = Runner.RunnerState.RUNNER_ERROR;
 	}
-	
+
 	return callback(err, obj, this._state);
 };
 
 /**
  * Save any state required to yield.
- * 
+ *
  * @method saveState
  */
 proto.saveState = function saveState() {
@@ -51,7 +51,7 @@ proto.saveState = function saveState() {
 /**
  * Restore saved state, possibly after a yield.  Return true if the runner is OK, false if
  * it was killed.
- * 
+ *
  * @method restoreState
  */
 proto.restoreState = function restoreState() {
@@ -60,7 +60,7 @@ proto.restoreState = function restoreState() {
 
 /**
  * Returns a description of the Runner
- * 
+ *
  * @method getInfo
  * @param [explain]
  * @param [planInfo]
@@ -79,7 +79,7 @@ proto.getInfo = function getInfo(explain) {
 
 /**
  * dispose of the Runner.
- * 
+ *
  * @method reset
  */
 proto.reset = function reset(){

+ 13 - 13
lib/query/DocumentSourceRunner.js

@@ -1,7 +1,7 @@
 "use strict";
 
-var Runner = require('./Runner'),
-	DocumentSource = require('../pipeline/documentSources/DocumentSource');
+var Runner = require("./Runner"),
+	DocumentSource = require("../pipeline/documentSources/DocumentSource");
 
 /**
  * This class is a runner used to wrap a document source
@@ -10,22 +10,22 @@ var Runner = require('./Runner'),
 var klass = module.exports = function DocumentSourceRunner(docSrc, pipeline){
 	base.call(this);
 
-	if (!docSrc || !(docSrc instanceof DocumentSource) ) throw new Error('DocumentSource runner requires a DocumentSource');
-	if (pipeline && pipeline.constructor != Array ) throw new Error('DocumentSource runner requires pipeline to be an Array');
-	
+	if (!docSrc || !(docSrc instanceof DocumentSource)) throw new Error("DocumentSource runner requires a DocumentSource");
+	if (!(pipeline instanceof Array)) throw new Error("DocumentSource runner requires pipeline to be an Array");
+
 	this._docSrc = docSrc;
 	this._pipeline = pipeline || [];
-	
+
 	while (this._pipeline.length && this._docSrc.coalesce(this._pipeline[0])) {
 		this._pipeline.shift();
 	}
-	
+
 	this._state = Runner.RunnerState.RUNNER_ADVANCED;
-}, base = Runner, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+}, base = Runner, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}}); //jshint ignore:line
 
 /**
  * Get the next result from the array.
- * 
+ *
  * @method getNext
  * @param [callback] {Function}
  */
@@ -47,7 +47,7 @@ proto.getNext = function getNext(callback) {
 
 /**
  * Save any state required to yield.
- * 
+ *
  * @method saveState
  */
 proto.saveState = function saveState() {
@@ -57,7 +57,7 @@ proto.saveState = function saveState() {
 /**
  * Restore saved state, possibly after a yield.  Return true if the runner is OK, false if
  * it was killed.
- * 
+ *
  * @method restoreState
  */
 proto.restoreState = function restoreState() {
@@ -66,7 +66,7 @@ proto.restoreState = function restoreState() {
 
 /**
  * Returns a description of the Runner
- * 
+ *
  * @method getInfo
  * @param [explain]
  * @param [planInfo]
@@ -84,7 +84,7 @@ proto.getInfo = function getInfo(explain) {
 
 /**
  * dispose of the Runner.
- * 
+ *
  * @method reset
  */
 proto.reset = function reset(){

+ 29 - 29
lib/query/Runner.js

@@ -2,14 +2,14 @@
 
 /**
  * This class is an implementation of the base class for runners used in MongoDB
- * 
+ *
  * Note that a lot of stuff here is not used by our code yet.  Check the existing implementations
  * for what we currently use
- * 
+ *
  **/
 var klass = module.exports = function Runner(){
-	
-}, base = Object, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+}, proto = klass.prototype;
 
 klass.RunnerState = {
 	// We successfully populated the out parameter.
@@ -70,12 +70,12 @@ klass.YieldPolicy = {
 
 /**
  * Set the yielding policy of the underlying runner.  See the RunnerYieldPolicy enum above.
- * 
+ *
  * @method setYieldPolicy
  * @param [policy]
  */
 proto.setYieldPolicy = function setYieldPolicy(policy) {
-	throw new Error('Not implemented');
+	throw new Error("Not implemented");
 };
 
 /**
@@ -108,23 +108,23 @@ proto.setYieldPolicy = function setYieldPolicy(policy) {
  * to a loggable format.
  *
  * objOut will be unowned if it's the result of a fetch or a collection scan.
- * 
+ *
  * @method getNext
  * @param [callback] {Function}
  */
 proto.getNext = function getNext(callback) {
-	throw new Error('Not implemented');
+	throw new Error("Not implemented");
 };
 
 
 /**
  * Will the next call to getNext() return EOF?  It's useful to know if the runner is done
  * without having to take responsibility for a result.
- * 
+ *
  * @method isEOF
  */
 proto.isEOF = function isEOF(){
-	throw new Error('Not implemented');
+	throw new Error("Not implemented");
 };
 
 /**
@@ -135,13 +135,13 @@ proto.isEOF = function isEOF(){
  * Called from CollectionCursorCache::invalidateDocument.
  *
  * See db/invalidation_type.h for InvalidationType.
- * 
+ *
  * @method invalidate
  * @param [dl]
  * @param [type]
  */
 proto.invalidate = function invalidate(dl, type) {
-	throw new Error('Not implemented');
+	throw new Error("Not implemented");
 };
 
 /**
@@ -151,72 +151,72 @@ proto.invalidate = function invalidate(dl, type) {
  *
  * The runner must guarantee as a postcondition that future calls to collection() will
  * return NULL.
- * 
+ *
  * @method kill
  */
 proto.kill = function kill() {
-	throw new Error('Not implemented');
+	throw new Error("Not implemented");
 };
 
 /**
  * Save any state required to yield.
- * 
+ *
  * @method saveState
  */
 proto.saveState = function saveState() {
-	throw new Error('Not implemented');
+	throw new Error("Not implemented");
 };
 
 /**
  * Restore saved state, possibly after a yield.  Return true if the runner is OK, false if
  * it was killed.
- * 
+ *
  * @method restoreState
  */
 proto.restoreState = function restoreState() {
-	throw new Error('Not implemented');
+	throw new Error("Not implemented");
 };
 
 /**
  * Return the NS that the query is running over.
- * 
+ *
  * @method ns
  */
 proto.ns = function ns() {
-	throw new Error('Not implemented');
+	throw new Error("Not implemented");
 };
 
 /**
  * Return the Collection that the query is running over.
- * 
+ *
  * @method collection
  */
 proto.collection = function collection() {
-	throw new Error('Not implemented');
+	throw new Error("Not implemented");
 };
 
 /**
- * Returns OK, allocating and filling '*explain' or '*planInfo' with a description of the
+ * Returns OK, allocating and filling "*explain" or "*planInfo" with a description of the
  * chosen plan, depending on which is non-NULL (one of the two should be NULL). Caller
- * takes onwership of either '*explain' and '*planInfo'. Otherwise, returns false
+ * takes onwership of either "*explain" and "*planInfo". Otherwise, returns false
  * a detailed error status.
  *
- * If 'explain' is NULL, then this out-parameter is ignored. Similarly, if 'staticInfo'
+ * If "explain" is NULL, then this out-parameter is ignored. Similarly, if "staticInfo"
  * is NULL, then no static debug information is produced.
- * 
+ *
  * @method getInfo
  * @param [explain]
  * @param [planInfo]
  */
 proto.getInfo = function getInfo(explain, planInfo) {
-	throw new Error('Not implemented');
+	throw new Error("Not implemented");
 };
 
 /**
  * dispose of the Runner.
- * 
+ *
  * @method reset
  */
 proto.reset = function reset(){
-	throw new Error('Not implemented');
+	throw new Error("Not implemented");
 };

+ 5 - 5
lib/query/index.js

@@ -1,9 +1,9 @@
 "use strict";
 
-var DocumentSource = require('../pipeline/documentSources/DocumentSource'),
-	Runner = require("./Runner.js"),
-	ArrayRunner = require("./ArrayRunner.js"),
-	DocumentSourceRunner = require("./DocumentSourceRunner.js");
+var DocumentSource = require("../pipeline/documentSources/DocumentSource"),
+	Runner = require("./Runner"),
+	ArrayRunner = require("./ArrayRunner"),
+	DocumentSourceRunner = require("./DocumentSourceRunner");
 
 module.exports = {
 	Runner: Runner,
@@ -15,7 +15,7 @@ module.exports = {
 		} else if (data && data instanceof DocumentSource){
 			return new DocumentSourceRunner(data, sources);
 		} else {
-			throw new Error('could not construct Runner from given data');
+			throw new Error("could not construct Runner from given data");
 		}
 	}
 };