Don't warn about await in loops

This commit is contained in:
Daniel Huigens 2018-05-16 18:57:30 +02:00
parent db39e616ca
commit 05479e6e6b
8 changed files with 1 additions and 12 deletions

View File

@ -137,7 +137,6 @@ module.exports = {
"newline-per-chained-call": "off",
"no-alert": "error",
"no-array-constructor": "error",
"no-await-in-loop": "error",
"no-bitwise": "off",
"no-buffer-constructor": "error",
"no-caller": "error",
@ -320,6 +319,7 @@ module.exports = {
"require-await": 0,
"no-multi-assign": 0,
"no-underscore-dangle": 0,
"no-await-in-loop": 0,
// Custom errors:
"no-undef": 2,

View File

@ -63,7 +63,6 @@ hash_headers[11] = [0x30, 0x2d, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01,
async function getPkcs1Padding(length) {
let result = '';
while (result.length < length) {
// eslint-disable-next-line no-await-in-loop
const randomBytes = await random.getRandomBytes(length - result.length);
for (let i = 0; i < randomBytes.length; i++) {
if (randomBytes[i] !== 0) {

View File

@ -75,7 +75,6 @@ export default {
// or s = 0 if signatures are generated properly.
while (true) {
// See Appendix B here: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
// eslint-disable-next-line no-await-in-loop
k = await random.getRandomBN(one, q); // returns in [1, q-1]
r = gred.redPow(k).fromRed().toRed(redq); // (g**k mod p) mod q
if (zero.cmp(r) === 0) {

View File

@ -59,7 +59,6 @@ async function randomProbablePrime(bits, e, k) {
n = n.mod(min.shln(1)).iadd(min);
i = n.mod(thirty).toNumber();
}
// eslint-disable-next-line no-await-in-loop
} while (!await isProbablePrime(n, e, k));
return n;
}
@ -248,7 +247,6 @@ async function millerRabin(n, k, rand) {
const d = n.shrn(s);
for (; k > 0; k--) {
// eslint-disable-next-line no-await-in-loop
const a = rand ? rand() : await random.getRandomBN(new BN(2), n1);
let x = a.toRed(red).redPow(d);

View File

@ -296,7 +296,6 @@ Key.prototype.getSigningKey = async function (keyId=null, date=new Date(), userI
const subKeys = this.subKeys.slice().sort((a, b) => b.keyPacket.created - a.keyPacket.created);
for (let i = 0; i < subKeys.length; i++) {
if (!keyId || subKeys[i].getKeyId().equals(keyId)) {
// eslint-disable-next-line no-await-in-loop
if (await subKeys[i].verify(primaryKey, date) === enums.keyStatus.valid) {
const bindingSignature = getLatestSignature(subKeys[i].bindingSignatures, date);
if (isValidSigningKeyPacket(subKeys[i].keyPacket, bindingSignature, date)) {
@ -342,7 +341,6 @@ Key.prototype.getEncryptionKey = async function(keyId, date=new Date(), userId={
const subKeys = this.subKeys.slice().sort((a, b) => b.keyPacket.created - a.keyPacket.created);
for (let i = 0; i < subKeys.length; i++) {
if (!keyId || subKeys[i].getKeyId().equals(keyId)) {
// eslint-disable-next-line no-await-in-loop
if (await subKeys[i].verify(primaryKey, date) === enums.keyStatus.valid) {
const bindingSignature = getLatestSignature(subKeys[i].bindingSignatures, date);
if (isValidEncryptionKeyPacket(subKeys[i].keyPacket, bindingSignature, date)) {
@ -541,11 +539,9 @@ Key.prototype.getPrimaryUser = async function(date=new Date(), userId={}) {
const primaryKey = this.keyPacket;
const dataToVerify = { userId: user.userId, key: primaryKey };
// skip if certificates is invalid, revoked, or expired
// eslint-disable-next-line no-await-in-loop
if (!(cert.verified || await cert.verify(primaryKey, dataToVerify))) {
return null;
}
// eslint-disable-next-line no-await-in-loop
if (cert.revoked || await user.isRevoked(primaryKey, cert, null, date)) {
return null;
}

View File

@ -192,7 +192,6 @@ KeyArray.prototype.importKey = async function (armored) {
const keyidHex = key.getKeyId().toHex();
const keyFound = this.getForId(keyidHex);
if (keyFound) {
// eslint-disable-next-line no-await-in-loop
await keyFound.update(key);
} else {
this.push(key);

View File

@ -118,7 +118,6 @@ Message.prototype.decrypt = async function(privateKeys, passwords, sessionKeys)
}
try {
// eslint-disable-next-line no-await-in-loop
await symEncryptedPacket.decrypt(keyObjs[i].algorithm, keyObjs[i].data);
break;
} catch (e) {

View File

@ -197,7 +197,6 @@ List.prototype.map = function (callback) {
*/
List.prototype.some = async function (callback) {
for (let i = 0; i < this.length; i++) {
// eslint-disable-next-line no-await-in-loop
if (await callback(this[i], i, this)) {
return true;
}