diff --git a/spec/MockStorageApi.js b/spec/MockStorageApi.js index b1ac4e2fb..691fccf3a 100644 --- a/spec/MockStorageApi.js +++ b/spec/MockStorageApi.js @@ -43,8 +43,8 @@ MockStorageApi.prototype = { let keys = []; for (let k in this.data) { if (!this.data.hasOwnProperty(k)) { - continue; -} + continue; + } keys.push(k); } this.keys = keys; diff --git a/spec/integ/matrix-client-event-emitter.spec.js b/spec/integ/matrix-client-event-emitter.spec.js index 14ab9c02c..24741c29a 100644 --- a/spec/integ/matrix-client-event-emitter.spec.js +++ b/spec/integ/matrix-client-event-emitter.spec.js @@ -144,8 +144,8 @@ describe("MatrixClient events", function() { expect(user).toBeDefined(); expect(event).toBeDefined(); if (!user || !event) { - return; -} + return; + } expect(event.event).toEqual(SYNC_DATA.presence.events[0]); expect(user.presence).toEqual( diff --git a/spec/integ/matrix-client-event-timeline.spec.js b/spec/integ/matrix-client-event-timeline.spec.js index 238494331..27ccec94d 100644 --- a/spec/integ/matrix-client-event-timeline.spec.js +++ b/spec/integ/matrix-client-event-timeline.spec.js @@ -123,9 +123,8 @@ describe("getEventTimeline support", function() { let room = client.getRoom(roomId); let timelineSet = room.getTimelineSets()[0]; expect(function() { - client.getEventTimeline(timelineSet, "event"); -}) - .toThrow(); + client.getEventTimeline(timelineSet, "event"); + }).toThrow(); }).catch(utils.failTest).done(done); }); @@ -142,9 +141,8 @@ describe("getEventTimeline support", function() { let room = client.getRoom(roomId); let timelineSet = room.getTimelineSets()[0]; expect(function() { - client.getEventTimeline(timelineSet, "event"); -}) - .not.toThrow(); + client.getEventTimeline(timelineSet, "event"); + }).not.toThrow(); }).catch(utils.failTest).done(done); httpBackend.flush().catch(utils.failTest); diff --git a/spec/integ/matrix-client-retrying.spec.js b/spec/integ/matrix-client-retrying.spec.js index db8120715..642b944e7 100644 --- a/spec/integ/matrix-client-retrying.spec.js +++ b/spec/integ/matrix-client-retrying.spec.js @@ -79,9 +79,8 @@ describe("MatrixClient retrying", function() { // shouldn't be able to cancel the first message yet expect(function() { - client.cancelPendingEvent(ev1); -}) - .toThrow(); + client.cancelPendingEvent(ev1); + }).toThrow(); }).respond(400); // fail the first message httpBackend.flush().then(function() { diff --git a/spec/integ/matrix-client-room-timeline.spec.js b/spec/integ/matrix-client-room-timeline.spec.js index acd8deb97..b1dc8bbf2 100644 --- a/spec/integ/matrix-client-room-timeline.spec.js +++ b/spec/integ/matrix-client-room-timeline.spec.js @@ -132,8 +132,8 @@ describe("MatrixClient room timelines", function() { "with EventStatus.SENDING and the right event.sender", function(done) { client.on("sync", function(state) { if (state !== "PREPARED") { - return; -} + return; + } let room = client.getRoom(roomId); expect(room.timeline.length).toEqual(1); @@ -170,8 +170,8 @@ describe("MatrixClient room timelines", function() { client.on("sync", function(state) { if (state !== "PREPARED") { - return; -} + return; + } let room = client.getRoom(roomId); client.sendTextMessage(roomId, "I am a fish", "txn1").done( function() { @@ -202,8 +202,8 @@ describe("MatrixClient room timelines", function() { client.on("sync", function(state) { if (state !== "PREPARED") { - return; -} + return; + } let room = client.getRoom(roomId); let promise = client.sendTextMessage(roomId, "I am a fish", "txn1"); httpBackend.flush("/sync", 1).done(function() { @@ -239,8 +239,8 @@ describe("MatrixClient room timelines", function() { " of the timeline.", function(done) { client.on("sync", function(state) { if (state !== "PREPARED") { - return; -} + return; + } let room = client.getRoom(roomId); expect(room.timeline.length).toEqual(1); @@ -299,8 +299,8 @@ describe("MatrixClient room timelines", function() { client.on("sync", function(state) { if (state !== "PREPARED") { - return; -} + return; + } let room = client.getRoom(roomId); // sync response expect(room.timeline.length).toEqual(1); @@ -335,8 +335,8 @@ describe("MatrixClient room timelines", function() { client.on("sync", function(state) { if (state !== "PREPARED") { - return; -} + return; + } let room = client.getRoom(roomId); expect(room.timeline.length).toEqual(1); @@ -363,8 +363,8 @@ describe("MatrixClient room timelines", function() { client.on("sync", function(state) { if (state !== "PREPARED") { - return; -} + return; + } let room = client.getRoom(roomId); expect(room.oldState.paginationToken).toBeDefined(); @@ -391,8 +391,8 @@ describe("MatrixClient room timelines", function() { client.on("sync", function(state) { if (state !== "PREPARED") { - return; -} + return; + } let room = client.getRoom(roomId); let index = 0; @@ -431,8 +431,8 @@ describe("MatrixClient room timelines", function() { client.on("sync", function(state) { if (state !== "PREPARED") { - return; -} + return; + } let room = client.getRoom(roomId); httpBackend.flush("/sync", 1).then(function() { let preNameEvent = room.timeline[room.timeline.length - 3]; @@ -455,8 +455,8 @@ describe("MatrixClient room timelines", function() { client.on("sync", function(state) { if (state !== "PREPARED") { - return; -} + return; + } let room = client.getRoom(roomId); let nameEmitCount = 0; client.on("Room.name", function(rm) { @@ -502,8 +502,8 @@ describe("MatrixClient room timelines", function() { client.on("sync", function(state) { if (state !== "PREPARED") { - return; -} + return; + } let room = client.getRoom(roomId); httpBackend.flush("/sync", 1).then(function() { expect(room.currentState.getMembers().length).toEqual(4); @@ -531,8 +531,8 @@ describe("MatrixClient room timelines", function() { client.on("sync", function(state) { if (state !== "PREPARED") { - return; -} + return; + } let room = client.getRoom(roomId); httpBackend.flush("/messages", 1); @@ -563,8 +563,8 @@ describe("MatrixClient room timelines", function() { client.on("sync", function(state) { if (state !== "PREPARED") { - return; -} + return; + } let room = client.getRoom(roomId); let emitCount = 0; diff --git a/spec/mock-request.js b/spec/mock-request.js index b8e644218..99df7e91c 100644 --- a/spec/mock-request.js +++ b/spec/mock-request.js @@ -91,8 +91,8 @@ HttpBackend.prototype = { for (j = 0; j < this.expectedRequests.length; j++) { expectedReq = this.expectedRequests[j]; if (path && path !== expectedReq.path) { - continue; -} + continue; + } if (expectedReq.method === req.method && req.path.indexOf(expectedReq.path) !== -1) { if (!expectedReq.data || (JSON.stringify(expectedReq.data) === @@ -242,32 +242,32 @@ function Request(opts, callback) { Object.defineProperty(this, 'method', { get: function() { - return opts.method; -}, + return opts.method; + }, }); Object.defineProperty(this, 'path', { get: function() { - return opts.uri; -}, + return opts.uri; + }, }); Object.defineProperty(this, 'data', { get: function() { - return opts.body; -}, + return opts.body; + }, }); Object.defineProperty(this, 'queryParams', { get: function() { - return opts.qs; -}, + return opts.qs; + }, }); Object.defineProperty(this, 'headers', { get: function() { - return opts.headers || {}; -}, + return opts.headers || {}; + }, }); } diff --git a/spec/test-utils.js b/spec/test-utils.js index 107a70b16..b5d53df83 100644 --- a/spec/test-utils.js +++ b/spec/test-utils.js @@ -122,11 +122,11 @@ module.exports.mkMembership = function(opts) { membership: opts.mship, }; if (opts.name) { - opts.content.displayname = opts.name; -} + opts.content.displayname = opts.name; + } if (opts.url) { - opts.content.avatar_url = opts.url; -} + opts.content.avatar_url = opts.url; + } return module.exports.mkEvent(opts); }; diff --git a/spec/unit/event-timeline.spec.js b/spec/unit/event-timeline.spec.js index 3fac91796..9876b8c76 100644 --- a/spec/unit/event-timeline.spec.js +++ b/spec/unit/event-timeline.spec.js @@ -20,8 +20,8 @@ describe("EventTimeline", function() { // XXX: this is a horrid hack; should use sinon or something instead to mock let timelineSet = { room: { roomId: roomId }}; timelineSet.room.getUnfilteredTimelineSet = function() { - return timelineSet; -}; + return timelineSet; + }; timeline = new EventTimeline(timelineSet); }); @@ -74,12 +74,12 @@ describe("EventTimeline", function() { ]; expect(function() { - timeline.initialiseState(state); -}).not.toThrow(); + timeline.initialiseState(state); + }).not.toThrow(); timeline.addEvent(event, false); expect(function() { - timeline.initialiseState(state); -}).toThrow(); + timeline.initialiseState(state); + }).toThrow(); }); }); diff --git a/spec/unit/realtime-callbacks.spec.js b/spec/unit/realtime-callbacks.spec.js index ddc5d5758..29e551bd6 100644 --- a/spec/unit/realtime-callbacks.spec.js +++ b/spec/unit/realtime-callbacks.spec.js @@ -18,8 +18,8 @@ describe("realtime-callbacks", function() { clock.useMock(); fakeDate = Date.now(); callbacks.setNow(function() { - return fakeDate; -}); + return fakeDate; + }); }); afterEach(function() { diff --git a/spec/unit/room-member.spec.js b/spec/unit/room-member.spec.js index 76abe2793..6cd3ab109 100644 --- a/spec/unit/room-member.spec.js +++ b/spec/unit/room-member.spec.js @@ -221,8 +221,8 @@ describe("RoomMember", function() { let roomState = { getStateEvents: function(type) { if (type !== "m.room.member") { - return []; -} + return []; + } return [ utils.mkMembership({ event: true, mship: "join", room: roomId, diff --git a/spec/unit/room.spec.js b/spec/unit/room.spec.js index 1d5d2e216..599dbbc2a 100644 --- a/spec/unit/room.spec.js +++ b/spec/unit/room.spec.js @@ -106,8 +106,8 @@ describe("Room", function() { it("should throw if duplicateStrategy isn't 'replace' or 'ignore'", function() { expect(function() { - room.addLiveEvents(events, "foo"); -}).toThrow(); + room.addLiveEvents(events, "foo"); + }).toThrow(); }); it("should replace a timeline event if dupe strategy is 'replace'", function() { @@ -616,8 +616,8 @@ describe("Room", function() { }; let setAliases = function(aliases, stateKey) { if (!stateKey) { - stateKey = "flibble"; -} + stateKey = "flibble"; + } stateLookup["m.room.aliases$" + stateKey] = utils.mkEvent({ type: "m.room.aliases", room: roomId, skey: stateKey, content: { aliases: aliases, @@ -633,8 +633,8 @@ describe("Room", function() { }; let addMember = function(userId, state, opts) { if (!state) { - state = "join"; -} + state = "join"; + } opts = opts || {}; opts.room = roomId; opts.mship = state; @@ -652,8 +652,8 @@ describe("Room", function() { let list = []; for (let stateBlob in stateLookup) { if (!stateLookup.hasOwnProperty(stateBlob)) { - continue; -} + continue; + } if (stateBlob.indexOf(prefix) === 0) { list.push(stateLookup[stateBlob]); } @@ -915,11 +915,11 @@ describe("Room", function() { let content = {}; records.forEach(function(r) { if (!content[r.eventId]) { - content[r.eventId] = {}; -} + content[r.eventId] = {}; + } if (!content[r.eventId][r.type]) { - content[r.eventId][r.type] = {}; -} + content[r.eventId][r.type] = {}; + } content[r.eventId][r.type][r.userId] = { ts: r.ts, }; diff --git a/spec/unit/scheduler.spec.js b/spec/unit/scheduler.spec.js index 6c4ab34cc..cf50c36df 100644 --- a/spec/unit/scheduler.spec.js +++ b/spec/unit/scheduler.spec.js @@ -76,8 +76,8 @@ describe("MatrixScheduler", function() { return waitTimeMs; }; queueFn = function() { - return "yep"; -}; + return "yep"; + }; let procCount = 0; scheduler.setProcessFunction(function(ev) { diff --git a/spec/unit/timeline-window.spec.js b/spec/unit/timeline-window.spec.js index 5e5ca862c..2906d7807 100644 --- a/spec/unit/timeline-window.spec.js +++ b/spec/unit/timeline-window.spec.js @@ -16,17 +16,17 @@ let USER_ID = "userId"; */ function createTimeline(numEvents, baseIndex) { if (numEvents === undefined) { - numEvents = 3; -} + numEvents = 3; + } if (baseIndex === undefined) { - baseIndex = 1; -} + baseIndex = 1; + } // XXX: this is a horrid hack let timelineSet = { room: { roomId: ROOM_ID }}; timelineSet.room.getUnfilteredTimelineSet = function() { - return timelineSet; -}; + return timelineSet; + }; let timeline = new EventTimeline(timelineSet); @@ -167,8 +167,8 @@ describe("TimelineWindow", function() { let liveTimeline = createTimeline(); let room = {}; room.getLiveTimeline = function() { - return liveTimeline; -}; + return liveTimeline; + }; let timelineWindow = new TimelineWindow(undefined, room); timelineWindow.load(undefined, 2).then(function() { diff --git a/spec/unit/utils.spec.js b/spec/unit/utils.spec.js index 55808b9e9..626820907 100644 --- a/spec/unit/utils.spec.js +++ b/spec/unit/utils.spec.js @@ -45,22 +45,22 @@ describe("utils", function() { describe("findElement", function() { it("should find only 1 element if there is a match", function() { let matchFn = function() { - return true; -}; + return true; + }; let arr = [55, 66, 77]; expect(utils.findElement(arr, matchFn)).toEqual(55); }); it("should be able to find in reverse order", function() { let matchFn = function() { - return true; -}; + return true; + }; let arr = [55, 66, 77]; expect(utils.findElement(arr, matchFn, true)).toEqual(77); }); it("should find nothing if the function never returns true", function() { let matchFn = function() { - return false; -}; + return false; + }; let arr = [55, 66, 77]; expect(utils.findElement(arr, matchFn)).toBeFalsy(); }); @@ -69,24 +69,24 @@ describe("utils", function() { describe("removeElement", function() { it("should remove only 1 element if there is a match", function() { let matchFn = function() { - return true; -}; + return true; + }; let arr = [55, 66, 77]; utils.removeElement(arr, matchFn); expect(arr).toEqual([66, 77]); }); it("should be able to remove in reverse order", function() { let matchFn = function() { - return true; -}; + return true; + }; let arr = [55, 66, 77]; utils.removeElement(arr, matchFn, true); expect(arr).toEqual([55, 66]); }); it("should remove nothing if the function never returns true", function() { let matchFn = function() { - return false; -}; + return false; + }; let arr = [55, 66, 77]; utils.removeElement(arr, matchFn); expect(arr).toEqual(arr); @@ -126,41 +126,41 @@ describe("utils", function() { describe("checkObjectHasKeys", function() { it("should throw for missing keys", function() { expect(function() { - utils.checkObjectHasKeys({}, ["foo"]); -}).toThrow(); + utils.checkObjectHasKeys({}, ["foo"]); + }).toThrow(); expect(function() { - utils.checkObjectHasKeys({ - foo: "bar", - }, ["foo"]); -}).not.toThrow(); + utils.checkObjectHasKeys({ + foo: "bar", + }, ["foo"]); + }).not.toThrow(); }); }); describe("checkObjectHasNoAdditionalKeys", function() { it("should throw for extra keys", function() { expect(function() { - utils.checkObjectHasNoAdditionalKeys({ - foo: "bar", - baz: 4, - }, ["foo"]); -}).toThrow(); + utils.checkObjectHasNoAdditionalKeys({ + foo: "bar", + baz: 4, + }, ["foo"]); + }).toThrow(); expect(function() { - utils.checkObjectHasNoAdditionalKeys({ - foo: "bar", - }, ["foo"]); -}).not.toThrow(); + utils.checkObjectHasNoAdditionalKeys({ + foo: "bar", + }, ["foo"]); + }).not.toThrow(); }); }); describe("deepCompare", function() { let assert = { isTrue: function(x) { - expect(x).toBe(true); -}, + expect(x).toBe(true); + }, isFalse: function(x) { - expect(x).toBe(false); -}, + expect(x).toBe(false); + }, }; it("should handle primitives", function() { @@ -217,11 +217,11 @@ describe("utils", function() { // context variables so even if they have same toString(), they // won't have same functionality let func = function(x) { - return true; -}; + return true; + }; let func2 = function(x) { - return true; -}; + return true; + }; assert.isTrue(utils.deepCompare(func, func)); assert.isFalse(utils.deepCompare(func, func2)); assert.isTrue(utils.deepCompare({ a: { b: func } }, { a: { b: func } })); diff --git a/src/base-apis.js b/src/base-apis.js index 88f4239e4..76c64a545 100644 --- a/src/base-apis.js +++ b/src/base-apis.js @@ -136,24 +136,24 @@ MatrixBaseApis.prototype.register = function( callback ) { if (auth === undefined) { - auth = {}; -} + auth = {}; + } if (sessionId) { - auth.session = sessionId; -} + auth.session = sessionId; + } let params = { auth: auth, }; if (username !== undefined && username !== null) { - params.username = username; -} + params.username = username; + } if (password !== undefined && password !== null) { - params.password = password; -} + params.password = password; + } if (bindEmail !== undefined && bindEmail !== null) { - params.bind_email = bindEmail; -} + params.bind_email = bindEmail; + } if (guestAccessToken !== undefined && guestAccessToken !== null) { params.guest_access_token = guestAccessToken; } @@ -185,8 +185,8 @@ MatrixBaseApis.prototype.registerGuest = function(opts, callback) { MatrixBaseApis.prototype.registerRequest = function(data, kind, callback) { let params = {}; if (kind) { - params.kind = kind; -} + params.kind = kind; + } return this._http.request( callback, "POST", "/register", params, data @@ -435,8 +435,8 @@ MatrixBaseApis.prototype.redactEvent = function(roomId, eventId, callback) { */ MatrixBaseApis.prototype.roomInitialSync = function(roomId, limit, callback) { if (utils.isFunction(limit)) { - callback = limit; limit = undefined; -} + callback = limit; limit = undefined; + } let path = utils.encodeUri("/rooms/$roomId/initialSync", {$roomId: roomId} ); @@ -689,8 +689,8 @@ MatrixBaseApis.prototype.getCurrentUploads = function() { */ MatrixBaseApis.prototype.getProfileInfo = function(userId, info, callback) { if (utils.isFunction(info)) { - callback = info; info = undefined; -} + callback = info; info = undefined; + } let path = info ? utils.encodeUri("/profile/$userId/$info", diff --git a/src/client.js b/src/client.js index 8d6f8e94e..de8cfb19e 100644 --- a/src/client.js +++ b/src/client.js @@ -212,8 +212,8 @@ MatrixClient.prototype.supportsVoip = function() { */ MatrixClient.prototype.getSyncState = function() { if (!this._syncApi) { - return null; -} + return null; + } return this._syncApi.getSyncState(); }; @@ -589,8 +589,8 @@ MatrixClient.prototype.joinRoom = function(roomIdOrAlias, opts, callback) { } opts = opts || {}; if (opts.syncRoom === undefined) { - opts.syncRoom = true; -} + opts.syncRoom = true; + } let room = this.getRoom(roomIdOrAlias); if (room && room.hasMembershipState(this.credentials.userId, "join")) { @@ -807,8 +807,8 @@ MatrixClient.prototype.setPowerLevel = function(roomId, userId, powerLevel, MatrixClient.prototype.sendEvent = function(roomId, eventType, content, txnId, callback) { if (utils.isFunction(txnId)) { - callback = txnId; txnId = undefined; -} + callback = txnId; txnId = undefined; + } if (!txnId) { txnId = this.makeTxnId(); @@ -950,8 +950,8 @@ function _sendEventHttpRequest(client, event) { */ MatrixClient.prototype.sendMessage = function(roomId, content, txnId, callback) { if (utils.isFunction(txnId)) { - callback = txnId; txnId = undefined; -} + callback = txnId; txnId = undefined; + } return this.sendEvent( roomId, "m.room.message", content, txnId, callback ); @@ -1016,11 +1016,11 @@ MatrixClient.prototype.sendEmoteMessage = function(roomId, body, txnId, callback */ MatrixClient.prototype.sendImageMessage = function(roomId, url, info, text, callback) { if (utils.isFunction(text)) { - callback = text; text = undefined; -} + callback = text; text = undefined; + } if (!text) { - text = "Image"; -} + text = "Image"; + } let content = { msgtype: "m.image", url: url, @@ -1340,8 +1340,8 @@ MatrixClient.prototype.kick = function(roomId, userId, reason, callback) { function _setMembershipState(client, roomId, userId, membershipValue, reason, callback) { if (utils.isFunction(reason)) { - callback = reason; reason = undefined; -} + callback = reason; reason = undefined; + } let path = utils.encodeUri( "/rooms/$roomId/state/m.room.member/$userId", @@ -1367,8 +1367,8 @@ function _setMembershipState(client, roomId, userId, membershipValue, reason, */ function _membershipChange(client, roomId, userId, membership, reason, callback) { if (utils.isFunction(reason)) { - callback = reason; reason = undefined; -} + callback = reason; reason = undefined; + } let path = utils.encodeUri("/rooms/$room_id/$membership", { $room_id: roomId, @@ -1547,8 +1547,8 @@ MatrixClient.prototype.dropFromPresenceList = function(callback, userIds) { */ MatrixClient.prototype.scrollback = function(room, limit, callback) { if (utils.isFunction(limit)) { - callback = limit; limit = undefined; -} + callback = limit; limit = undefined; + } limit = limit || 30; let timeToWaitMs = 0; @@ -2326,11 +2326,11 @@ MatrixClient.prototype._processRoomEventsSearch = function(searchResults, respon // to avoid O(N^2) fail let highlights = {}; room_events.highlights.forEach(function(hl) { - highlights[hl] = 1; -}); + highlights[hl] = 1; + }); searchResults.highlights.forEach(function(hl) { - highlights[hl] = 1; -}); + highlights[hl] = 1; + }); // turn it back into a list. searchResults.highlights = Object.keys(highlights); @@ -2842,12 +2842,9 @@ function checkTurnServers(client) { }; client._turnServers = [servers]; // re-fetch when we're about to reach the TTL - client._checkTurnServersTimeoutID = - setTimeout(function() { - checkTurnServers(client); -}, - (res.ttl || (60 * 60)) * 1000 * 0.9 - ); + client._checkTurnServersTimeoutID = setTimeout(() => { + checkTurnServers(client); + }, (res.ttl || (60 * 60)) * 1000 * 0.9); } }, function(err) { console.error("Failed to get TURN URIs"); diff --git a/src/content-repo.js b/src/content-repo.js index a2e0912f5..124e4ca27 100644 --- a/src/content-repo.js +++ b/src/content-repo.js @@ -89,11 +89,11 @@ module.exports = { return null; } if (!width) { - width = 96; -} + width = 96; + } if (!height) { - height = 96; -} + height = 96; + } let params = { width: width, height: height, diff --git a/src/crypto/algorithms/megolm.js b/src/crypto/algorithms/megolm.js index 7682089fe..7962bdeb1 100644 --- a/src/crypto/algorithms/megolm.js +++ b/src/crypto/algorithms/megolm.js @@ -90,8 +90,8 @@ OutboundSessionInfo.prototype.sharedWithTooManyDevices = function( ) { for (let userId in this.sharedWithDevices) { if (!this.sharedWithDevices.hasOwnProperty(userId)) { - continue; -} + continue; + } if (!devicesInRoom.hasOwnProperty(userId)) { console.log("Starting new session because we shared with " + userId); @@ -226,8 +226,8 @@ MegolmEncryption.prototype._ensureOutboundSession = function(devicesInRoom) { // helper which returns the session prepared by prepareSession function returnSession() { - return session; -} + return session; + } // first wait for the previous share to complete let prom = this._setupPromise.then(prepareSession); diff --git a/src/crypto/index.js b/src/crypto/index.js index ae35bede2..6e54d936a 100644 --- a/src/crypto/index.js +++ b/src/crypto/index.js @@ -363,8 +363,8 @@ Crypto.prototype._doKeyDownloadForUsers = function(downloadUsers) { let promise = deferred.promise.finally(function() { let inProgress = self._keyDownloadsInProgressByUser[u]; utils.removeElement(inProgress, function(e) { - return e === promise; -}); + return e === promise; + }); if (inProgress.length === 0) { // no more downloads for this user; remove the element delete self._keyDownloadsInProgressByUser[u]; @@ -614,11 +614,11 @@ Crypto.prototype.listDeviceKeys = function(userId) { // sort by deviceid result.sort(function(a, b) { if (a.deviceId < b.deviceId) { - return -1; -} + return -1; + } if (a.deviceId > b.deviceId) { - return 1; -} + return 1; + } return 0; }); diff --git a/src/crypto/olmlib.js b/src/crypto/olmlib.js index c02ac5420..0a731e82a 100644 --- a/src/crypto/olmlib.js +++ b/src/crypto/olmlib.js @@ -128,8 +128,8 @@ module.exports.ensureOlmSessionsForDevices = function( for (let userId in devicesByUser) { if (!devicesByUser.hasOwnProperty(userId)) { - continue; -} + continue; + } result[userId] = {}; let devices = devicesByUser[userId]; for (let j = 0; j < devices.length; j++) { @@ -164,8 +164,8 @@ module.exports.ensureOlmSessionsForDevices = function( let otk_res = res.one_time_keys || {}; for (let userId in devicesByUser) { if (!devicesByUser.hasOwnProperty(userId)) { - continue; -} + continue; + } let userRes = otk_res[userId] || {}; let devices = devicesByUser[userId]; for (let j = 0; j < devices.length; j++) { diff --git a/src/filter-component.js b/src/filter-component.js index bb2133698..b0c56479b 100644 --- a/src/filter-component.js +++ b/src/filter-component.js @@ -86,14 +86,14 @@ FilterComponent.prototype._checkFields = function(room_id, sender, event_type, contains_url) { let literal_keys = { "rooms": function(v) { - return room_id === v; -}, + return room_id === v; + }, "senders": function(v) { - return sender === v; -}, + return sender === v; + }, "types": function(v) { - return _matches_wildcard(event_type, v); -}, + return _matches_wildcard(event_type, v); + }, }; let self = this; diff --git a/src/http-api.js b/src/http-api.js index 35a0330f1..c26458690 100644 --- a/src/http-api.js +++ b/src/http-api.js @@ -617,8 +617,8 @@ module.exports.MatrixHttpApi.prototype = { if (this.opts.extraParams) { for (let key in this.opts.extraParams) { if (!this.opts.extraParams.hasOwnProperty(key)) { - continue; -} + continue; + } queryParams[key] = this.opts.extraParams[key]; } } diff --git a/src/models/event-timeline-set.js b/src/models/event-timeline-set.js index 696135e24..911a4046d 100644 --- a/src/models/event-timeline-set.js +++ b/src/models/event-timeline-set.js @@ -170,12 +170,12 @@ EventTimelineSet.prototype.resetLiveTimeline = function(backPaginationToken, flu let events = []; for (let evtype in evMap) { if (!evMap.hasOwnProperty(evtype)) { - continue; -} + continue; + } for (let stateKey in evMap[evtype]) { if (!evMap[evtype].hasOwnProperty(stateKey)) { - continue; -} + continue; + } events.push(evMap[evtype][stateKey]); } } @@ -213,10 +213,9 @@ EventTimelineSet.prototype.findEventById = function(eventId) { if (!tl) { return undefined; } - return utils.findElement(tl.getEvents(), - function(ev) { - return ev.getId() == eventId; -}); + return utils.findElement(tl.getEvents(), function(ev) { + return ev.getId() == eventId; + }); }; /** diff --git a/src/models/event-timeline.js b/src/models/event-timeline.js index bcc943b46..e9b574bef 100644 --- a/src/models/event-timeline.js +++ b/src/models/event-timeline.js @@ -78,11 +78,12 @@ EventTimeline.prototype.initialiseState = function(stateEvents) { let oldStateEvents = utils.map( utils.deepCopy( stateEvents.map(function(mxEvent) { - return mxEvent.event; -}) - ), function(ev) { - return new MatrixEvent(ev); -}); + return mxEvent.event; + }) + ), + function(ev) { + return new MatrixEvent(ev); + }); this._startState.setStateEvents(oldStateEvents); this._endState.setStateEvents(stateEvents); diff --git a/src/models/event.js b/src/models/event.js index 03864f2c7..38686239c 100644 --- a/src/models/event.js +++ b/src/models/event.js @@ -343,8 +343,8 @@ utils.extend(module.exports.MatrixEvent.prototype, { let key; for (key in this.event) { if (!this.event.hasOwnProperty(key)) { - continue; -} + continue; + } if (!_REDACT_KEEP_KEY_MAP[key]) { delete this.event[key]; } @@ -354,8 +354,8 @@ utils.extend(module.exports.MatrixEvent.prototype, { let content = this.getContent(); for (key in content) { if (!content.hasOwnProperty(key)) { - continue; -} + continue; + } if (!keeps[key]) { delete content[key]; } @@ -428,7 +428,7 @@ let _REDACT_KEEP_KEY_MAP = [ 'event_id', 'type', 'room_id', 'user_id', 'state_key', 'prev_state', 'content', 'unsigned', ].reduce(function(ret, val) { - ret[val] = 1; return ret; + ret[val] = 1; return ret; }, {}); // a map from event type to the .content keys we keep when an event is redacted diff --git a/src/models/room-member.js b/src/models/room-member.js index a1c80dcbd..f749e92e0 100644 --- a/src/models/room-member.js +++ b/src/models/room-member.js @@ -190,8 +190,8 @@ RoomMember.prototype.getLastModifiedTime = function() { RoomMember.prototype.getAvatarUrl = function(baseUrl, width, height, resizeMethod, allowDefault, allowDirectLinks) { if (allowDefault === undefined) { - allowDefault = true; -} + allowDefault = true; + } if (!this.events.member && !allowDefault) { return null; } diff --git a/src/models/room-state.js b/src/models/room-state.js index 5fda628bc..6becc8bc3 100644 --- a/src/models/room-state.js +++ b/src/models/room-state.js @@ -121,11 +121,11 @@ RoomState.prototype.setStateEvents = function(stateEvents) { // update the core event dict utils.forEach(stateEvents, function(event) { if (event.getRoomId() !== self.roomId) { - return; -} + return; + } if (!event.isState()) { - return; -} + return; + } if (self.events[event.getType()] === undefined) { self.events[event.getType()] = {}; @@ -146,11 +146,11 @@ RoomState.prototype.setStateEvents = function(stateEvents) { // clashing names rather than progressively which only catches 1 of them). utils.forEach(stateEvents, function(event) { if (event.getRoomId() !== self.roomId) { - return; -} + return; + } if (!event.isState()) { - return; -} + return; + } if (event.getType() === "m.room.member") { let userId = event.getStateKey(); @@ -314,8 +314,8 @@ RoomState.prototype.maySendStateEvent = function(stateEventType, userId) { RoomState.prototype._maySendEventOfType = function(eventType, userId, state) { let member = this.getMember(userId); if (!member || member.membership == 'leave') { - return false; -} + return false; + } let power_levels_event = this.getStateEvents('m.room.power_levels', ''); diff --git a/src/models/room.js b/src/models/room.js index b3a526fc2..bf4baddac 100644 --- a/src/models/room.js +++ b/src/models/room.js @@ -310,8 +310,8 @@ Room.prototype.getAvatarUrl = function(baseUrl, width, height, resizeMethod, allowDefault) { let roomAvatarEvent = this.currentState.getStateEvents("m.room.avatar", ""); if (allowDefault === undefined) { - allowDefault = true; -} + allowDefault = true; + } if (!roomAvatarEvent && !allowDefault) { return null; } @@ -668,9 +668,8 @@ Room.prototype._handleRemoteEcho = function(remoteEvent, localEvent) { utils.removeElement( this._pendingEventList, function(ev) { - return ev.getId() == oldEventId; -}, - false + return ev.getId() == oldEventId; + }, false ); } @@ -778,9 +777,8 @@ Room.prototype.updatePendingEvent = function(event, newStatus, newEventId) { utils.removeElement( this._pendingEventList, function(ev) { - return ev.getId() == oldEventId; -}, - false + return ev.getId() == oldEventId; + }, false ); } this.removeEvent(oldEventId); @@ -985,8 +983,8 @@ Room.prototype.addReceipt = function(event, fake) { // } // } if (fake === undefined) { - fake = false; -} + fake = false; + } if (!fake) { this._addReceiptsToStructure(event, this._realReceipts); // we don't bother caching real receipts by event ID diff --git a/src/pushprocessor.js b/src/pushprocessor.js index 8afd53ac2..f8cb110c4 100644 --- a/src/pushprocessor.js +++ b/src/pushprocessor.js @@ -38,13 +38,13 @@ function PushProcessor(client) { for (let ruleIndex = 0; ruleIndex < ruleset.length; ++ruleIndex) { let rule = ruleset[ruleIndex]; if (!rule.enabled) { - continue; -} + continue; + } let rawrule = templateRuleToRaw(kind, rule, device); if (!rawrule) { - continue; -} + continue; + } if (ruleMatchesEvent(rawrule, ev)) { rule.kind = kind; @@ -68,8 +68,8 @@ function PushProcessor(client) { break; case 'room': if (!tprule.rule_id) { - return null; -} + return null; + } rawrule.conditions.push({ 'kind': 'event_match', 'key': 'room_id', @@ -78,8 +78,8 @@ function PushProcessor(client) { break; case 'sender': if (!tprule.rule_id) { - return null; -} + return null; + } rawrule.conditions.push({ 'kind': 'event_match', 'key': 'user_id', @@ -88,8 +88,8 @@ function PushProcessor(client) { break; case 'content': if (!tprule.pattern) { - return null; -} + return null; + } rawrule.conditions.push({ 'kind': 'event_match', 'key': 'content.body', @@ -131,13 +131,13 @@ function PushProcessor(client) { let eventFulfillsRoomMemberCountCondition = function(cond, ev) { if (!cond.is) { - return false; -} + return false; + } let room = client.getRoom(ev.getRoomId()); if (!room || !room.currentState || !room.currentState.members) { - return false; -} + return false; + } let memberCount = Object.keys(room.currentState.members).filter(function(m) { return room.currentState.members[m].membership == 'join'; @@ -145,13 +145,13 @@ function PushProcessor(client) { let m = cond.is.match(/^([=<>]*)([0-9]*)$/); if (!m) { - return false; -} + return false; + } let ineq = m[1]; let rhs = parseInt(m[2]); if (isNaN(rhs)) { - return false; -} + return false; + } switch (ineq) { case '': case '==': @@ -178,8 +178,8 @@ function PushProcessor(client) { let room = client.getRoom(ev.getRoomId()); if (!room || !room.currentState || !room.currentState.members || !room.currentState.getMember(client.credentials.userId)) { - return false; -} + return false; + } let displayName = room.currentState.getMember(client.credentials.userId).name; @@ -196,8 +196,8 @@ function PushProcessor(client) { let eventFulfillsEventMatchCondition = function(cond, ev) { let val = valueForDottedKey(cond.key, ev); if (!val || typeof val != 'string') { - return false; -} + return false; + } let pat; if (cond.key == 'content.body') { @@ -245,8 +245,8 @@ function PushProcessor(client) { while (parts.length > 0) { let thispart = parts.shift(); if (!val[thispart]) { - return null; -} + return null; + } val = val[thispart]; } return val; @@ -254,11 +254,11 @@ function PushProcessor(client) { let matchingRuleForEventWithRulesets = function(ev, rulesets) { if (!rulesets || !rulesets.device) { - return null; -} + return null; + } if (ev.getSender() == client.credentials.userId) { - return null; -} + return null; + } let allDevNames = Object.keys(rulesets.device); for (let i = 0; i < allDevNames.length; ++i) { @@ -267,8 +267,8 @@ function PushProcessor(client) { let matchingRule = matchingRuleFromKindSet(devrules, devname); if (matchingRule) { - return matchingRule; -} + return matchingRule; + } } return matchingRuleFromKindSet(ev, rulesets.global); }; @@ -276,8 +276,8 @@ function PushProcessor(client) { let pushActionsForEventAndRulesets = function(ev, rulesets) { let rule = matchingRuleForEventWithRulesets(ev, rulesets); if (!rule) { - return {}; -} + return {}; + } let actionObj = PushProcessor.actionListToActionsObject(rule.actions); @@ -319,8 +319,8 @@ PushProcessor.actionListToActionsObject = function(actionlist) { actionobj.notify = true; } else if (typeof action === 'object') { if (action.value === undefined) { - action.value = true; -} + action.value = true; + } actionobj.tweaks[action.set_tweak] = action.value; } } diff --git a/src/store/memory.js b/src/store/memory.js index 93b48e88a..c91651efa 100644 --- a/src/store/memory.js +++ b/src/store/memory.js @@ -203,8 +203,8 @@ module.exports.MatrixInMemoryStore.prototype = { */ storeFilter: function(filter) { if (!filter) { - return; -} + return; + } if (!this.filters[filter.userId]) { this.filters[filter.userId] = {}; } diff --git a/src/sync.js b/src/sync.js index 9742a2dd3..f0a00eb20 100644 --- a/src/sync.js +++ b/src/sync.js @@ -46,8 +46,8 @@ function getFilterName(userId, suffix) { function debuglog() { if (!DEBUG) { - return; -} + return; + } console.log(...arguments); } @@ -437,8 +437,8 @@ SyncApi.prototype.stop = function() { } this._running = false; if (this._currentSyncRequest) { - this._currentSyncRequest.abort(); -} + this._currentSyncRequest.abort(); + } if (this._keepAliveTimer) { clearTimeout(this._keepAliveTimer); this._keepAliveTimer = null; @@ -452,8 +452,8 @@ SyncApi.prototype.stop = function() { */ SyncApi.prototype.retryImmediately = function() { if (!this._connectionReturnedDefer) { - return false; -} + return false; + } this._startKeepAlives(0); return true; }; @@ -703,8 +703,8 @@ SyncApi.prototype._processSyncResponse = function(syncToken, data) { client.emit("Room", room); } stateEvents.forEach(function(e) { - client.emit("event", e); -}); + client.emit("event", e); + }); }); // Handle joins @@ -803,17 +803,17 @@ SyncApi.prototype._processSyncResponse = function(syncToken, data) { client.emit("Room", room); } stateEvents.forEach(function(e) { - client.emit("event", e); -}); + client.emit("event", e); + }); timelineEvents.forEach(function(e) { - client.emit("event", e); -}); + client.emit("event", e); + }); ephemeralEvents.forEach(function(e) { - client.emit("event", e); -}); + client.emit("event", e); + }); accountDataEvents.forEach(function(e) { - client.emit("event", e); -}); + client.emit("event", e); + }); }); // Handle leaves (e.g. kicked rooms) @@ -836,14 +836,14 @@ SyncApi.prototype._processSyncResponse = function(syncToken, data) { } stateEvents.forEach(function(e) { - client.emit("event", e); -}); + client.emit("event", e); + }); timelineEvents.forEach(function(e) { - client.emit("event", e); -}); + client.emit("event", e); + }); accountDataEvents.forEach(function(e) { - client.emit("event", e); -}); + client.emit("event", e); + }); }); // update the notification timeline, if appropriate. @@ -1044,8 +1044,8 @@ SyncApi.prototype._processRoomEvents = function(room, stateEventList, let oldStateEvents = utils.map( utils.deepCopy( stateEventList.map(function(mxEvent) { - return mxEvent.event; -}) + return mxEvent.event; + }) ), client.getEventMapper() ); let stateEvents = stateEventList; diff --git a/src/timeline-window.js b/src/timeline-window.js index 226eedbab..72d7ca431 100644 --- a/src/timeline-window.js +++ b/src/timeline-window.js @@ -162,12 +162,12 @@ TimelineWindow.prototype.canPaginate = function(direction) { if (direction == EventTimeline.BACKWARDS) { if (tl.index > tl.minIndex()) { - return true; -} + return true; + } } else { if (tl.index < tl.maxIndex()) { - return true; -} + return true; + } } return Boolean(tl.timeline.getNeighbouringTimeline(direction) || diff --git a/src/utils.js b/src/utils.js index e9d3c2ba1..8f13716f8 100644 --- a/src/utils.js +++ b/src/utils.js @@ -29,8 +29,8 @@ module.exports.encodeParams = function(params) { let qs = ""; for (let key in params) { if (!params.hasOwnProperty(key)) { - continue; -} + continue; + } qs += "&" + encodeURIComponent(key) + "=" + encodeURIComponent(params[key]); } @@ -48,8 +48,8 @@ module.exports.encodeParams = function(params) { module.exports.encodeUri = function(pathTemplate, variables) { for (let key in variables) { if (!variables.hasOwnProperty(key)) { - continue; -} + continue; + } pathTemplate = pathTemplate.replace( key, encodeURIComponent(variables[key]) ); @@ -99,8 +99,8 @@ module.exports.keys = function(obj) { let keys = []; for (let key in obj) { if (!obj.hasOwnProperty(key)) { - continue; -} + continue; + } keys.push(key); } return keys; @@ -115,8 +115,8 @@ module.exports.values = function(obj) { let values = []; for (let key in obj) { if (!obj.hasOwnProperty(key)) { - continue; -} + continue; + } values.push(obj[key]); } return values; @@ -237,8 +237,8 @@ module.exports.checkObjectHasKeys = function(obj, keys) { module.exports.checkObjectHasNoAdditionalKeys = function(obj, allowedKeys) { for (let key in obj) { if (!obj.hasOwnProperty(key)) { - continue; -} + continue; + } if (allowedKeys.indexOf(key) === -1) { throw new Error("Unknown key: " + key); }