Remove usage of ++ outside of for loops update

The usage of postfix ++ is somewhat obscure in its meaning.  It's better
to be explicit here.
This commit is contained in:
Hornwitser committed 2020-11-07 18:16:24 +01:00
1 parent 3ce32ba870
commit 5337280eec
8 files changed
+21 -14

No files matched your search

+1 -1
View File
@@ -177,7 +177,7 @@ module.exports = {
"no-octal-escape": "error",
"no-param-reassign": "off",
"no-path-concat": "error",
"no-plusplus": ["warn", { "allowForLoopAfterthoughts": true }],
"no-plusplus": ["error", { "allowForLoopAfterthoughts": true }],
"no-process-env": "error",
"no-process-exit": "warn",
"no-proto": "error",
+1 -1
View File
@@ -152,7 +152,7 @@ function reorderDependencies(modules) {
// No unmet dependencies, record and continue
present.set(module.name, module.version);
index++;
index += 1;
if (hold.has(module.name)) {
modules.splice(index, 0, ...hold.get(module.name));
+9 -5
View File
@@ -34,7 +34,7 @@ class WebSocketBaseConnector extends events.EventEmitter {
let dropCount = 0;
for (let index = 0; index < this._sendBuffer.length; index++) {
if (this._sendBuffer[index].seq <= seq) {
dropCount++;
dropCount += 1;
} else {
break;
}
@@ -102,12 +102,14 @@ class WebSocketBaseConnector extends events.EventEmitter {
if (!["handshake", "connected", "closing"].includes(this._state)) {
throw new libErrors.SessionLost("No session");
}
let message = { seq: this._seq, type, data };
let seq = this._seq;
this._seq += 1;
let message = { seq, type, data };
this._sendBuffer.push(message);
if (["connected", "closing"].includes(this._state)) {
this._socket.send(JSON.stringify(message));
}
return this._seq++;
return seq;
}
/**
@@ -450,8 +452,10 @@ class VirtualConnector extends events.EventEmitter {
* @returns {number} the sequence number of the message sent
*/
send(type, data) {
this.other.emit("message", { seq: this._seq, type, data });
return this._seq++;
let seq = this._seq;
this._seq += 1;
this.other.emit("message", { seq, type, data });
return seq;
}
}
+2 -1
View File
@@ -1429,7 +1429,8 @@ async function handleHandshake(message, socket, req, attachHandler) {
return;
}
let sessionId = nextSessionId++;
let sessionId = nextSessionId;
nextSessionId += 1;
let sessionToken = jwt.sign({ aud: masterSession, sid: sessionId }, masterConfig.get("master.auth_secret"));
let connector = new WebSocketServerConnector(socket, sessionId);
activeConnectors.set(sessionId, connector);
+2 -2
View File
@@ -46,7 +46,7 @@ describe("global_chat plugin", function() {
instancePlugin.instance.connector.sentMessages = [];
await instancePlugin.onOutput(output);
assert(instancePlugin.instance.connector.sentMessages.length, "message was not sent");
count++;
count += 1;
}
}
assert(count > 0, "no lines were tested");
@@ -58,7 +58,7 @@ describe("global_chat plugin", function() {
instancePlugin.instance.connector.sentMessages = [];
await instancePlugin.onOutput(output);
assert(!instancePlugin.instance.connector.sentMessages.length, "message was sent");
count++;
count += 1;
}
}
assert(count > 0, "no lines were tested");
+1 -1
View File
@@ -24,7 +24,7 @@ describe("Integration of lib/factorio/export", function() {
// Value is always a string, nearly always truthy
if (!value) {
empty_keys++;
empty_keys += 1;
}
assert.equal(typeof value, "string");
}
+1 -1
View File
@@ -199,7 +199,7 @@ describe("lib/factorio", function() {
} catch (err) { }
if (success) {
validate(modules);
successCount++;
successCount += 1;
}
}
+4 -2
View File
@@ -58,10 +58,12 @@ class MockConnector extends events.EventEmitter {
}
send(type, data) {
let message = { seq: this._seq, type, data };
let seq = this._seq;
this._seq += 1;
let message = { seq, type, data };
this.sentMessages.push(message);
setImmediate(() => this.emit("send", message));
return this._seq++;
return seq;
}
}