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