Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit 2489d87

Browse files
committed
chore(lint): lint lib/
1 parent 9ac1daa commit 2489d87

File tree

3 files changed

+43
-43
lines changed

3 files changed

+43
-43
lines changed

lib/client/client.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -418,25 +418,25 @@ Client.prototype.modify = function modify (name, change, controls, callback) {
418418

419419
const changes = []
420420

421-
function changeFromObject (change) {
422-
if (!change.operation && !change.type) { throw new Error('change.operation required') }
423-
if (typeof (change.modification) !== 'object') { throw new Error('change.modification (object) required') }
421+
function changeFromObject (obj) {
422+
if (!obj.operation && !obj.type) { throw new Error('change.operation required') }
423+
if (typeof (obj.modification) !== 'object') { throw new Error('change.modification (object) required') }
424424

425-
if (Object.keys(change.modification).length === 2 &&
426-
typeof (change.modification.type) === 'string' &&
427-
Array.isArray(change.modification.vals)) {
425+
if (Object.keys(obj.modification).length === 2 &&
426+
typeof (obj.modification.type) === 'string' &&
427+
Array.isArray(obj.modification.vals)) {
428428
// Use modification directly if it's already normalized:
429429
changes.push(new Change({
430-
operation: change.operation || change.type,
431-
modification: change.modification
430+
operation: obj.operation || obj.type,
431+
modification: obj.modification
432432
}))
433433
} else {
434434
// Normalize the modification object
435-
Object.keys(change.modification).forEach(function (k) {
435+
Object.keys(obj.modification).forEach(function (k) {
436436
const mod = {}
437-
mod[k] = change.modification[k]
437+
mod[k] = obj.modification[k]
438438
changes.push(new Change({
439-
operation: change.operation || change.type,
439+
operation: obj.operation || obj.type,
440440
modification: mod
441441
}))
442442
})
@@ -679,9 +679,9 @@ Client.prototype.starttls = function starttls (options,
679679
return callback(new Error('STARTTLS already in progress or active'))
680680
}
681681

682-
function onSend (err, emitter) {
683-
if (err) {
684-
callback(err)
682+
function onSend (sendErr, emitter) {
683+
if (sendErr) {
684+
callback(sendErr)
685685
return
686686
}
687687
/*
@@ -850,9 +850,9 @@ Client.prototype.connect = function connect () {
850850
}
851851

852852
// Initialize socket events and LDAP parser.
853-
function initSocket (url) {
853+
function initSocket (server) {
854854
tracker = messageTrackerFactory({
855-
id: url ? url.href : self.socketPath,
855+
id: server ? server.href : self.socketPath,
856856
parser: new Parser({ log: log })
857857
})
858858

lib/client/message-tracker/id-generator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ const { MAX_MSGID } = require('../constants')
1616
module.exports = function idGeneratorFactory (start = 0) {
1717
let currentID = start
1818
return function nextID () {
19-
const nextID = currentID + 1
20-
currentID = (nextID >= MAX_MSGID) ? 1 : nextID
19+
const id = currentID + 1
20+
currentID = (id >= MAX_MSGID) ? 1 : id
2121
return currentID
2222
}
2323
}

lib/server.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -313,28 +313,28 @@ function Server (options) {
313313
return c
314314
}
315315

316-
function newConnection (c) {
317-
setupConnection(c)
318-
log.trace('new connection from %s', c.ldap.id)
316+
function newConnection (conn) {
317+
setupConnection(conn)
318+
log.trace('new connection from %s', conn.ldap.id)
319319

320320
dtrace.fire('server-connection', function () {
321-
return [c.remoteAddress]
321+
return [conn.remoteAddress]
322322
})
323323

324-
c.parser = new Parser({
324+
conn.parser = new Parser({
325325
log: options.log
326326
})
327-
c.parser.on('message', function (req) {
328-
req.connection = c
329-
req.logId = c.ldap.id + '::' + req.messageID
327+
conn.parser.on('message', function (req) {
328+
req.connection = conn
329+
req.logId = conn.ldap.id + '::' + req.messageID
330330
req.startTime = new Date().getTime()
331331

332-
log.debug('%s: message received: req=%j', c.ldap.id, req.json)
332+
log.debug('%s: message received: req=%j', conn.ldap.id, req.json)
333333

334334
const res = getResponse(req)
335335
if (!res) {
336336
log.warn('Unimplemented server method: %s', req.type)
337-
c.destroy()
337+
conn.destroy()
338338
return false
339339
}
340340

@@ -368,18 +368,18 @@ function Server (options) {
368368
}
369369
}
370370

371-
res.connection = c
371+
res.connection = conn
372372
res.logId = req.logId
373373
res.requestDN = req.dn
374374

375375
const chain = self._getHandlerChain(req, res)
376376

377377
let i = 0
378378
return (function messageIIFE (err) {
379-
function sendError (err) {
380-
res.status = err.code || errors.LDAP_OPERATIONS_ERROR
379+
function sendError (sendErr) {
380+
res.status = sendErr.code || errors.LDAP_OPERATIONS_ERROR
381381
res.matchedDN = req.suffix ? req.suffix.toString() : ''
382-
res.errorMessage = err.message || ''
382+
res.errorMessage = sendErr.message || ''
383383
return res.end()
384384
}
385385

@@ -388,8 +388,8 @@ function Server (options) {
388388

389389
function next () {} // stub out next for the post chain
390390

391-
self._postChain.forEach(function (c) {
392-
c.call(self, req, res, next)
391+
self._postChain.forEach(function (cb) {
392+
cb.call(self, req, res, next)
393393
})
394394
}
395395

@@ -404,7 +404,7 @@ function Server (options) {
404404
const next = messageIIFE
405405
if (chain.handlers[i]) { return chain.handlers[i++].call(chain.backend, req, res, next) }
406406

407-
if (req.protocolOp === Protocol.LDAP_REQ_BIND && res.status === 0) { c.ldap.bindDN = req.dn }
407+
if (req.protocolOp === Protocol.LDAP_REQ_BIND && res.status === 0) { conn.ldap.bindDN = req.dn }
408408

409409
return after()
410410
} catch (e) {
@@ -415,23 +415,23 @@ function Server (options) {
415415
}())
416416
})
417417

418-
c.parser.on('error', function (err, message) {
419-
self.emit('error', new VError(err, 'Parser error for %s', c.ldap.id))
418+
conn.parser.on('error', function (err, message) {
419+
self.emit('error', new VError(err, 'Parser error for %s', conn.ldap.id))
420420

421-
if (!message) { return c.destroy() }
421+
if (!message) { return conn.destroy() }
422422

423423
const res = getResponse(message)
424-
if (!res) { return c.destroy() }
424+
if (!res) { return conn.destroy() }
425425

426426
res.status = 0x02 // protocol error
427427
res.errorMessage = err.toString()
428-
return c.end(res.toBer())
428+
return conn.end(res.toBer())
429429
})
430430

431-
c.on('data', function (data) {
432-
log.trace('data on %s: %s', c.ldap.id, util.inspect(data))
431+
conn.on('data', function (data) {
432+
log.trace('data on %s: %s', conn.ldap.id, util.inspect(data))
433433

434-
c.parser.write(data)
434+
conn.parser.write(data)
435435
})
436436
} // end newConnection
437437

0 commit comments

Comments
 (0)