From fa47c3c4a88d9d02e7b53d826d5745cdc5ff2fa3 Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Tue, 2 Nov 2021 09:22:11 -0700 Subject: [PATCH] Normalize ++x to x++. (#5660) There are only 10 instances of ++x in our codebase, compared with over 500 instances of x++. The stlye guide has no opinion on which to use, nor do I. But the lack of consistency was making regex searches for bugs more difficult. --- core/block.js | 2 +- core/extensions.js | 2 +- core/field_dropdown.js | 2 +- core/input.js | 2 +- core/utils.js | 2 +- generators/dart/logic.js | 2 +- generators/javascript/logic.js | 2 +- generators/lua/logic.js | 2 +- generators/php/logic.js | 2 +- generators/python/logic.js | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/block.js b/core/block.js index 8a0521c081c..1b4fc04d918 100644 --- a/core/block.js +++ b/core/block.js @@ -1612,7 +1612,7 @@ Block.prototype.jsonInit = function(json) { const extensionNames = json['extensions']; if (Array.isArray(extensionNames)) { - for (let j = 0; j < extensionNames.length; ++j) { + for (let j = 0; j < extensionNames.length; j++) { Extensions.apply(extensionNames[j], this, false); } } diff --git a/core/extensions.js b/core/extensions.js index f8c939c9e56..c5ba089d94b 100644 --- a/core/extensions.js +++ b/core/extensions.js @@ -426,7 +426,7 @@ const checkDropdownOptionsInTable = function(block, dropdownName, lookupTable) { const dropdown = block.getField(dropdownName); if (!dropdown.isOptionListDynamic()) { const options = dropdown.getOptions(); - for (let i = 0; i < options.length; ++i) { + for (let i = 0; i < options.length; i++) { const optionKey = options[i][1]; // label, then value if (lookupTable[optionKey] === null) { console.warn( diff --git a/core/field_dropdown.js b/core/field_dropdown.js index 924c7f9993b..c200c0faa4e 100644 --- a/core/field_dropdown.js +++ b/core/field_dropdown.js @@ -742,7 +742,7 @@ const validateOptions = function(options) { throw TypeError('FieldDropdown options must not be an empty array.'); } let foundError = false; - for (let i = 0; i < options.length; ++i) { + for (let i = 0; i < options.length; i++) { const tuple = options[i]; if (!Array.isArray(tuple)) { foundError = true; diff --git a/core/input.js b/core/input.js index 8f805d6f770..e1bc3b5fbd5 100644 --- a/core/input.js +++ b/core/input.js @@ -135,7 +135,7 @@ Input.prototype.insertFieldAt = function(index, field, opt_name) { } // Add the field to the field row. this.fieldRow.splice(index, 0, field); - ++index; + index++; if (field.suffixField) { // Add any suffix. index = this.insertFieldAt(index, field.suffixField); diff --git a/core/utils.js b/core/utils.js index 1f1e061df8d..5fdf5de1d0d 100644 --- a/core/utils.js +++ b/core/utils.js @@ -418,7 +418,7 @@ const tokenizeInterpolation_ = function(message, parseInterpolationTokens) { // Merge adjacent text tokens into a single string. const mergedTokens = []; buffer.length = 0; - for (let i = 0; i < tokens.length; ++i) { + for (let i = 0; i < tokens.length; i++) { if (typeof tokens[i] === 'string') { buffer.push(tokens[i]); } else { diff --git a/generators/dart/logic.js b/generators/dart/logic.js index 51993700799..ac493646e4e 100644 --- a/generators/dart/logic.js +++ b/generators/dart/logic.js @@ -33,7 +33,7 @@ Blockly.Dart['controls_if'] = function(block) { } code += (n > 0 ? 'else ' : '') + 'if (' + conditionCode + ') {\n' + branchCode + '}'; - ++n; + n++; } while (block.getInput('IF' + n)); if (block.getInput('ELSE') || Blockly.Dart.STATEMENT_SUFFIX) { diff --git a/generators/javascript/logic.js b/generators/javascript/logic.js index 50f293f06bd..4162ea06ad0 100644 --- a/generators/javascript/logic.js +++ b/generators/javascript/logic.js @@ -34,7 +34,7 @@ Blockly.JavaScript['controls_if'] = function(block) { } code += (n > 0 ? ' else ' : '') + 'if (' + conditionCode + ') {\n' + branchCode + '}'; - ++n; + n++; } while (block.getInput('IF' + n)); if (block.getInput('ELSE') || Blockly.JavaScript.STATEMENT_SUFFIX) { diff --git a/generators/lua/logic.js b/generators/lua/logic.js index abeccb50bfb..510866f370a 100644 --- a/generators/lua/logic.js +++ b/generators/lua/logic.js @@ -33,7 +33,7 @@ Blockly.Lua['controls_if'] = function(block) { } code += (n > 0 ? 'else' : '') + 'if ' + conditionCode + ' then\n' + branchCode; - ++n; + n++; } while (block.getInput('IF' + n)); if (block.getInput('ELSE') || Blockly.Lua.STATEMENT_SUFFIX) { diff --git a/generators/php/logic.js b/generators/php/logic.js index 57647273852..b36c3ac6d4b 100644 --- a/generators/php/logic.js +++ b/generators/php/logic.js @@ -33,7 +33,7 @@ Blockly.PHP['controls_if'] = function(block) { } code += (n > 0 ? ' else ' : '') + 'if (' + conditionCode + ') {\n' + branchCode + '}'; - ++n; + n++; } while (block.getInput('IF' + n)); if (block.getInput('ELSE') || Blockly.PHP.STATEMENT_SUFFIX) { diff --git a/generators/python/logic.js b/generators/python/logic.js index b8673b6037b..dfde8856183 100644 --- a/generators/python/logic.js +++ b/generators/python/logic.js @@ -33,7 +33,7 @@ Blockly.Python['controls_if'] = function(block) { Blockly.Python.INDENT) + branchCode; } code += (n === 0 ? 'if ' : 'elif ') + conditionCode + ':\n' + branchCode; - ++n; + n++; } while (block.getInput('IF' + n)); if (block.getInput('ELSE') || Blockly.Python.STATEMENT_SUFFIX) {