feat(space-unary-ops) : changes according to space unary ops eslint rule (#1639) r=vladikoff

This commit is contained in:
Divya Biyani 2017-02-08 21:09:56 +05:30 коммит произвёл Vlad Filippov
Родитель 08151dddae
Коммит 8ca537cbcc
49 изменённых файлов: 129 добавлений и 131 удалений

Просмотреть файл

@ -61,7 +61,7 @@ module.exports = function (log, error) {
// log a flow event that user got blocked.
request.emitMetricsEvent('customs.blocked')
var unblock = !!result.unblock
var unblock = !! result.unblock
if (result.retryAfter) {
// create a localized retryAfterLocalized value from retryAfter, for example '713' becomes '12 minutes'.
var retryAfterLocalized = localizeTimestamp.format(Date.now() + (result.retryAfter * 1000),

Просмотреть файл

@ -386,7 +386,7 @@ module.exports = function (
.then(
function (body) {
var data = bufferize(body)
data.emailVerified = !!data.emailVerified
data.emailVerified = !! data.emailVerified
return data
},
function (err) {
@ -404,7 +404,7 @@ module.exports = function (
.then(
function (body) {
var data = bufferize(body)
data.emailVerified = !!data.emailVerified
data.emailVerified = !! data.emailVerified
return data
},
function (err) {

Просмотреть файл

@ -36,7 +36,7 @@ module.exports = function (log, error) {
}
function deleteAccountIfUnverified(record) {
if (!record.emailVerified) {
if (! record.emailVerified) {
return db.deleteAccount(record)
.then(
accountDeleted.bind(null, record.uid, record.email),
@ -72,7 +72,7 @@ module.exports = function (log, error) {
op: 'handleBounce',
action: recipient.action,
email: email,
bounce: !!message.bounce,
bounce: !! message.bounce,
diagnosticCode: recipient.diagnosticCode,
status: recipient.status
}
@ -94,7 +94,7 @@ module.exports = function (log, error) {
// Log the type of complaint and userAgent reported
if (message.complaint) {
logData.complaint = !!message.complaint
logData.complaint = !! message.complaint
if (message.complaint.userAgent) {
logData.complaintUserAgent = message.complaint.userAgent

Просмотреть файл

@ -58,7 +58,7 @@ function AppError(options, extra, headers) {
this.message = options.message || DEFAULTS.message
this.isBoom = true
this.stack = options.stack
if (!this.stack) {
if (! this.stack) {
Error.captureStackTrace(this, AppError)
}
this.errno = options.errno || DEFAULTS.errno
@ -335,7 +335,7 @@ AppError.requestBodyTooLarge = function () {
}
AppError.tooManyRequests = function (retryAfter, retryAfterLocalized, canUnblock) {
if (!retryAfter) {
if (! retryAfter) {
retryAfter = 30
}
@ -383,7 +383,7 @@ AppError.requestBlocked = function (canUnblock) {
}
AppError.serviceUnavailable = function (retryAfter) {
if (!retryAfter) {
if (! retryAfter) {
retryAfter = 30
}
return new AppError(
@ -403,7 +403,7 @@ AppError.serviceUnavailable = function (retryAfter) {
}
AppError.featureNotEnabled = function (retryAfter) {
if (!retryAfter) {
if (! retryAfter) {
retryAfter = 30
}
return new AppError(

Просмотреть файл

@ -55,7 +55,7 @@ Lug.prototype.error = function (data) {
// lift it into top-level fields so that our
// PII-scrubbing tool is able to find it.
if (data.err && data.err.email) {
if (!data.email) {
if (! data.email) {
data.email = data.err.email
}
data.err.email = null

Просмотреть файл

@ -176,13 +176,13 @@ module.exports = function (log, config) {
function validate() {
const metadata = this.payload.metricsContext
if (!metadata) {
if (! metadata) {
return logInvalidContext(this, 'missing context')
}
if (!metadata.flowId) {
if (! metadata.flowId) {
return logInvalidContext(this, 'missing flowId')
}
if (!metadata.flowBeginTime) {
if (! metadata.flowBeginTime) {
return logInvalidContext(this, 'missing flowBeginTime')
}

Просмотреть файл

@ -125,4 +125,3 @@ function safeParse (json) {
catch (e) {
}
}

Просмотреть файл

@ -20,7 +20,7 @@ module.exports = function (error, config) {
if (payload.aud !== config.domain) {
return { aud: payload.aud }
}
if (!payload.sub || payload.sub !== email) {
if (! payload.sub || payload.sub !== email) {
return { sub: payload.sub }
}
return false
@ -43,7 +43,7 @@ module.exports = function (error, config) {
}
return function isPreVerified(email, token) {
if (!token) { return P.resolve(false) }
if (! token) { return P.resolve(false) }
return isValidToken(email, token)
}
}

Просмотреть файл

@ -336,7 +336,7 @@ module.exports = function (log, db, config) {
var pushPayload = null
var pushOptions = { 'TTL': options.TTL || '0' }
if (options.data) {
if (!device.pushPublicKey || !device.pushAuthKey) {
if (! device.pushPublicKey || ! device.pushAuthKey) {
reportPushError(new Error(ERR_DATA_BUT_NO_KEYS), uid, deviceId)
incrementPushAction(events.noKeys)
return

Просмотреть файл

@ -182,7 +182,7 @@ module.exports = function (
}
function createAccount () {
if (!locale) {
if (! locale) {
// We're seeing a surprising number of accounts created
// without a proper locale. Log details to help debug this.
log.info({
@ -562,13 +562,13 @@ module.exports = function (
}
)
}
if (!didSigninUnblock && customsErr) {
if (! didSigninUnblock && customsErr) {
throw customsErr
}
}
function checkSecurityHistory () {
if (!features.isSecurityHistoryTrackingEnabled()) {
if (! features.isSecurityHistoryTrackingEnabled()) {
return
}
return db.securityEvents({
@ -840,7 +840,7 @@ module.exports = function (
// Delegate sending emails for unverified users to auth-server.
emailSent = false
if (!emailRecord.emailVerified) {
if (! emailRecord.emailVerified) {
if (didSigninUnblock) {
log.info({
op: 'Account.login.unverified.unblocked',
@ -994,7 +994,7 @@ module.exports = function (
// customs server has not rate-limited unblock. Nonetheless,
// we shouldn't signal to the content-server that it is
// possible to unblock the user if the feature is not allowed.
if (!allowSigninUnblock && err.output && err.output.payload) {
if (! allowSigninUnblock && err.output && err.output.payload) {
delete err.output.payload.verificationMethod
delete err.output.payload.verificationReason
}
@ -1154,7 +1154,7 @@ module.exports = function (
var keyFetchToken = request.auth.credentials
var verified = keyFetchToken.tokenVerified && keyFetchToken.emailVerified
if (!verified) {
if (! verified) {
// don't delete the token on use until the account is verified
return reply(error.unverifiedAccount())
}
@ -1237,7 +1237,7 @@ module.exports = function (
payload.id = sessionToken.deviceId.toString('hex')
}
if (payload.pushCallback && (!payload.pushPublicKey || !payload.pushAuthKey)) {
if (payload.pushCallback && (! payload.pushPublicKey || ! payload.pushAuthKey)) {
payload.pushPublicKey = ''
payload.pushAuthKey = ''
}
@ -1319,7 +1319,7 @@ module.exports = function (
var ip = request.app.clientAddress
var payload = body.payload
if (!validatePushPayload(payload)) {
if (! validatePushPayload(payload)) {
throw error.invalidRequestParameter('invalid payload')
}
var pushOptions = {
@ -1520,8 +1520,8 @@ module.exports = function (
// of accounts with invalid email addresses. These
// can never be verified, so the best we can do is
// to delete them so the browser will stop polling.
if (!sessionToken.emailVerified) {
if (!validators.isValidEmailAddress(sessionToken.email)) {
if (! sessionToken.emailVerified) {
if (! validators.isValidEmailAddress(sessionToken.email)) {
return db.deleteAccount(sessionToken)
.then(
function () {
@ -1538,7 +1538,7 @@ module.exports = function (
function createResponse() {
var sessionVerified = sessionToken.tokenVerified
var emailVerified = !!sessionToken.emailVerified
var emailVerified = !! sessionToken.emailVerified
// For backwards-compatibility reasons, the reported verification status
// depends on whether the sessionToken was created with keys=true and
@ -1593,7 +1593,7 @@ module.exports = function (
code = sessionToken.emailCode
}
if (!sessionToken.emailVerified) {
if (! sessionToken.emailVerified) {
func = mailer.sendVerifyCode
event = 'verification'
} else {
@ -2042,7 +2042,7 @@ module.exports = function (
function createKeyFetchToken () {
if (requestHelper.wantsKeys(request)) {
if (!hasSessionToken) {
if (! hasSessionToken) {
// Sanity-check: any client requesting keys,
// should also be requesting a sessionToken.
throw error.missingRequestParameter('sessionToken')
@ -2077,7 +2077,7 @@ module.exports = function (
function createResponse () {
// If no sessionToken, this could be a legacy client
// attempting to reset an account password, return legacy response.
if (!hasSessionToken) {
if (! hasSessionToken) {
return {}
}
@ -2125,7 +2125,7 @@ module.exports = function (
return checkPassword(emailRecord, authPW, request.app.clientAddress)
.then(
function (match) {
if (!match) {
if (! match) {
throw error.incorrectPassword(emailRecord.email, form.email)
}
return db.deleteAccount(emailRecord)

Просмотреть файл

@ -64,7 +64,7 @@ module.exports = function (
return checkPassword(emailRecord, oldAuthPW, request.app.clientAddress)
.then(
function (match) {
if (!match) {
if (! match) {
throw error.incorrectPassword(emailRecord.email, form.email)
}
var password = new Password(
@ -271,7 +271,7 @@ module.exports = function (
function createSessionToken() {
return P.resolve()
.then(() => {
if (!verifiedStatus) {
if (! verifiedStatus) {
return random(16)
}
})
@ -317,7 +317,7 @@ module.exports = function (
function createResponse () {
// If no sessionToken, this could be a legacy client
// attempting to change password, return legacy response.
if (!sessionTokenId) {
if (! sessionTokenId) {
return {}
}

Просмотреть файл

@ -42,7 +42,7 @@ module.exports = function (log, P, isA, error, signer, db, domain, devices) {
// No need to wait for a response, update in the background.
db.updateSessionToken(sessionToken, request.headers['user-agent'])
if (!sessionToken.emailVerified) {
if (! sessionToken.emailVerified) {
return reply(error.unverifiedAccount())
}
@ -73,29 +73,29 @@ module.exports = function (log, P, isA, error, signer, db, domain, devices) {
.then(
function () {
if (publicKey.algorithm === 'RS') {
if (!publicKey.n) {
if (! publicKey.n) {
return reply(error.missingRequestParameter('n'))
}
if (!publicKey.e) {
if (! publicKey.e) {
return reply(error.missingRequestParameter('e'))
}
}
else { // DS
if (!publicKey.y) {
if (! publicKey.y) {
return reply(error.missingRequestParameter('y'))
}
if (!publicKey.p) {
if (! publicKey.p) {
return reply(error.missingRequestParameter('p'))
}
if (!publicKey.q) {
if (! publicKey.q) {
return reply(error.missingRequestParameter('q'))
}
if (!publicKey.g) {
if (! publicKey.g) {
return reply(error.missingRequestParameter('g'))
}
}
if (!sessionToken.locale) {
if (! sessionToken.locale) {
if (request.app.acceptLanguage) {
// Log details to sanity-check locale backfilling.
log.info({

Просмотреть файл

@ -69,7 +69,7 @@ module.exports.email = function() {
module.exports.isValidEmailAddress = function(value) {
// It cant be empty or end with strange chars.
if (!value) {
if (! value) {
return false
}
if (value[value.length - 1] === '.' || value[value.length - 1] === '-') {
@ -87,7 +87,7 @@ module.exports.isValidEmailAddress = function(value) {
domain = punycode.toASCII(domain)
// The username portion must contain only allowed characters.
for (var i = 0; i < username.length; i++) {
if (!username[i].match(/[a-zA-Z0-9.!#$%&'*+-\/=?^_`{|}~]/)) {
if (! username[i].match(/[a-zA-Z0-9.!#$%&'*+-\/=?^_`{|}~]/)) {
return false
}
}
@ -110,7 +110,7 @@ module.exports.isValidEmailAddress = function(value) {
if (domain[i - 1] === '.') {
return false
}
} else if (!domain[i].match(/[a-zA-Z0-9-]/)) {
} else if (! domain[i].match(/[a-zA-Z0-9-]/)) {
// The domain characters must be alphanumeric.
return false
}
@ -122,7 +122,7 @@ module.exports.isValidEmailAddress = function(value) {
module.exports.redirectTo = function (base) {
var redirectTo = isA.string().max(512)
if (!base) { return redirectTo }
if (! base) { return redirectTo }
var regex = new RegExp('(?:\\.|^)' + base.replace('.', '\\.') + '$')
redirectTo._tests.push(
{

Просмотреть файл

@ -10,7 +10,7 @@ var Hapi = require('hapi')
var HEX_STRING = require('./routes/validators').HEX_STRING
function trimLocale(header) {
if (!header) {
if (! header) {
return header
}
if (header.length < 256) {
@ -74,7 +74,7 @@ function create(log, error, config, routes, db) {
function makeCredentialFn(dbGetFn) {
return function (id, cb) {
log.trace({ op: 'DB.getToken', id: id })
if (!HEX_STRING.test(id)) {
if (! HEX_STRING.test(id)) {
return process.nextTick(cb.bind(null, null, null)) // not found
}
dbGetFn(Buffer(id, 'hex'))

Просмотреть файл

@ -33,7 +33,7 @@ module.exports = function (log) {
function (err, data) {
if (err) {
log.error({ op: 'fetch', url: url, err: err })
if (!errTimer) {
if (! errTimer) {
// unacceptable! this aws lib will call the callback
// more than once with different errors. ಠ_ಠ
errTimer = setTimeout(this.fetch.bind(this, url), 2000)

Просмотреть файл

@ -61,7 +61,7 @@ module.exports = function (crypto, P, hkdf, butil, error) {
var hmac = crypto.createHmac(HASH_ALGORITHM, keys.hmacKey)
hmac.update(ciphertext)
var mac = hmac.digest()
if (!butil.buffersAreEqual(mac, expectedHmac)) {
if (! butil.buffersAreEqual(mac, expectedHmac)) {
throw error.invalidSignature()
}
return butil.xorBuffers(ciphertext, keys.xorKey)

Просмотреть файл

@ -7,7 +7,7 @@ module.exports = function (log, inherits, Token, P, error) {
function KeyFetchToken(keys, details) {
Token.call(this, keys, details)
this.keyBundle = details.keyBundle
this.emailVerified = !!details.emailVerified
this.emailVerified = !! details.emailVerified
// Tokens are considered verified if no tokenVerificationId exists
this.tokenVerificationId = details.tokenVerificationId || null

Просмотреть файл

@ -37,7 +37,7 @@ module.exports = function (log, inherits, Token, random, lifetime) {
}
PasswordForgotToken.prototype.failAttempt = function () {
this.tries--
this.tries --
return this.tries < 1
}

Просмотреть файл

@ -19,10 +19,10 @@ module.exports = (log, inherits, Token, config) => {
this.setDeviceInfo(details)
this.email = details.email || null
this.emailCode = details.emailCode || null
this.emailVerified = !!details.emailVerified
this.emailVerified = !! details.emailVerified
this.verifierSetAt = details.verifierSetAt
this.locale = details.locale || null
this.mustVerify = !!details.mustVerify || false
this.mustVerify = !! details.mustVerify || false
if (details.createdAt > 0) {
this.accountCreatedAt = details.createdAt

Просмотреть файл

@ -2,6 +2,7 @@
"plugins": ["fxa"],
"rules": {
"no-console": 0,
"fxa/async-crypto-random": 0
"fxa/async-crypto-random": 0,
"fxa/no-new-buffer": 2
}
}

Просмотреть файл

@ -9,7 +9,7 @@ const localeQuirks = require('./localeQuirks')
var errors = {}
function reportError(lang, msg) {
if (!errors[lang]) {
if (! errors[lang]) {
errors[lang] = []
}
errors[lang].push(msg)
@ -21,7 +21,7 @@ function langFromEmail(email) {
}
function ensureHeader(headers, key, lang) {
if (!headers[key]) {
if (! headers[key]) {
reportError(lang, 'Missing header ' + key)
}
}
@ -73,7 +73,7 @@ function ensureSubjectLang(lang, subject, expectedSubject) {
// en-GB is almost identical to en, except for... fugly
var en_sync = 'A new device is now syncing to your Firefox Account'
var en_gb_sync = 'A new device is now synchronising to your Firefox Account'
if (!(lang === 'en-GB' && expectedSubject === en_sync && subject === en_gb_sync)) {
if (! (lang === 'en-GB' && expectedSubject === en_sync && subject === en_gb_sync)) {
reportError(lang, util.format('strings should be equal: "%s" vs. "%s"',
subject, expectedSubject))
}
@ -93,7 +93,7 @@ function checkContent(mail, idx) {
var missing = []
contentChecks.xheaders.forEach(function(xheader) {
if (!mail.headers[xheader]) {
if (! mail.headers[xheader]) {
missing.push(xheader)
}
})

Просмотреть файл

@ -30,7 +30,7 @@ const secretKeyFile = config.get('secretKeyFile')
try {
var keysExist = fs.existsSync(pubKeyFile) && fs.existsSync(secretKeyFile)
assert(!keysExist, 'keys already exists')
assert(! keysExist, 'keys already exists')
} catch(e) {
process.exit()
}
@ -57,4 +57,3 @@ cp.exec(
console.error('Public Key saved:', pubKeyFile)
}
)

Просмотреть файл

@ -7,3 +7,4 @@ env:
rules:
fxa/async-crypto-random: 0
fxa/no-new-buffer: 2

Просмотреть файл

@ -42,7 +42,7 @@ server.stderr
console.log(json)
}
if (json.op && json.op === 'request.summary') {
if (!start) start = Date.now()
if (! start) start = Date.now()
requests++
if (json.code === 200) { pass++ } else { fail++ }
var stat = pathStats[json.path] || {}

Просмотреть файл

@ -43,7 +43,7 @@ module.exports = config => {
}
// We do a shallow clone to avoid tainting the caller's copy of `headers`.
headers = JSON.parse(JSON.stringify(headers))
if (token && !headers.Authorization) {
if (token && ! headers.Authorization) {
headers.Authorization = hawkHeader(token, method, url, payload, this.timeOffset)
}
var options = {
@ -125,7 +125,7 @@ module.exports = config => {
}
ClientApi.prototype.accountLogin = function (email, authPW, opts) {
if (!opts) {
if (! opts) {
opts = { keys: true }
}
@ -447,7 +447,7 @@ module.exports = config => {
}
ClientApi.prototype.passwordForgotVerifyCode = function (passwordForgotTokenHex, code, headers, options) {
if (!options) {
if (! options) {
options = {}
}

Просмотреть файл

@ -415,7 +415,7 @@ module.exports = config => {
}
Client.prototype.resetPassword = function (newPassword, headers, options) {
if (!this.accountResetToken) {
if (! this.accountResetToken) {
throw new Error('call verifyPasswordResetCode before calling resetPassword')
}
// this will generate a new wrapKb on the server

Просмотреть файл

@ -159,7 +159,7 @@ describe('bounce messages', () => {
assert.equal(mockLog.messages[5].args[0].op, 'handleBounce')
assert.equal(mockLog.messages[5].args[0].email, 'verified@example.com')
assert.equal(mockLog.messages[5].args[0].status, '4.0.0')
assert(!mockLog.messages[3].args[0].diagnosticCode)
assert(! mockLog.messages[3].args[0].diagnosticCode)
assert.equal(mockLog.messages[6].args[0], 'account.email_bounced')
assert.equal(mockLog.messages[7].level, 'increment')
assert.equal(mockLog.messages[7].args[0], 'account.email_bounced.already_verified')

Просмотреть файл

@ -190,8 +190,8 @@ describe('Customs', () => {
assert.equal(err.message, 'The request was blocked for security reasons', 'Error message is correct')
assert.ok(err.isBoom, 'The error causes a boom')
assert.equal(err.output.statusCode, 400, 'Status Code is correct')
assert(!err.output.payload.retryAfter, 'retryAfter field is not present')
assert(!err.output.headers['retry-after'], 'retryAfter header is not present')
assert(! err.output.payload.retryAfter, 'retryAfter field is not present')
assert(! err.output.headers['retry-after'], 'retryAfter header is not present')
})
}
)
@ -431,4 +431,3 @@ function newAction() {
return EMAIL_ACTIONS[Math.floor(Math.random() * EMAIL_ACTIONS.length)]
}

Просмотреть файл

@ -105,7 +105,7 @@ describe('AppErrors', () => {
result = AppError.tooManyRequests(900)
assert.equal(result.output.payload.retryAfter, 900)
assert(!result.output.payload.retryAfterLocalized)
assert(! result.output.payload.retryAfterLocalized)
}
)

Просмотреть файл

@ -380,7 +380,7 @@ describe('log', () => {
assert.equal(args[0], 'unexpectedError', 'logger.error received "op" value')
assert.equal(Object.keys(args[1]).length, 3, 'log info has three fields')
assert.equal(args[1].email, 'test@example.com', 'email is reported in top-level fields')
assert(!args[1].err.email, 'email should not be reported in error object')
assert(! args[1].err.email, 'email should not be reported in error object')
logger.error.reset()
}

Просмотреть файл

@ -65,7 +65,7 @@ describe('push', () => {
return push.pushToDevices([mockUid], 'bogusid').then(function () {
assert(false, 'must throw')
}, function(err) {
assert(!push.sendPush.called)
assert(! push.sendPush.called)
})
}
)

Просмотреть файл

@ -707,7 +707,7 @@ describe('metricsConext', () => {
var metricsContext = require('../../../lib/metrics/context')(mockLog, mockConfig)
var valid = metricsContext.validate.call(mockRequest)
assert(!valid, 'the data is treated as invalid')
assert(! valid, 'the data is treated as invalid')
assert.equal(mockLog.info.callCount, 0, 'log.info was not called')
assert.equal(mockLog.warn.callCount, 1, 'log.warn was called once')
assert.ok(mockLog.warn.calledWithExactly({
@ -743,8 +743,8 @@ describe('metricsConext', () => {
var metricsContext = require('../../../lib/metrics/context')(mockLog, mockConfig)
var valid = metricsContext.validate.call(mockRequest)
assert(!valid, 'the data is treated as invalid')
assert(!mockRequest.payload.metricsContext.flowBeginTime, 'the invalid flow data was removed')
assert(! valid, 'the data is treated as invalid')
assert(! mockRequest.payload.metricsContext.flowBeginTime, 'the invalid flow data was removed')
assert.equal(mockLog.info.callCount, 0, 'log.info was not called')
assert.equal(mockLog.warn.callCount, 1, 'log.warn was called once')
assert.ok(mockLog.warn.calledWithExactly({
@ -780,8 +780,8 @@ describe('metricsConext', () => {
var metricsContext = require('../../../lib/metrics/context')(mockLog, mockConfig)
var valid = metricsContext.validate.call(mockRequest)
assert(!valid, 'the data is treated as invalid')
assert(!mockRequest.payload.metricsContext.flowId, 'the invalid flow data was removed')
assert(! valid, 'the data is treated as invalid')
assert(! mockRequest.payload.metricsContext.flowId, 'the invalid flow data was removed')
assert.equal(mockLog.info.callCount, 0, 'log.info was not called')
assert.equal(mockLog.warn.callCount, 1, 'log.warn was called once')
assert.ok(mockLog.warn.calledWithExactly({
@ -818,8 +818,8 @@ describe('metricsConext', () => {
var metricsContext = require('../../../lib/metrics/context')(mockLog, mockConfig)
var valid = metricsContext.validate.call(mockRequest)
assert(!valid, 'the data is treated as invalid')
assert(!mockRequest.payload.metricsContext.flowId, 'the invalid flow data was removed')
assert(! valid, 'the data is treated as invalid')
assert(! mockRequest.payload.metricsContext.flowId, 'the invalid flow data was removed')
assert.equal(mockLog.info.callCount, 0, 'log.info was not called')
assert.equal(mockLog.warn.callCount, 1, 'log.warn was called once')
assert.ok(mockLog.warn.calledWithExactly({
@ -856,8 +856,8 @@ describe('metricsConext', () => {
var metricsContext = require('../../../lib/metrics/context')(mockLog, mockConfig)
var valid = metricsContext.validate.call(mockRequest)
assert(!valid, 'the data is treated as invalid')
assert(!mockRequest.payload.metricsContext.flowId, 'the invalid flow data was removed')
assert(! valid, 'the data is treated as invalid')
assert(! mockRequest.payload.metricsContext.flowId, 'the invalid flow data was removed')
assert.equal(mockLog.info.callCount, 0, 'log.info was not called')
assert.equal(mockLog.warn.callCount, 1, 'log.warn was called once')
assert.ok(mockLog.warn.calledWithExactly({
@ -904,8 +904,8 @@ describe('metricsConext', () => {
Date.now.restore()
}
assert(!valid, 'the data is treated as invalid')
assert(!mockRequest.payload.metricsContext.flowId, 'the invalid flow data was removed')
assert(! valid, 'the data is treated as invalid')
assert(! mockRequest.payload.metricsContext.flowId, 'the invalid flow data was removed')
assert.equal(mockLog.info.callCount, 0, 'log.info was not called')
assert.equal(mockLog.warn.callCount, 1, 'log.warn was called once')
assert.ok(mockLog.warn.calledWithExactly({
@ -952,8 +952,8 @@ describe('metricsConext', () => {
Date.now.restore()
}
assert(!valid, 'the data is treated as invalid')
assert(!mockRequest.payload.metricsContext.flowId, 'the invalid flow data was removed')
assert(! valid, 'the data is treated as invalid')
assert(! mockRequest.payload.metricsContext.flowId, 'the invalid flow data was removed')
assert.equal(mockLog.info.callCount, 0, 'log.info was not called')
assert.equal(mockLog.warn.callCount, 1, 'log.warn was called once')
assert.ok(mockLog.warn.calledWithExactly({
@ -1000,8 +1000,8 @@ describe('metricsConext', () => {
Date.now.restore()
}
assert(!valid, 'the data is treated as invalid')
assert(!mockRequest.payload.metricsContext.flowId, 'the invalid flow data was removed')
assert(! valid, 'the data is treated as invalid')
assert(! mockRequest.payload.metricsContext.flowId, 'the invalid flow data was removed')
assert.equal(mockLog.info.callCount, 0, 'log.info was not called')
assert.equal(mockLog.warn.callCount, 1, 'log.warn was called once')
assert.ok(mockLog.warn.calledWithExactly({

Просмотреть файл

@ -71,7 +71,7 @@ describe('Password', () => {
)
.then(
function (matched) {
assert.ok(!matched, 'passwords should not match')
assert.ok(! matched, 'passwords should not match')
}
)
}

Просмотреть файл

@ -89,7 +89,7 @@ describe('password_check', () => {
)
.then(
function (match) {
assert.equal(!!match, false, 'password does not match, checkPassword returns false')
assert.equal(!! match, false, 'password does not match, checkPassword returns false')
assert.equal(MockCustoms.flag.callCount, 1, 'customs.flag was called')
assert.equal(MockCustoms.flag.getCall(0).args[0], CLIENT_ADDRESS, 'customs.flag was called with client ip')
assert.deepEqual(MockCustoms.flag.getCall(0).args[1], {

Просмотреть файл

@ -577,7 +577,7 @@ describe('/account/login', function () {
assert.equal(args[2].uaDeviceType, 'mobile')
assert.equal(mockMailer.sendNewDeviceLoginNotification.callCount, 0, 'mailer.sendNewDeviceLoginNotification was not called')
assert.ok(!response.verified, 'response indicates account is not verified')
assert.ok(! response.verified, 'response indicates account is not verified')
assert.equal(response.verificationMethod, 'email', 'verificationMethod is email')
assert.equal(response.verificationReason, 'login', 'verificationReason is login')
}).finally(() => Date.now.restore())
@ -649,7 +649,7 @@ describe('/account/login', function () {
assert.ok(tokenData.tokenVerificationId, 'sessionToken was created unverified')
assert.equal(mockMailer.sendVerifyCode.callCount, 0, 'mailer.sendVerifyCode was not called')
assert.equal(mockMailer.sendNewDeviceLoginNotification.callCount, 0, 'mailer.sendNewDeviceLoginNotification was not called')
assert.ok(!response.verified, 'response indicates account is not verified')
assert.ok(! response.verified, 'response indicates account is not verified')
assert.equal(response.verificationMethod, 'email', 'verificationMethod is email')
assert.equal(response.verificationReason, 'login', 'verificationReason is login')
@ -679,7 +679,7 @@ describe('/account/login', function () {
return runTest(route, mockRequestNoKeys, function (response) {
assert.equal(mockDB.createSessionToken.callCount, 1, 'db.createSessionToken was called')
var tokenData = mockDB.createSessionToken.getCall(0).args[0]
assert.ok(!tokenData.mustVerify, 'sessionToken does not have to be verified')
assert.ok(! tokenData.mustVerify, 'sessionToken does not have to be verified')
assert.ok(tokenData.tokenVerificationId, 'sessionToken was created unverified')
// Note that *neither* email is sent in this case,
// since it can't have been a new device connection.
@ -690,8 +690,8 @@ describe('/account/login', function () {
assert.deepEqual(mockMetricsContext.setFlowCompleteSignal.args[0][0], 'account.login', 'argument was event name')
assert.ok(response.verified, 'response indicates account is verified')
assert.ok(!response.verificationMethod, 'verificationMethod doesn\'t exist')
assert.ok(!response.verificationReason, 'verificationReason doesn\'t exist')
assert.ok(! response.verificationMethod, 'verificationMethod doesn\'t exist')
assert.ok(! response.verificationReason, 'verificationReason doesn\'t exist')
})
})
@ -720,7 +720,7 @@ describe('/account/login', function () {
assert.equal(mockMailer.sendVerifyCode.callCount, 1, 'mailer.sendVerifyCode was called')
assert.equal(mockMailer.sendNewDeviceLoginNotification.callCount, 0, 'mailer.sendNewDeviceLoginNotification was not called')
assert.equal(mockMailer.sendVerifyLoginEmail.callCount, 0, 'mailer.sendVerifyLoginEmail was not called')
assert.ok(!response.verified, 'response indicates account is not verified')
assert.ok(! response.verified, 'response indicates account is not verified')
assert.equal(response.verificationMethod, 'email', 'verificationMethod is email')
assert.equal(response.verificationReason, 'signup', 'verificationReason is signup')
assert.equal(response.emailSent, true, 'response indicates an email was sent')
@ -775,7 +775,7 @@ describe('/account/login', function () {
assert.ok(tokenData.tokenVerificationId, 'sessionToken was created unverified')
assert.equal(mockMailer.sendVerifyCode.callCount, 0, 'mailer.sendVerifyCode was not called')
assert.equal(mockMailer.sendNewDeviceLoginNotification.callCount, 0, 'mailer.sendNewDeviceLoginNotification was not called')
assert.ok(!response.verified, 'response indicates account is not verified')
assert.ok(! response.verified, 'response indicates account is not verified')
assert.equal(response.verificationMethod, 'email', 'verificationMethod is email')
assert.equal(response.verificationReason, 'login', 'verificationReason is login')
@ -810,7 +810,7 @@ describe('/account/login', function () {
assert.ok(tokenData.tokenVerificationId, 'sessionToken was created unverified')
assert.equal(mockMailer.sendVerifyLoginEmail.callCount, 1, 'mailer.sendVerifyLoginEmail was called')
assert.equal(mockMailer.sendNewDeviceLoginNotification.callCount, 0, 'mailer.sendNewDeviceLoginNotification was not called')
assert.ok(!response.verified, 'response indicates account is unverified')
assert.ok(! response.verified, 'response indicates account is unverified')
})
})
})
@ -868,7 +868,7 @@ describe('/account/login', function () {
assert.equal(securityQuery.uid, uid)
assert.equal(securityQuery.ipAddr, clientAddress)
assert.equal(!!record, true, 'log.info was called for Account.history')
assert.equal(!! record, true, 'log.info was called for Account.history')
assert.equal(record.op, 'Account.history.verified')
assert.equal(record.uid, uid.toString('hex'))
assert.equal(record.events, 1)
@ -894,7 +894,7 @@ describe('/account/login', function () {
assert.equal(securityQuery.uid, uid)
assert.equal(securityQuery.ipAddr, clientAddress)
assert.equal(!!record, true, 'log.info was called for Account.history')
assert.equal(!! record, true, 'log.info was called for Account.history')
assert.equal(record.op, 'Account.history.unverified')
assert.equal(record.uid, uid.toString('hex'))
assert.equal(record.events, 1)

Просмотреть файл

@ -116,7 +116,7 @@ describe('/account/login/send_unblock_code', function () {
it('signin unblock enabled', function () {
config.signinUnblock.enabled = true
return runTest(route, mockRequest, function (response) {
assert.ok(!(response instanceof Error), response.stack)
assert.ok(! (response instanceof Error), response.stack)
assert.deepEqual(response, {}, 'response has no keys')
assert.equal(mockDb.emailRecord.callCount, 1, 'db.emailRecord called')
@ -153,7 +153,7 @@ describe('/account/login/send_unblock_code', function () {
mockRequest.payload.email = 'UNBLOCK@example.com'
return runTest(route, mockRequest, function(response) {
assert.ok(!(response instanceof Error), response.stack)
assert.ok(! (response instanceof Error), response.stack)
assert.deepEqual(response, {}, 'response has no keys')
assert.equal(mockDb.emailRecord.callCount, 1, 'db.emailRecord called')
@ -181,7 +181,7 @@ describe('/account/login/reject_unblock_code', function () {
var route = getRoute(accountRoutes, '/account/login/reject_unblock_code')
return runTest(route, mockRequest, function (response) {
assert.ok(!(response instanceof Error), response.stack)
assert.ok(! (response instanceof Error), response.stack)
assert.deepEqual(response, {}, 'response has no keys')
assert.equal(mockDb.consumeUnblockCode.callCount, 1, 'consumeUnblockCode is called')

Просмотреть файл

@ -67,7 +67,7 @@ api.connection({
function loop(email, cb) {
var mail = users[email]
if (!mail) {
if (! mail) {
return setTimeout(loop.bind(null, email, cb), 50)
}
cb(mail)

Просмотреть файл

@ -45,7 +45,7 @@ module.exports = function (host, port, printLogs) {
return cb(e)
}
if(!json) {
if(! json) {
if (tries === 0) {
return cb(new Error('could not get mail for ' + url))
}

Просмотреть файл

@ -257,7 +257,7 @@ function mockDevices (data) {
function mockLog (methods) {
const log = extend({}, methods)
LOG_METHOD_NAMES.forEach((name) => {
if (!log[name]) {
if (! log[name]) {
log[name] = function() {}
}
})
@ -270,7 +270,7 @@ function spyLog (methods) {
methods = extend({}, methods)
methods.messages = methods.messages || []
LOG_METHOD_NAMES.forEach(name => {
if (!methods[name]) {
if (! methods[name]) {
// arrow function would alter `this` inside the method
methods[name] = function() {
this.messages.push({
@ -356,4 +356,3 @@ function mockRequest (data) {
validateMetricsContext: metricsContext.validate
}
}

Просмотреть файл

@ -20,7 +20,7 @@ var P = require('../lib/promise')
* @constructor
*/
function PushManager(options) {
if (!options || !options.server) {
if (! options || ! options.server) {
throw new Error('Server is required')
}

Просмотреть файл

@ -41,7 +41,7 @@ describe('remote account locale', function() {
)
.then(
function (response) {
assert.ok(!response.locale, 'account has no locale')
assert.ok(! response.locale, 'account has no locale')
return client.login()
}
)
@ -86,7 +86,7 @@ describe('remote account locale', function() {
)
.then(
function (response) {
assert.ok(!response.locale, 'account has no locale')
assert.ok(! response.locale, 'account has no locale')
}
)
}

Просмотреть файл

@ -164,7 +164,7 @@ describe('remote account profile', function() {
.then(
function (response) {
assert.ok(response.email, 'email address is returned')
assert.ok(!response.locale, 'locale should not be returned')
assert.ok(! response.locale, 'locale should not be returned')
}
)
.then(
@ -179,7 +179,7 @@ describe('remote account profile', function() {
)
.then(
function (response) {
assert.ok(!response.email, 'email address should not be returned')
assert.ok(! response.email, 'email address should not be returned')
assert.equal(response.locale, 'en-US', 'locale is returned')
}
)
@ -220,7 +220,7 @@ describe('remote account profile', function() {
)
.then(
function (response) {
assert.ok(!response.email, 'email address should not be returned')
assert.ok(! response.email, 'email address should not be returned')
assert.ok(response.locale, 'locale is returned')
}
)
@ -237,7 +237,7 @@ describe('remote account profile', function() {
.then(
function (response) {
assert.ok(response.email, 'email address is returned')
assert.ok(!response.locale, 'locale should not be returned')
assert.ok(! response.locale, 'locale should not be returned')
}
)
}

Просмотреть файл

@ -62,9 +62,9 @@ describe('remote account reset', function() {
)
.then(
function (response) {
assert(!response.sessionToken, 'session token is not in response')
assert(!response.keyFetchToken, 'keyFetchToken token is not in response')
assert(!response.verified, 'verified is not in response')
assert(! response.sessionToken, 'session token is not in response')
assert(! response.keyFetchToken, 'keyFetchToken token is not in response')
assert(! response.verified, 'verified is not in response')
}
)
.then(
@ -218,7 +218,7 @@ describe('remote account reset', function() {
.then(
function (response) {
assert.ok(response.sessionToken, 'session token is in response')
assert(!response.keyFetchToken, 'keyFetchToken token is not in response')
assert(! response.keyFetchToken, 'keyFetchToken token is not in response')
assert.equal(response.verified, true, 'verified is true')
}
)

Просмотреть файл

@ -62,8 +62,8 @@ describe('remote account signin verification', function() {
)
.then(
function (response) {
assert(!response.verificationMethod, 'no challenge method set')
assert(!response.verificationReason, 'no challenge reason set')
assert(! response.verificationMethod, 'no challenge method set')
assert(! response.verificationReason, 'no challenge reason set')
assert.equal(response.verified, true, 'verified set true')
}
)

Просмотреть файл

@ -65,7 +65,7 @@ describe('remote account status', function() {
)
.then(
function (response) {
assert.ok(!response.locale, 'locale is not present')
assert.ok(! response.locale, 'locale is not present')
}
)
}
@ -99,7 +99,7 @@ describe('remote account status', function() {
return api.accountStatus('0123456789ABCDEF0123456789ABCDEF')
.then(
function (response) {
assert.ok(!response.exists, 'account does not exist')
assert.ok(! response.exists, 'account does not exist')
}
)
}
@ -136,7 +136,7 @@ describe('remote account status', function() {
)
.then(
function (response) {
assert.ok(!response.exists, 'account does not exist')
assert.ok(! response.exists, 'account does not exist')
}
)
}

Просмотреть файл

@ -41,7 +41,7 @@ describe('remote concurrect', function() {
// Note that P.all fails fast when one of the requests fails,
// but we have to wait for *both* to complete before tearing
// down the test infrastructure. Bleh.
if (!r1.isRejected()) {
if (! r1.isRejected()) {
return r1
} else {
return r2

Просмотреть файл

@ -94,7 +94,7 @@ describe('remote db', function() {
assert.equal(account.emailVerified, ACCOUNT.emailVerified, 'emailVerified')
assert.deepEqual(account.kA, ACCOUNT.kA, 'kA')
assert.deepEqual(account.wrapWrapKb, ACCOUNT.wrapWrapKb, 'wrapWrapKb')
assert(!account.verifyHash, 'verifyHash')
assert(! account.verifyHash, 'verifyHash')
assert.deepEqual(account.authSalt, ACCOUNT.authSalt, 'authSalt')
assert.equal(account.verifierVersion, ACCOUNT.verifierVersion, 'verifierVersion')
assert.ok(account.createdAt, 'createdAt')

Просмотреть файл

@ -326,8 +326,8 @@ describe('remote password change', function() {
)
.then(
function (response) {
assert(!response.sessionToken, 'no session token returned')
assert(!response.keyFetchToken, 'no key fetch token returned')
assert(! response.sessionToken, 'no session token returned')
assert(! response.keyFetchToken, 'no key fetch token returned')
assert.notEqual(client.authPW.toString('hex'), firstAuthPW, 'password has changed')
}
)

Просмотреть файл

@ -44,7 +44,7 @@ function waitLoop(testServer, url, cb) {
console.log(err)
return cb(err)
}
if (!testServer.server) {
if (! testServer.server) {
if (testServer.printLogs) {
console.log('starting...')
}