mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-21 12:39:08 +01:00
SERVER-23728 Enable the no-unused-expressions ESLint rule
This commit is contained in:
parent
2d00414fa0
commit
2569b254a5
@ -33,6 +33,7 @@ rules:
|
||||
no-sparse-arrays: 2
|
||||
no-unexpected-multiline: 2
|
||||
no-unreachable: 2
|
||||
no-unused-expressions: 2
|
||||
no-useless-call: 2
|
||||
no-with: 2
|
||||
semi: 2
|
||||
|
@ -157,32 +157,27 @@ var testOps = function(db, allowedActions) {
|
||||
var dbName = db.getName();
|
||||
var db2 = newConn.getDB(dbName);
|
||||
|
||||
if (db2 == 'admin') {
|
||||
if (db2.getName() == 'admin') {
|
||||
assert.eq(1, db2.auth('aro', AUTH_INFO.admin.aro.pwd));
|
||||
} else {
|
||||
assert.eq(1, db2.auth('ro', AUTH_INFO.test.ro.pwd));
|
||||
}
|
||||
|
||||
var cursor = db2.kill_cursor.find().batchSize(2);
|
||||
// Create cursor from db2.
|
||||
var cmdRes = db2.runCommand({find: db2.kill_cursor.getName(), batchSize: 2});
|
||||
assert.commandWorked(cmdRes);
|
||||
var cursorId = cmdRes.cursor.id;
|
||||
assert(!bsonBinaryEqual({cursorId: cursorId}, {cursorId: NumberLong(0)}),
|
||||
"find command didn't return a cursor: " + tojson(cmdRes));
|
||||
|
||||
db.killCursor(cursor.id());
|
||||
// Send a synchronous message to make sure that kill cursor was processed
|
||||
// before proceeding.
|
||||
db.runCommand({whatsmyuri: 1});
|
||||
|
||||
checkErr(!allowedActions.hasOwnProperty('killCursor'), function() {
|
||||
while (cursor.hasNext()) {
|
||||
var next = cursor.next();
|
||||
|
||||
// This is a failure in mongos case. Standalone case will fail
|
||||
// when next() was called.
|
||||
if (next.code == 16336) {
|
||||
// could not find cursor in cache for id
|
||||
throw next.$err;
|
||||
}
|
||||
}
|
||||
checkErr(allowedActions.hasOwnProperty('killCursor'), function() {
|
||||
// Issue killCursor command from db.
|
||||
cmdRes = db.runCommand({killCursors: db2.kill_cursor.getName(), cursors: [cursorId]});
|
||||
assert.commandWorked(cmdRes);
|
||||
assert(bsonBinaryEqual({cursorId: cmdRes.cursorsKilled}, {cursorId: [cursorId]}),
|
||||
"unauthorized to kill cursor: " + tojson(cmdRes));
|
||||
});
|
||||
}); // TODO: enable test after SERVER-5813 is fixed.
|
||||
})();
|
||||
|
||||
var isMongos = db.runCommand({isdbgrid: 1}).isdbgrid;
|
||||
// Note: fsyncUnlock is not supported in mongos.
|
||||
@ -192,7 +187,7 @@ var testOps = function(db, allowedActions) {
|
||||
var errorCodeUnauthorized = 13;
|
||||
|
||||
if (res.code == errorCodeUnauthorized) {
|
||||
throw Error("unauthorized unauthorized fsyncUnlock");
|
||||
throw Error("unauthorized fsyncUnlock");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ coll.drop();
|
||||
for (i = 0; i < 100; i++) {
|
||||
coll.insert({a: i, b: "strvar_" + (i % 13), c: NumberInt(i % 10)});
|
||||
}
|
||||
coll.insert;
|
||||
|
||||
coll.ensureIndex({a: 1, b: -1, c: 1});
|
||||
|
||||
// Test no query, sort on all fields in index order
|
||||
|
@ -1,25 +0,0 @@
|
||||
|
||||
t = db.distinct_speed1;
|
||||
|
||||
t.drop();
|
||||
for (var i = 0; i < 10000; i++) {
|
||||
t.save({x: i % 10});
|
||||
}
|
||||
|
||||
assert.eq(10, t.distinct("x").length, "A1");
|
||||
|
||||
function fast() {
|
||||
t.find().explain("executionStats").executionStats.executionTimeMillis;
|
||||
}
|
||||
|
||||
function slow() {
|
||||
t.distinct("x");
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
print("it: " + Date.timeFunc(fast));
|
||||
print("di: " + Date.timeFunc(slow));
|
||||
}
|
||||
|
||||
t.ensureIndex({x: 1});
|
||||
t.distinct("x", {x: 5});
|
@ -96,7 +96,6 @@ assert.throws(function() {
|
||||
}, [], "throw on invalid sorted projection (field mismatch)");
|
||||
|
||||
assert.throws(function() {
|
||||
x;
|
||||
t.find({group: 3, 'x.a': 2}, {'x.$': 1, group: 0}).sort({x: 1}).toArray();
|
||||
}, [], "throw on invalid projection combination (include and exclude)");
|
||||
|
||||
|
@ -13,4 +13,4 @@
|
||||
writeConcern: {w: 'majority', wtimeout: 30000}
|
||||
};
|
||||
db.runCommand({'eval': 'db.runCommand(' + tojson(insertCommand) + ')'});
|
||||
});
|
||||
})();
|
||||
|
@ -103,7 +103,7 @@ p = {
|
||||
},
|
||||
initial: {count: 0},
|
||||
finalize: function(obj) {
|
||||
ob;
|
||||
throw new Error("Intentionally throwing exception in finalize function");
|
||||
}
|
||||
};
|
||||
assert.commandFailedWithCode(
|
||||
@ -117,7 +117,7 @@ p = {
|
||||
},
|
||||
initial: {count: 0},
|
||||
finalize: function(obj) {
|
||||
ob;
|
||||
throw new Error("Intentionally throwing exception in finalize function");
|
||||
}
|
||||
};
|
||||
assert.commandFailedWithCode(
|
||||
|
@ -16,7 +16,6 @@ assert.eq("/abc/i", real.c.toString(), "regex 1");
|
||||
|
||||
var cursor = t.find({
|
||||
$where: function() {
|
||||
fullObject;
|
||||
assert.eq(7, Object.keySet(obj).length, "A");
|
||||
assert.eq(1, obj.a, "B");
|
||||
assert.eq("abc", obj.b, "C");
|
||||
@ -37,7 +36,6 @@ t.drop();
|
||||
t.save({a: 2, b: {c: 7, d: "d is good"}});
|
||||
var cursor = t.find({
|
||||
$where: function() {
|
||||
fullObject;
|
||||
assert.eq(3, Object.keySet(obj).length);
|
||||
assert.eq(2, obj.a);
|
||||
assert.eq(7, obj.b.c);
|
||||
|
@ -17,5 +17,5 @@ t.drop();
|
||||
t.ensureIndex({loc: "2d"});
|
||||
|
||||
assert.throws(function() {
|
||||
t.find({$or: [{loc: {$near: [11, 11]}}]}).limit(1).next()['_id'];
|
||||
t.find({$or: [{loc: {$near: [11, 11]}}]}).limit(1).next();
|
||||
});
|
||||
|
@ -4,10 +4,10 @@
|
||||
* and local reads and writes return the last applied optime's timestamp.
|
||||
*/
|
||||
(function() {
|
||||
load("jstests/replsets/rslib.js"); // For startSetIfSupportsReadMajority.
|
||||
|
||||
"use strict";
|
||||
|
||||
load("jstests/replsets/rslib.js"); // For startSetIfSupportsReadMajority.
|
||||
|
||||
function assertCorrectOperationTime(operationTime, expectedTimestamp, opTimeType) {
|
||||
assert.eq(0,
|
||||
timestampCmp(operationTime, expectedTimestamp),
|
||||
|
@ -12,21 +12,21 @@ var secondary = replTest.liveNodes.slaves[0].getDB(name);
|
||||
|
||||
// populate the collection
|
||||
for (i = 0; i < 5; i++) {
|
||||
primary.in .insert({x: i});
|
||||
primary.coll.insert({x: i});
|
||||
}
|
||||
replTest.awaitReplication();
|
||||
|
||||
// make sure $out cannot be run on a secondary
|
||||
assert.throws(function() {
|
||||
secondary.in .aggregate({$out: "out"}).itcount;
|
||||
secondary.coll.aggregate({$out: "out"}).itcount();
|
||||
});
|
||||
// even if slaveOk
|
||||
secondary.setSlaveOk();
|
||||
assert.throws(function() {
|
||||
secondary.in .aggregate({$out: "out"}).itcount;
|
||||
secondary.coll.aggregate({$out: "out"}).itcount();
|
||||
});
|
||||
|
||||
// run one and check for proper replication
|
||||
primary.in .aggregate({$out: "out"}).itcount;
|
||||
primary.coll.aggregate({$out: "out"}).itcount();
|
||||
replTest.awaitReplication();
|
||||
assert.eq(primary.out.find().sort({x: 1}).toArray(), secondary.out.find().sort({x: 1}).toArray());
|
||||
|
@ -12,11 +12,10 @@
|
||||
*
|
||||
*/
|
||||
(function() {
|
||||
load("jstests/libs/write_concern_util.js"); // for stopReplicationOnSecondaries,
|
||||
// restartReplicationOnSecondaries
|
||||
|
||||
"use strict";
|
||||
|
||||
load("jstests/libs/write_concern_util.js"); // for stopReplicationOnSecondaries,
|
||||
// restartReplicationOnSecondaries
|
||||
var name = "shutdown_primary";
|
||||
|
||||
var replTest = new ReplSetTest({name: name, nodes: 3});
|
||||
|
@ -20,12 +20,12 @@
|
||||
*
|
||||
*/
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
load("jstests/libs/write_concern_util.js"); // for stopReplicationOnSecondaries,
|
||||
// restartServerReplication,
|
||||
// restartReplSetReplication
|
||||
|
||||
'use strict';
|
||||
|
||||
var name = 'stepdown_needs_electable_secondary';
|
||||
|
||||
var replTest = new ReplSetTest({name: name, nodes: 5});
|
||||
|
@ -16,12 +16,12 @@
|
||||
*
|
||||
*/
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
load("jstests/libs/write_concern_util.js"); // for stopReplicationOnSecondaries, //
|
||||
// restartServerReplication,
|
||||
// restartReplSetReplication
|
||||
|
||||
'use strict';
|
||||
|
||||
function assertStepDownFailsWithExceededTimeLimit(node) {
|
||||
assert.commandFailedWithCode(
|
||||
node.getDB("admin").runCommand({replSetStepDown: 5, secondaryCatchUpPeriodSecs: 5}),
|
||||
|
Loading…
Reference in New Issue
Block a user