mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 08:23:29 +00:00
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
This commit is contained in:
parent
b8d198eeed
commit
140350d767
694 changed files with 23283 additions and 12499 deletions
|
@ -467,8 +467,9 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
|
|||
exp_beg = true;
|
||||
|
||||
} else if ((c == '-' || c == '+') && !exp_sign && !exp_beg) {
|
||||
if (c == '-')
|
||||
if (c == '-') {
|
||||
is_float = true;
|
||||
}
|
||||
exp_sign = true;
|
||||
|
||||
} else {
|
||||
|
@ -477,8 +478,9 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
|
|||
} break;
|
||||
}
|
||||
|
||||
if (reading == READING_DONE)
|
||||
if (reading == READING_DONE) {
|
||||
break;
|
||||
}
|
||||
num += String::chr(c);
|
||||
c = GET_CHAR();
|
||||
}
|
||||
|
@ -487,10 +489,11 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
|
|||
|
||||
r_token.type = TK_CONSTANT;
|
||||
|
||||
if (is_float)
|
||||
if (is_float) {
|
||||
r_token.value = num.to_double();
|
||||
else
|
||||
} else {
|
||||
r_token.value = num.to_int();
|
||||
}
|
||||
return OK;
|
||||
|
||||
} else if ((cchar >= 'A' && cchar <= 'Z') || (cchar >= 'a' && cchar <= 'z') || cchar == '_') {
|
||||
|
@ -619,8 +622,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
|
|||
|
||||
Token tk;
|
||||
_get_token(tk);
|
||||
if (error_set)
|
||||
if (error_set) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
switch (tk.type) {
|
||||
case TK_CURLY_BRACKET_OPEN: {
|
||||
|
@ -636,8 +640,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
|
|||
str_ofs = cofs; //revert
|
||||
//parse an expression
|
||||
ENode *expr2 = _parse_expression();
|
||||
if (!expr2)
|
||||
if (!expr2) {
|
||||
return nullptr;
|
||||
}
|
||||
dn->dict.push_back(expr2);
|
||||
|
||||
_get_token(tk);
|
||||
|
@ -647,8 +652,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
|
|||
}
|
||||
|
||||
expr2 = _parse_expression();
|
||||
if (!expr2)
|
||||
if (!expr2) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
dn->dict.push_back(expr2);
|
||||
|
||||
|
@ -679,8 +685,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
|
|||
str_ofs = cofs; //revert
|
||||
//parse an expression
|
||||
ENode *expr2 = _parse_expression();
|
||||
if (!expr2)
|
||||
if (!expr2) {
|
||||
return nullptr;
|
||||
}
|
||||
an->array.push_back(expr2);
|
||||
|
||||
cofs = str_ofs;
|
||||
|
@ -699,8 +706,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
|
|||
case TK_PARENTHESIS_OPEN: {
|
||||
//a suexpression
|
||||
ENode *e = _parse_expression();
|
||||
if (error_set)
|
||||
if (error_set) {
|
||||
return nullptr;
|
||||
}
|
||||
_get_token(tk);
|
||||
if (tk.type != TK_PARENTHESIS_CLOSE) {
|
||||
_set_error("Expected ')'");
|
||||
|
@ -760,8 +768,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
|
|||
str_ofs = cofs; //revert
|
||||
//parse an expression
|
||||
ENode *expr2 = _parse_expression();
|
||||
if (!expr2)
|
||||
if (!expr2) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
constructor->arguments.push_back(expr2);
|
||||
|
||||
|
@ -800,8 +809,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
|
|||
str_ofs = cofs; //revert
|
||||
//parse an expression
|
||||
ENode *expr2 = _parse_expression();
|
||||
if (!expr2)
|
||||
if (!expr2) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bifunc->arguments.push_back(expr2);
|
||||
|
||||
|
@ -850,8 +860,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
|
|||
while (true) {
|
||||
int cofs2 = str_ofs;
|
||||
_get_token(tk);
|
||||
if (error_set)
|
||||
if (error_set) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool done = false;
|
||||
|
||||
|
@ -863,8 +874,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
|
|||
index->base = expr;
|
||||
|
||||
ENode *what = _parse_expression();
|
||||
if (!what)
|
||||
if (!what) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
index->index = what;
|
||||
|
||||
|
@ -903,8 +915,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
|
|||
str_ofs = cofs3; //revert
|
||||
//parse an expression
|
||||
ENode *expr2 = _parse_expression();
|
||||
if (!expr2)
|
||||
if (!expr2) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
func_call->arguments.push_back(expr2);
|
||||
|
||||
|
@ -937,8 +950,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
|
|||
} break;
|
||||
}
|
||||
|
||||
if (done)
|
||||
if (done) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//push expression
|
||||
|
@ -953,8 +967,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
|
|||
|
||||
int cofs = str_ofs;
|
||||
_get_token(tk);
|
||||
if (error_set)
|
||||
if (error_set) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Variant::Operator op = Variant::OP_MAX;
|
||||
|
||||
|
@ -1217,8 +1232,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
|
|||
}
|
||||
|
||||
bool VisualScriptExpression::_compile_expression() {
|
||||
if (!expression_dirty)
|
||||
if (!expression_dirty) {
|
||||
return error_set;
|
||||
}
|
||||
|
||||
if (nodes) {
|
||||
memdelete(nodes);
|
||||
|
@ -1271,15 +1287,17 @@ public:
|
|||
|
||||
Variant a;
|
||||
bool ret = _execute(p_inputs, op->nodes[0], a, r_error_str, ce);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Variant b;
|
||||
|
||||
if (op->nodes[1]) {
|
||||
ret = _execute(p_inputs, op->nodes[1], b, r_error_str, ce);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool valid = true;
|
||||
|
@ -1295,14 +1313,16 @@ public:
|
|||
|
||||
Variant base;
|
||||
bool ret = _execute(p_inputs, index->base, base, r_error_str, ce);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Variant idx;
|
||||
|
||||
ret = _execute(p_inputs, index->index, idx, r_error_str, ce);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool valid;
|
||||
r_ret = base.get(idx, &valid);
|
||||
|
@ -1317,8 +1337,9 @@ public:
|
|||
|
||||
Variant base;
|
||||
bool ret = _execute(p_inputs, index->base, base, r_error_str, ce);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool valid;
|
||||
r_ret = base.get_named(index->name, &valid);
|
||||
|
@ -1336,8 +1357,9 @@ public:
|
|||
for (int i = 0; i < array->array.size(); i++) {
|
||||
Variant value;
|
||||
bool ret = _execute(p_inputs, array->array[i], value, r_error_str, ce);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
arr[i] = value;
|
||||
}
|
||||
|
||||
|
@ -1351,13 +1373,15 @@ public:
|
|||
for (int i = 0; i < dictionary->dict.size(); i += 2) {
|
||||
Variant key;
|
||||
bool ret = _execute(p_inputs, dictionary->dict[i + 0], key, r_error_str, ce);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Variant value;
|
||||
ret = _execute(p_inputs, dictionary->dict[i + 1], value, r_error_str, ce);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
|
||||
d[key] = value;
|
||||
}
|
||||
|
@ -1375,8 +1399,9 @@ public:
|
|||
for (int i = 0; i < constructor->arguments.size(); i++) {
|
||||
Variant value;
|
||||
bool ret = _execute(p_inputs, constructor->arguments[i], value, r_error_str, ce);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
arr.write[i] = value;
|
||||
argp.write[i] = &arr[i];
|
||||
}
|
||||
|
@ -1400,8 +1425,9 @@ public:
|
|||
for (int i = 0; i < bifunc->arguments.size(); i++) {
|
||||
Variant value;
|
||||
bool ret = _execute(p_inputs, bifunc->arguments[i], value, r_error_str, ce);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
arr.write[i] = value;
|
||||
argp.write[i] = &arr[i];
|
||||
}
|
||||
|
@ -1419,8 +1445,9 @@ public:
|
|||
|
||||
Variant base;
|
||||
bool ret = _execute(p_inputs, call->base, base, r_error_str, ce);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Vector<Variant> arr;
|
||||
Vector<const Variant *> argp;
|
||||
|
@ -1430,8 +1457,9 @@ public:
|
|||
for (int i = 0; i < call->arguments.size(); i++) {
|
||||
Variant value;
|
||||
bool ret2 = _execute(p_inputs, call->arguments[i], value, r_error_str, ce);
|
||||
if (ret2)
|
||||
if (ret2) {
|
||||
return true;
|
||||
}
|
||||
arr.write[i] = value;
|
||||
argp.write[i] = &arr[i];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue