-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mongo package linting #8175
Mongo package linting #8175
Changes from 11 commits
9df15fc
69ef77b
349a1b4
cea6f4a
a71a6e6
fa631c4
1472a41
4197c9d
7a8ce9a
92a2c4f
23b5564
bd61f6b
3739a60
a60b30f
ada34ef
fc3349b
2a8667d
5b193e5
ebde43d
edf58bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,8 +63,7 @@ var replaceMongoAtomWithMeteor = function (document) { | |
if (document instanceof MongoDB.ObjectID) { | ||
return new Mongo.ObjectID(document.toHexString()); | ||
} | ||
if (document["EJSON$type"] && document["EJSON$value"] | ||
&& _.size(document) === 2) { | ||
if (document["EJSON$type"] && document["EJSON$value"] && _.size(document) === 2) { | ||
return EJSON.fromJSONValue(replaceNames(unmakeMongoLegal, document)); | ||
} | ||
if (document instanceof MongoDB.Timestamp) { | ||
|
@@ -494,7 +493,6 @@ MongoConnection.prototype._update = function (collection_name, selector, mod, | |
throw new Error( | ||
"Only plain objects may be used as replacement" + | ||
" documents in MongoDB"); | ||
return; | ||
} | ||
|
||
if (!options) options = {}; | ||
|
@@ -522,11 +520,11 @@ MongoConnection.prototype._update = function (collection_name, selector, mod, | |
var knownId = selector._id || mod._id; | ||
|
||
if (options._forbidReplace && ! isModify) { | ||
var e = new Error("Invalid modifier. Replacements are forbidden."); | ||
var err = new Error("Invalid modifier. Replacements are forbidden."); | ||
if (callback) { | ||
return callback(e); | ||
return callback(err); | ||
} else { | ||
throw e; | ||
throw err; | ||
} | ||
} | ||
|
||
|
@@ -936,7 +934,7 @@ Cursor.prototype._publishCursor = function (sub) { | |
Cursor.prototype._getCollectionName = function () { | ||
var self = this; | ||
return self._cursorDescription.collectionName; | ||
} | ||
}; | ||
|
||
Cursor.prototype.observe = function (callbacks) { | ||
var self = this; | ||
|
@@ -1092,7 +1090,7 @@ _.extend(SynchronousCursor.prototype, { | |
return self.map(_.identity); | ||
}, | ||
|
||
count: function (applySkipLimit: false) { | ||
count: function (applySkipLimit = false) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
var self = this; | ||
return self._synchronousCount(applySkipLimit).wait(); | ||
}, | ||
|
@@ -1120,18 +1118,19 @@ MongoConnection.prototype.tail = function (cursorDescription, docCallback) { | |
var cursor = self._createSynchronousCursor(cursorDescription); | ||
|
||
var stopped = false; | ||
var lastTS = undefined; | ||
var lastTS; | ||
var loop = function () { | ||
var doc = null; | ||
while (true) { | ||
if (stopped) | ||
return; | ||
try { | ||
var doc = cursor._nextObject(); | ||
doc = cursor._nextObject(); | ||
} catch (err) { | ||
// There's no good way to figure out if this was actually an error | ||
// from Mongo. Ah well. But either way, we need to retry the cursor | ||
// (unless the failure was because the observe got stopped). | ||
doc = null; | ||
// `doc` is already `null` here; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this change is safe or just a "linting" change – at least not without further consideration or explanation. This is in a loop. While Do you disagree? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @abernix you're right. My bad. |
||
} | ||
// Since cursor._nextObject can yield, we need to check again to see if | ||
// we've been stopped before calling the callback. | ||
|
@@ -1350,9 +1349,7 @@ MongoConnection.prototype._observeChangesTailable = function ( | |
// error if you didn't provide them. | ||
if ((ordered && !callbacks.addedBefore) || | ||
(!ordered && !callbacks.added)) { | ||
throw new Error("Can't observe an " + (ordered ? "ordered" : "unordered") | ||
+ " tailable cursor without a " | ||
+ (ordered ? "addedBefore" : "added") + " callback"); | ||
throw new Error("Can't observe an " + (ordered ? "ordered" : "unordered") + " tailable cursor without a " + (ordered ? "addedBefore" : "added") + " callback"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Preference to revert this. Previous readability was better and lines over 100 characters are too much. While there may be room with your IDE maximized, not everyone does this. |
||
} | ||
|
||
return self.tail(cursorDescription, function (doc) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also go ahead and wrap/indent this while we're at it?